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
ec4507df
Commit
ec4507df
authored
Nov 01, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed ajax value passing to function
parent
1c2ec275
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
43 deletions
+8
-43
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+1
-12
common/lib/xmodule/xmodule/self_assessment_module.py
+7
-31
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
ec4507df
...
...
@@ -9,23 +9,12 @@ $(document).on('click', 'section.sa-wrapper input#show', ( ->
));
$
(
document
).
on
(
'click'
,
'section.sa-wrapper input#save'
,
(
->
answer
=
$
(
'section.sa-wrapper input#answer'
).
val
()
assessment
=
0
assessment_correct
=
$
(
'section.sa-wrapper #assessment'
).
find
(
':selected'
).
text
()
alert
(
assessment_correct
)
root
=
location
.
protocol
+
"//"
+
location
.
host
post_url
=
$
(
'section.sa-wrapper input#show'
).
attr
(
'url'
)
final_url
=
"/courses/MITx/6.002x/2012_Fall/modx/
#{
post_url
}
/sa_save"
$
(
'section.sa-wrapper input#assessment option'
).
each
(
->
if
(
this
.
selected
)
alert
(
'this option is selected'
)
else
alert
(
'this is not'
)
);
$
.
post
final_url
,
answer
,
(
response
)
->
$
.
post
final_url
,
assessment_correct
,
(
response
)
->
if
response
.
success
$
(
'section.sa_wrapper p#save_message'
).
replace
(
response
.
message
)
...
...
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
ec4507df
...
...
@@ -72,7 +72,7 @@ class SelfAssessmentModule(XModule):
self
.
problem
=
''
.
join
([
self
.
problem
,
problem_form
])
self
.
rubric
=
''
.
join
([
self
.
rubric
,
rubric_form
])
self
.
html
=
self
.
problem
self
.
answer
s
=
{}
self
.
answer
=
""
self
.
score
=
0
self
.
top_score
=
1
...
...
@@ -124,22 +124,23 @@ class SelfAssessmentModule(XModule):
})
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
def
show_rubric
(
self
,
get
):
self
.
answer
=
get
.
keys
()[
0
]
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
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.
'''
correctness
=
get
.
keys
()[
0
]
log
.
debug
(
correctness
)
event_info
=
dict
()
event_info
[
'state'
]
=
{
'seed'
:
1
,
'student_answers'
:
self
.
answers
,
'correct_map'
:
{
'self_assess'
:
{
'correctness'
:
False
,
'correct_map'
:
{
'self_assess'
:
{
'correctness'
:
correctness
,
'npoints'
:
0
,
'msg'
:
""
,
'hint'
:
""
,
...
...
@@ -150,37 +151,12 @@ class SelfAssessmentModule(XModule):
event_info
[
'problem_id'
]
=
self
.
location
.
url
()
answers
=
self
.
make_dict_of_responses
(
get
)
log
.
debug
(
answers
)
event_info
[
'answers'
]
=
answers
event_info
[
'answers'
]
=
self
.
answer
self
.
system
.
track_function
(
'save_problem_succeed'
,
event_info
)
return
{
'success'
:
True
,
'message'
:
"Save Succcesful. Thanks for participating!"
}
@staticmethod
def
make_dict_of_responses
(
get
):
'''Make dictionary of student responses (aka "answers")
get is POST dictionary.
'''
answers
=
dict
()
for
key
in
get
:
# e.g. input_resistor_1 ==> resistor_1
_
,
_
,
name
=
key
.
partition
(
'_'
)
# This allows for answers which require more than one value for
# the same form input (e.g. checkbox inputs). The convention is that
# if the name ends with '[]' (which looks like an array), then the
# answer will be an array.
if
not
name
.
endswith
(
'[]'
):
answers
[
name
]
=
get
[
key
]
else
:
name
=
name
[:
-
2
]
answers
[
name
]
=
get
.
getlist
(
key
)
return
answers
class
SelfAssessmentDescriptor
(
XmlDescriptor
,
EditingDescriptor
):
"""
Module for putting raw html in a course
...
...
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