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
b263117c
Commit
b263117c
authored
Oct 31, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing coffee file
parent
d31e8606
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
171 additions
and
24 deletions
+171
-24
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+147
-20
common/lib/xmodule/xmodule/js/src/selfassessment/display.js
+20
-0
common/lib/xmodule/xmodule/self_assessment_module.py
+4
-4
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
b263117c
show
:
=>
Logger
.
log
'sa_show'
,
problem
:
@
id
$
.
postWithPrefix
"
#{
@
url
}
/sa_show"
,
(
response
)
=>
answers
=
response
.
answers
$
.
each
answers
,
(
key
,
value
)
=>
if
$
.
isArray
(
value
)
for
choice
in
value
@
$
(
"label[for='input_
#{
key
}
_
#{
choice
}
']"
).
attr
correct_answer
:
'true'
class
@
SelfAssessment
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.sa-wrapper'
)
@
id
=
@
el
.
data
(
'sa-id'
)
@
element_id
=
@
el
.
attr
(
'id'
)
@
url
=
@
el
.
data
(
'url'
)
@
render
()
$
:
(
selector
)
->
$
(
selector
,
@
el
)
bind
:
=>
window
.
update_schematics
()
problem_prefix
=
@
element_id
.
replace
(
/sa_/
,
''
)
@
inputs
=
@
$
(
"[id^=input_
#{
problem_prefix
}
_]"
)
@
$
(
'input:button'
).
click
@
refreshAnswers
#@$('section.action input.check').click @check
@
$
(
'input.show'
).
click
@
show
@
$
(
'input.save'
).
click
@
save
# Collapsibles
Collapsible
.
setCollapsibles
(
@
el
)
# Dynamath
@
$
(
'input.math'
).
keyup
(
@
refreshMath
)
@
$
(
'input.math'
).
each
(
index
,
element
)
=>
MathJax
.
Hub
.
Queue
[
@
refreshMath
,
null
,
element
]
updateProgress
:
(
response
)
=>
if
response
.
progress_changed
@
el
.
attr
progress
:
response
.
progress_status
@
el
.
trigger
(
'progressChanged'
)
show
:
=>
$
.
postWithPrefix
"
#{
@
url
}
/sa_show"
,
(
response
)
=>
answers
=
response
.
answers
@
el
.
addClass
'showed'
save
:
=>
$
.
postWithPrefix
"/sa_save"
,
@
answers
,
(
response
)
=>
if
response
.
success
@
$
(
'p.rubric'
).
replace
(
response
.
rubric
)
render
:
(
content
)
->
if
content
@
el
.
html
(
content
)
JavascriptLoader
.
executeModuleScripts
@
el
,
()
=>
@
setupInputTypes
()
@
bind
()
else
$
.
postWithPrefix
"
#{
@
url
}
/problem_get"
,
(
response
)
=>
@
el
.
html
(
response
.
html
)
JavascriptLoader
.
executeModuleScripts
@
el
,
()
=>
@
setupInputTypes
()
@
bind
()
setupInputTypes
:
=>
@
inputtypeDisplays
=
{}
@
el
.
find
(
".capa_inputtype"
).
each
(
index
,
inputtype
)
=>
classes
=
$
(
inputtype
).
attr
(
'class'
).
split
(
' '
)
id
=
$
(
inputtype
).
attr
(
'id'
)
for
cls
in
classes
setupMethod
=
@
inputtypeSetupMethods
[
cls
]
if
setupMethod
?
@
inputtypeDisplays
[
id
]
=
setupMethod
(
inputtype
)
gentle_alert
:
(
msg
)
=>
if
@
el
.
find
(
'.capa_alert'
).
length
@
el
.
find
(
'.capa_alert'
).
remove
()
alert_elem
=
"<div class='capa_alert'>"
+
msg
+
"</div>"
@
el
.
find
(
'.action'
).
after
(
alert_elem
)
@
el
.
find
(
'.capa_alert'
).
css
(
opacity
:
0
).
animate
(
opacity
:
1
,
700
)
refreshAnswers
:
=>
@
$
(
'input.schematic'
).
each
(
index
,
element
)
->
element
.
schematic
.
update_value
()
@
$
(
".CodeMirror"
).
each
(
index
,
element
)
->
element
.
CodeMirror
.
save
()
if
element
.
CodeMirror
.
save
@
answers
=
@
inputs
.
serialize
()
inputtypeSetupMethods
:
'text-input-dynamath'
:
(
element
)
=>
###
Return: function (eqn) -> eqn that preprocesses the user formula input before
it is fed into MathJax. Return 'false' if no preprocessor specified
###
data
=
$
(
element
).
find
(
'.text-input-dynamath_data'
)
preprocessorClassName
=
data
.
data
(
'preprocessor'
)
preprocessorClass
=
window
[
preprocessorClassName
]
if
not
preprocessorClass
?
return
false
else
answer
=
@
$
(
"#answer_
#{
key
}
, #solution_
#{
key
}
"
)
answer
.
html
(
value
)
Collapsible
.
setCollapsibles
(
answer
)
@
$
(
'.show'
).
val
'Hide Answer'
@
el
.
addClass
'showed'
save
:
=>
Logger
.
log
'sa_save'
,
@
answers
$
.
postWithPrefix
"
#{
@
url
}
/sa_save"
,
@
answers
,
(
response
)
=>
if
response
.
success
@
$
(
'p.rubric'
).
replace
(
response
.
rubric
)
preprocessor
=
new
preprocessorClass
()
return
preprocessor
.
fn
javascriptinput
:
(
element
)
=>
data
=
$
(
element
).
find
(
".javascriptinput_data"
)
params
=
data
.
data
(
"params"
)
submission
=
data
.
data
(
"submission"
)
evaluation
=
data
.
data
(
"evaluation"
)
problemState
=
data
.
data
(
"problem_state"
)
displayClass
=
window
[
data
.
data
(
'display_class'
)]
if
evaluation
==
''
evaluation
=
null
container
=
$
(
element
).
find
(
".javascriptinput_container"
)
submissionField
=
$
(
element
).
find
(
".javascriptinput_input"
)
display
=
new
displayClass
(
problemState
,
submission
,
evaluation
,
container
,
submissionField
,
params
)
display
.
render
()
return
display
inputtypeShowAnswerMethods
:
choicegroup
:
(
element
,
display
,
answers
)
=>
element
=
$
(
element
)
element
.
find
(
'input'
).
attr
(
'disabled'
,
'disabled'
)
input_id
=
element
.
attr
(
'id'
).
replace
(
/inputtype_/
,
''
)
answer
=
answers
[
input_id
]
for
choice
in
answer
element
.
find
(
"label[for='input_
#{
input_id
}
_
#{
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
()
common/lib/xmodule/xmodule/js/src/selfassessment/display.js
0 → 100644
View file @
b263117c
show
:
function
()
{
Logger
.
log
(
'sa_show'
,
{
problem
:
_this
.
id
});
return
$
.
postWithPrefix
(
""
+
_this
.
url
+
"/sa_show"
,
function
(
response
)
{
var
answers
;
answers
=
response
.
answers
;
return
_this
.
el
.
addClass
(
'showed'
);
});
}
save
:
function
()
{
Logger
.
log
(
'sa_save'
,
_this
.
answers
);
return
$
.
postWithPrefix
(
""
+
_this
.
url
+
"/sa_save"
,
_this
.
answers
,
function
(
response
)
{
if
(
response
.
success
)
{
return
_this
.
$
(
'p.rubric'
).
replace
(
response
.
rubric
);
}
});
}
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
b263117c
...
...
@@ -19,12 +19,12 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
log
=
logging
.
getLogger
(
"mitx.courseware"
)
problem_form
=
(
'<
form action="save()
"><input type="text" name="answer" '
'id="answer"/><br/><input type="
submit" value="Check" id ="save"/></form><p id="rubric"></p
>'
)
problem_form
=
(
'<
section class="sa-wrapper" sa_id="one
"><input type="text" name="answer" '
'id="answer"/><br/><input type="
button" value="Check" id ="save" name="save"/><p id="rubric"></p></section
>'
)
rubric_form
=
(
'<
form action="show()
"><input type="radio" name="assessment" value="correct"/>Correct<br/>'
rubric_form
=
(
'<
section class="sa-wrapper" sa_id="two
"><input type="radio" name="assessment" value="correct"/>Correct<br/>'
'<input type="radio" name="assessment" value="incorrect">'
'Incorrect<
input type="submit" value="Submit" id="show"/></form
>'
)
'Incorrect<
br/><input type="button" value="Save" id="show" name="show"/></section
>'
)
def
only_one
(
lst
,
default
=
""
,
process
=
lambda
x
:
x
):
"""
...
...
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