Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3896fb09
Commit
3896fb09
authored
Apr 16, 2014
by
Valera Rozuvan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3354 from edx/valera/l63b
Fix for BLD-993
parents
cf759414
9e8941f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletions
+26
-1
common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee
+14
-0
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+12
-1
No files found.
common/lib/xmodule/xmodule/js/spec/capa/display_spec.coffee
View file @
3896fb09
...
...
@@ -255,6 +255,20 @@ describe 'Problem', ->
expect
(
$
(
'.show .show-label'
)).
toHaveText
'Hide Answer'
expect
(
window
.
SR
.
readElts
).
toHaveBeenCalled
()
it
'toggle the show answer button, answers are strings'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
answers
:
'1_1'
:
'One'
,
'1_2'
:
'Two'
)
@
problem
.
show
()
expect
(
$
(
'.show .show-label'
)).
toHaveText
'Hide Answer'
expect
(
window
.
SR
.
readElts
).
toHaveBeenCalledWith
[
'<p>Answer: One</p>'
,
'<p>Answer: Two</p>'
]
it
'toggle the show answer button, answers are elements'
,
->
answer1
=
'<div><span class="detailed-solution">one</span></div>'
answer2
=
'<div><span class="detailed-solution">two</span></div>'
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
answers
:
'1_1'
:
answer1
,
'1_2'
:
answer2
)
@
problem
.
show
()
expect
(
$
(
'.show .show-label'
)).
toHaveText
'Hide Answer'
expect
(
window
.
SR
.
readElts
).
toHaveBeenCalledWith
[
jasmine
.
any
(
jQuery
),
jasmine
.
any
(
jQuery
)]
it
'add the showed class to element'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
answers
:
{})
@
problem
.
show
()
...
...
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
3896fb09
...
...
@@ -342,7 +342,18 @@ class @Problem
answer
=
@
$
(
"#answer_
#{
key
}
, #solution_
#{
key
}
"
)
answer
.
html
(
value
)
Collapsible
.
setCollapsibles
(
answer
)
solution
=
$
(
value
).
find
(
'.detailed-solution'
)
# Sometimes, `value` is just a string containing a MathJax formula.
# If this is the case, jQuery will throw an error in some corner cases
# because of an incorrect selector. We setup a try..catch so that
# the script doesn't break in such cases.
#
# We will fallback to the second `if statement` below, if an
# error is thrown by jQuery.
try
solution
=
$
(
value
).
find
(
'.detailed-solution'
)
catch
e
solution
=
{}
if
solution
.
length
answer_text
.
push
(
solution
)
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment