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
54687d45
Commit
54687d45
authored
Nov 01, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing javascript ajax path issues
parent
b263117c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
148 deletions
+42
-148
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+1
-0
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+18
-141
common/lib/xmodule/xmodule/self_assessment_module.py
+23
-7
No files found.
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
54687d45
...
...
@@ -209,6 +209,7 @@ class @Problem
show
:
=>
if
!
@
el
.
hasClass
'showed'
Logger
.
log
'problem_show'
,
problem
:
@
id
alert
(
@
url
)
$
.
postWithPrefix
"
#{
@
url
}
/problem_show"
,
(
response
)
=>
answers
=
response
.
answers
$
.
each
answers
,
(
key
,
value
)
=>
...
...
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
54687d45
class
@
SelfAssessment
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.sa-wrapper'
)
@
id
=
@
el
.
data
(
'sa-id'
)
@
element_id
=
@
el
.
attr
(
'id'
)
@
url
=
@
el
.
data
(
'url'
)
@
render
()
#@$('section.action input.check').click @check
$
(
'input#show'
).
click
(
@
show
)
#$('#save').click(function -> alert('save'))
$
:
(
selector
)
->
$
(
selector
,
@
el
)
$
(
document
).
on
(
'click'
,
'input#save'
,
(
->
answer
=
$
(
'#answer'
).
text
()
$
.
postWithPrefix
"modx/6.002x/sa_save"
,
answer
,
(
response
)
->
if
response
.
success
$
(
'p.rubric'
).
replace
(
response
.
rubric
)
bind
:
=>
alert
(
"save"
)
));
window
.
update_schematics
()
show
:
=>
alert
(
"show"
)
#$.postWithPrefix "/sa_show", (response) =>
# answers = response.answers
# @el.addClass 'showed'
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
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
()
save
:
=>
alert
(
"save"
)
alert
(
$
(
'input#save'
).
attr
(
'url'
))
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
54687d45
...
...
@@ -19,9 +19,6 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
log
=
logging
.
getLogger
(
"mitx.courseware"
)
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
=
(
'<section class="sa-wrapper" sa_id="two"><input type="radio" name="assessment" value="correct"/>Correct<br/>'
'<input type="radio" name="assessment" value="incorrect">'
'Incorrect<br/><input type="button" value="Save" id="show" name="show"/></section>'
)
...
...
@@ -61,6 +58,11 @@ class SelfAssessmentModule(XModule):
self
.
rubric
=
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'rubric'
))])
self
.
problem
=
''
.
join
([
etree
.
tostring
(
child
)
for
child
in
only_one
(
dom2
.
xpath
(
'problem'
))])
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" url="{0}"/>'
'<p id="rubric"></p></section>'
)
.
format
(
self
.
location
)
self
.
problem
=
''
.
join
([
self
.
problem
,
problem_form
])
self
.
rubric
=
''
.
join
([
self
.
rubric
,
rubric_form
])
...
...
@@ -70,6 +72,9 @@ class SelfAssessmentModule(XModule):
self
.
html
=
self
.
problem
self
.
answers
=
{}
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
This is called by courseware.module_render, to handle an AJAX call.
...
...
@@ -106,14 +111,25 @@ class SelfAssessmentModule(XModule):
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
}
event_info
[
'state'
]
=
{
'seed'
:
1
,
'student_answers'
:
self
.
answers
,
'correct_map'
:
{
'self_assess'
:
{
'correctness'
:
False
,
'npoints'
:
0
,
'msg'
:
""
,
'hint'
:
""
,
'hintmode'
:
""
,
'queuestate'
:
""
,
}},
'done'
:
True
}
event_info
[
'problem_id'
]
=
self
.
location
.
url
()
answers
=
self
.
make_dict_of_responses
(
get
)
event_info
[
'answers'
]
=
answers
self
.
system
.
track_function
(
'save_problem_succeed'
,
event_info
)
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
class
SelfAssessmentDescriptor
(
XmlDescriptor
,
EditingDescriptor
):
...
...
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