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
68ca1251
Commit
68ca1251
authored
Nov 01, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on save functionality to select only one
parent
d12bc257
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
12 deletions
+40
-12
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+0
-1
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+12
-5
common/lib/xmodule/xmodule/self_assessment_module.py
+28
-6
No files found.
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
68ca1251
...
...
@@ -209,7 +209,6 @@ 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 @
68ca1251
...
...
@@ -3,6 +3,8 @@ $(document).on('click', 'section.sa-wrapper input#show', ( ->
post_url
=
$
(
'section.sa-wrapper input#show'
).
attr
(
'url'
)
final_url
=
"/courses/MITx/6.002x/2012_Fall/modx/
#{
post_url
}
/sa_show"
answer
=
$
(
'section.sa-wrapper input#answer'
).
val
()
alert
(
answer
)
alert
(
final_url
)
$
.
post
final_url
,
answer
,
(
response
)
->
alert
(
"posted"
)
...
...
@@ -15,20 +17,25 @@ $(document).on('click', 'section.sa-wrapper input#save', ( ->
answer
=
$
(
'section.sa-wrapper input#answer'
).
val
()
alert
(
answer
)
assessment
=
0
assessment_correct
=
$
(
'section.sa-wrapper input#assessment_correct'
).
val
()
assessment_correct
=
$
(
'section.sa-wrapper input#assessment_correct'
).
selected
()
alert
(
assessment_correct
)
assessment_incorrect
=
$
(
'section.sa-wrapper input#assessment_incorrect'
).
val
()
assessment_incorrect
=
$
(
'section.sa-wrapper input#assessment_incorrect'
).
selected
()
alert
(
assessment_incorrect
)
root
=
location
.
protocol
+
"//"
+
location
.
host
post_url
=
$
(
'section.sa-wrapper input#show'
).
attr
(
'url'
)
alert
(
post_url
)
final_url
=
"/courses/MITx/6.002x/2012_Fall/modx/
#{
post_url
}
/sa_save"
alert
(
final_url
)
$
(
'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
)
->
if
response
.
success
$
(
'
p.rubric'
).
replace
(
response
.
rubric
)
$
(
'
section.sa_wrapper p#save_message'
).
replace
(
response
.
message
)
alert
(
"save"
)
));
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
68ca1251
...
...
@@ -21,9 +21,9 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
log
=
logging
.
getLogger
(
"mitx.courseware"
)
rubric_form
=
(
'<section class="sa-wrapper"><input type="radio" name="assessment" id="assessment
_correct
" value="correct"/>Correct<br/>'
'<input type="radio" id="assessment
_incorrect
" name="assessment" value="incorrect">'
'Incorrect<br/><input type="button" value="Save" id="save" name="save"/><
/section
>'
)
rubric_form
=
(
'<section class="sa-wrapper"><input type="radio" name="assessment" id="assessment" value="correct"/>Correct<br/>'
'<input type="radio" id="assessment" name="assessment" value="incorrect">'
'Incorrect<br/><input type="button" value="Save" id="save" name="save"/><
p id="save_message"></p></section><br/><br/
>'
)
def
only_one
(
lst
,
default
=
""
,
process
=
lambda
x
:
x
):
"""
...
...
@@ -61,7 +61,7 @@ class SelfAssessmentModule(XModule):
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
,
shared_state
,
**
kwargs
)
dom2
=
etree
.
fromstring
(
"<selfassessment>"
+
self
.
definition
[
'data'
]
+
"</selfassessment>"
)
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'
))])
...
...
@@ -127,7 +127,7 @@ class SelfAssessmentModule(XModule):
def
show_rubric
(
self
,
get
):
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
return
{
'success'
:
True
,
'rubric'
:
self
.
rubric
}
def
save_problem
(
self
,
get
):
...
...
@@ -155,7 +155,29 @@ class SelfAssessmentModule(XModule):
self
.
system
.
track_function
(
'save_problem_succeed'
,
event_info
)
return
{
'success'
:
True
}
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
):
...
...
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