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
a91a571f
Commit
a91a571f
authored
Oct 31, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update javascript
parent
947e6e6e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
76 deletions
+27
-76
common/lib/xmodule/xmodule/capa_module.py
+2
-2
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+5
-68
common/lib/xmodule/xmodule/self_assessment_module.py
+20
-6
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
a91a571f
...
@@ -580,7 +580,7 @@ class CapaModule(XModule):
...
@@ -580,7 +580,7 @@ class CapaModule(XModule):
'contents'
:
html
,
'contents'
:
html
,
}
}
def
save_problem
(
self
,
get
):
def
save_problem
(
self
,
get
):
'''
'''
Save the passed in answers.
Save the passed in answers.
Returns a dict { 'success' : bool, ['error' : error-msg]},
Returns a dict { 'success' : bool, ['error' : error-msg]},
...
@@ -614,7 +614,7 @@ def save_problem(self, get):
...
@@ -614,7 +614,7 @@ def save_problem(self, get):
self
.
system
.
track_function
(
'save_problem_fail'
,
event_info
)
self
.
system
.
track_function
(
'save_problem_fail'
,
event_info
)
return
{
'success'
:
True
}
return
{
'success'
:
True
}
def
reset_problem
(
self
,
get
):
def
reset_problem
(
self
,
get
):
''' Changes problem state to unfinished -- removes student answers,
''' Changes problem state to unfinished -- removes student answers,
and causes problem to rerender itself.
and causes problem to rerender itself.
...
...
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
a91a571f
class
@
Problem
show
:
=>
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.problems-wrapper'
)
@
id
=
@
el
.
data
(
'problem-id'
)
@
element_id
=
@
el
.
attr
(
'id'
)
@
url
=
@
el
.
data
(
'url'
)
@
render
()
$
:
(
selector
)
->
$
(
selector
,
@
el
)
bind
:
=>
problem_prefix
=
@
element_id
.
replace
(
/sa_/
,
''
)
@
inputs
=
@
$
(
"[id^=input_
#{
problem_prefix
}
_]"
)
@
$
(
'section.action input.show'
).
click
@
show
@
$
(
'section.action input.save'
).
click
@
save
render
:
(
content
)
->
if
content
@
el
.
html
(
content
)
JavascriptLoader
.
executeModuleScripts
@
el
,
()
=>
@
setupInputTypes
()
@
bind
()
else
$
.
postWithPrefix
"
#{
@
url
}
/sa_get"
,
(
response
)
=>
@
el
.
html
(
response
.
html
)
JavascriptLoader
.
executeModuleScripts
@
el
,
()
=>
@
setupInputTypes
()
@
bind
()
# TODO add hooks for problem types here by inspecting response.html and doing
# stuff if a div w a class is found
show
:
=>
Logger
.
log
'sa_show'
,
problem
:
@
id
Logger
.
log
'sa_show'
,
problem
:
@
id
$
.
postWithPrefix
"
#{
@
url
}
/sa_show"
,
(
response
)
=>
$
.
postWithPrefix
"
#{
@
url
}
/sa_show"
,
(
response
)
=>
answers
=
response
.
answers
answers
=
response
.
answers
...
@@ -50,35 +14,8 @@ class @Problem
...
@@ -50,35 +14,8 @@ class @Problem
@
$
(
'.show'
).
val
'Hide Answer'
@
$
(
'.show'
).
val
'Hide Answer'
@
el
.
addClass
'showed'
@
el
.
addClass
'showed'
save
:
=>
save
:
=>
Logger
.
log
'problem
_save'
,
@
answers
Logger
.
log
'sa
_save'
,
@
answers
$
.
postWithPrefix
"
#{
@
url
}
/problem
_save"
,
@
answers
,
(
response
)
=>
$
.
postWithPrefix
"
#{
@
url
}
/sa
_save"
,
@
answers
,
(
response
)
=>
if
response
.
success
if
response
.
success
saveMessage
=
"Your answers have been saved but not graded. Hit 'Check' to grade them."
@
$
(
'p.rubric'
).
replace
(
response
.
rubric
)
@
gentle_alert
saveMessage
@
updateProgress
response
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/self_assessment_module.py
View file @
a91a571f
...
@@ -19,12 +19,12 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
...
@@ -19,12 +19,12 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
log
=
logging
.
getLogger
(
"mitx.courseware"
)
log
=
logging
.
getLogger
(
"mitx.courseware"
)
problem_form
=
(
'<form action="s
how
()"><input type="text" name="answer" '
problem_form
=
(
'<form action="s
ave
()"><input type="text" name="answer" '
'id="answer"/><br/><input type="submit" value="Check"
/></form
>'
)
'id="answer"/><br/><input type="submit" value="Check"
id ="save"/></form><p id="rubric"></p
>'
)
rubric_form
=
(
'<form action="s
ave
()"><input type="radio" name="assessment" value="correct"/>Correct<br/>'
rubric_form
=
(
'<form action="s
how
()"><input type="radio" name="assessment" value="correct"/>Correct<br/>'
'<input type="radio" name="assessment" value="incorrect">'
'<input type="radio" name="assessment" value="incorrect">'
'Incorrect<input type="submit" value="Submit"/></form>'
)
'Incorrect<input type="submit" value="Submit"
id="show"
/></form>'
)
def
only_one
(
lst
,
default
=
""
,
process
=
lambda
x
:
x
):
def
only_one
(
lst
,
default
=
""
,
process
=
lambda
x
:
x
):
"""
"""
...
@@ -46,7 +46,7 @@ class SelfAssessmentModule(XModule):
...
@@ -46,7 +46,7 @@ class SelfAssessmentModule(XModule):
resource_string
(
__name__
,
'js/src/selfassessment/display.coffee'
)
resource_string
(
__name__
,
'js/src/selfassessment/display.coffee'
)
]
]
}
}
js_module_name
=
"SelfAssessment
Module
"
js_module_name
=
"SelfAssessment"
def
get_html
(
self
):
def
get_html
(
self
):
# cdodge: perform link substitutions for any references to course static content (e.g. images)
# cdodge: perform link substitutions for any references to course static content (e.g. images)
...
@@ -80,8 +80,9 @@ class SelfAssessmentModule(XModule):
...
@@ -80,8 +80,9 @@ class SelfAssessmentModule(XModule):
'progress' : 'none'/'in_progress'/'done',
'progress' : 'none'/'in_progress'/'done',
<other request-specific values here > }
<other request-specific values here > }
'''
'''
handlers
=
{
handlers
=
{
'sa_get'
:
self
.
show_problem
'sa_get'
:
self
.
show_problem
,
'sa_show'
:
self
.
show_rubric
,
'sa_show'
:
self
.
show_rubric
,
'sa_save'
:
self
.
save_problem
,
'sa_save'
:
self
.
save_problem
,
}
}
...
@@ -98,6 +99,19 @@ class SelfAssessmentModule(XModule):
...
@@ -98,6 +99,19 @@ class SelfAssessmentModule(XModule):
})
})
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
def
save_problem
(
self
,
get
):
'''
Save the passed in answers.
Returns a dict { 'success' : bool, ['error' : error-msg]},
with the error key only present if success is False.
'''
event_info
=
dict
()
event_info
[
'state'
]
=
self
.
lcp
.
get_state
()
event_info
[
'problem_id'
]
=
self
.
location
.
url
()
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
...
...
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