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
e6b57fcd
Commit
e6b57fcd
authored
Sep 03, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make show answer work for choicegroups + javascriptinputs
parent
8f4b599a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
3 deletions
+54
-3
common/lib/capa/capa/templates/choicegroup.html
+1
-1
common/lib/capa/capa/templates/javascriptinput.html
+1
-1
common/lib/xmodule/xmodule/css/capa/display.scss
+6
-0
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+46
-1
No files found.
common/lib/capa/capa/templates/choicegroup.html
View file @
e6b57fcd
<form
class=
"choicegroup"
>
<form
class=
"choicegroup
capa_inputtype"
id=
"inputtype_${id}
"
>
% for choice_id, choice_description in choices:
% for choice_id, choice_description in choices:
<label
for=
"input_${id}_${choice_id}"
>
<input
type=
"${input_type}"
name=
"input_${id}${name_array_suffix}"
id=
"input_${id}_${choice_id}"
value=
"${choice_id}"
<label
for=
"input_${id}_${choice_id}"
>
<input
type=
"${input_type}"
name=
"input_${id}${name_array_suffix}"
id=
"input_${id}_${choice_id}"
value=
"${choice_id}"
...
...
common/lib/capa/capa/templates/javascriptinput.html
View file @
e6b57fcd
<form
class=
"javascriptinput capa_inputtype"
>
<form
class=
"javascriptinput capa_inputtype"
id=
"inputtype_${id}"
>
<input
type=
"hidden"
name=
"input_${id}"
id=
"input_${id}"
class=
"javascriptinput_input"
/>
<input
type=
"hidden"
name=
"input_${id}"
id=
"input_${id}"
class=
"javascriptinput_input"
/>
<div
class=
"javascriptinput_data"
data-display_class=
"${display_class}"
<div
class=
"javascriptinput_data"
data-display_class=
"${display_class}"
data-problem_state=
"${problem_state}"
data-params=
"${params}"
data-problem_state=
"${problem_state}"
data-params=
"${params}"
...
...
common/lib/xmodule/xmodule/css/capa/display.scss
View file @
e6b57fcd
...
@@ -32,6 +32,12 @@ section.problem {
...
@@ -32,6 +32,12 @@ section.problem {
display
:
inline
;
display
:
inline
;
}
}
.choicegroup
{
label
.choicegroup_correct
:after
{
content
:
url('../images/correct-icon.png')
;
}
}
div
{
div
{
p
{
p
{
...
...
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
e6b57fcd
...
@@ -84,11 +84,14 @@ class @Problem
...
@@ -84,11 +84,14 @@ class @Problem
# stuff if a div w a class is found
# stuff if a div w a class is found
setupInputTypes
:
=>
setupInputTypes
:
=>
@
inputtypeDisplays
=
{}
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
id
=
$
(
inputtype
).
attr
(
'id'
)
for
cls
in
classes
for
cls
in
classes
setupMethod
=
@
inputtypeSetupMethods
[
cls
]
setupMethod
=
@
inputtypeSetupMethods
[
cls
]
setupMethod
(
inputtype
)
if
setupMethod
?
if
setupMethod
?
@
inputtypeDisplays
[
id
]
=
setupMethod
(
inputtype
)
executeProblemScripts
:
(
callback
=
null
)
->
executeProblemScripts
:
(
callback
=
null
)
->
...
@@ -248,6 +251,17 @@ class @Problem
...
@@ -248,6 +251,17 @@ class @Problem
@
$
(
"label[for='input_
#{
key
}
_
#{
choice
}
']"
).
attr
correct_answer
:
'true'
@
$
(
"label[for='input_
#{
key
}
_
#{
choice
}
']"
).
attr
correct_answer
:
'true'
else
else
@
$
(
"#answer_
#{
key
}
, #solution_
#{
key
}
"
).
html
(
value
)
@
$
(
"#answer_
#{
key
}
, #solution_
#{
key
}
"
).
html
(
value
)
# TODO remove the above once everything is extracted into its own
# inputtype functions.
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
for
cls
in
classes
display
=
@
inputtypeDisplays
[
$
(
inputtype
).
attr
(
'id'
)]
showMethod
=
@
inputtypeShowAnswerMethods
[
cls
]
showMethod
(
inputtype
,
display
,
answers
)
if
showMethod
?
MathJax
.
Hub
.
Queue
[
"Typeset"
,
MathJax
.
Hub
]
MathJax
.
Hub
.
Queue
[
"Typeset"
,
MathJax
.
Hub
]
@
$
(
'.show'
).
val
'Hide Answer'
@
$
(
'.show'
).
val
'Hide Answer'
@
el
.
addClass
'showed'
@
el
.
addClass
'showed'
...
@@ -258,6 +272,13 @@ class @Problem
...
@@ -258,6 +272,13 @@ class @Problem
@
el
.
removeClass
'showed'
@
el
.
removeClass
'showed'
@
$
(
'.show'
).
val
'Show Answer'
@
$
(
'.show'
).
val
'Show Answer'
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
display
=
@
inputtypeDisplays
[
$
(
inputtype
).
attr
(
'id'
)]
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
for
cls
in
classes
hideMethod
=
@
inputtypeHideAnswerMethods
[
cls
]
hideMethod
(
inputtype
,
display
)
if
hideMethod
?
gentle_alert
:
(
msg
)
=>
gentle_alert
:
(
msg
)
=>
if
@
el
.
find
(
'.capa_alert'
).
length
if
@
el
.
find
(
'.capa_alert'
).
length
@
el
.
find
(
'.capa_alert'
).
remove
()
@
el
.
find
(
'.capa_alert'
).
remove
()
...
@@ -314,3 +335,27 @@ class @Problem
...
@@ -314,3 +335,27 @@ class @Problem
display
=
new
displayClass
(
problemState
,
submission
,
evaluation
,
container
,
submissionField
,
params
)
display
=
new
displayClass
(
problemState
,
submission
,
evaluation
,
container
,
submissionField
,
params
)
display
.
render
()
display
.
render
()
return
display
inputtypeShowAnswerMethods
:
choicegroup
:
(
element
,
display
,
answers
)
=>
element
=
$
(
element
)
for
key
,
value
of
answers
element
.
find
(
'input'
).
attr
(
'disabled'
,
'disabled'
)
for
choice
in
value
element
.
find
(
"label[for='input_
#{
key
}
_
#{
choice
}
']"
).
addClass
'choicegroup_correct'
javascriptinput
:
(
element
,
display
,
answers
)
=>
answer_id
=
$
(
element
).
attr
(
'id'
).
split
(
"_"
)[
1
...].
join
(
"_"
)
answer
=
JSON
.
parse
(
answers
[
answer_id
])
display
.
showAnswer
(
answer
)
inputtypeHideAnswerMethods
:
choicegroup
:
(
element
,
display
)
=>
element
=
$
(
element
)
element
.
find
(
'input'
).
attr
(
'disabled'
,
null
)
element
.
find
(
'label'
).
removeClass
(
'choicegroup_correct'
)
javascriptinput
:
(
element
,
display
)
=>
display
.
hideAnswer
()
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