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
2891ea4b
Commit
2891ea4b
authored
Jan 04, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert away from self.system to just using system
parent
6e7dae4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
29 deletions
+30
-29
common/lib/xmodule/xmodule/open_ended_module.py
+30
-29
No files found.
common/lib/xmodule/xmodule/open_ended_module.py
View file @
2891ea4b
...
...
@@ -28,6 +28,7 @@ from .stringify import stringify_children
from
.x_module
import
XModule
from
.xml_module
import
XmlDescriptor
from
xmodule.modulestore
import
Location
from
capa.util
import
*
log
=
logging
.
getLogger
(
"mitx.courseware"
)
...
...
@@ -139,9 +140,9 @@ class OpenEndedModule():
if
rubric
is
None
:
raise
ValueError
(
"No rubric found in problem xml."
)
self
.
_parse
(
oeparam
,
prompt
,
rubric
)
self
.
_parse
(
oeparam
,
prompt
,
rubric
,
system
)
def
_parse
(
self
,
oeparam
,
prompt
,
rubric
):
def
_parse
(
self
,
oeparam
,
prompt
,
rubric
,
system
):
'''
Parse OpenEndedResponse XML:
self.initial_display
...
...
@@ -151,8 +152,8 @@ class OpenEndedModule():
self.answer - What to display when show answer is clicked
'''
# Note that OpenEndedResponse is agnostic to the specific contents of grader_payload
prompt_string
=
s
elf
.
s
tringify_children
(
prompt
)
rubric_string
=
s
elf
.
s
tringify_children
(
rubric
)
prompt_string
=
stringify_children
(
prompt
)
rubric_string
=
stringify_children
(
rubric
)
grader_payload
=
oeparam
.
find
(
'grader_payload'
)
grader_payload
=
grader_payload
.
text
if
grader_payload
is
not
None
else
''
...
...
@@ -170,8 +171,8 @@ class OpenEndedModule():
self
.
answer
=
find_with_default
(
oeparam
,
'answer_display'
,
'No answer given.'
)
parsed_grader_payload
.
update
({
'location'
:
s
elf
.
s
ystem
.
location
,
'course_id'
:
s
elf
.
s
ystem
.
course_id
,
'location'
:
system
.
location
,
'course_id'
:
system
.
course_id
,
'prompt'
:
prompt_string
,
'rubric'
:
rubric_string
,
'initial_display'
:
self
.
initial_display
,
...
...
@@ -186,15 +187,15 @@ class OpenEndedModule():
except
ValueError
:
self
.
max_score
=
1
def
handle_message_post
(
self
,
get
):
def
handle_message_post
(
self
,
get
,
system
):
"""
Handles a student message post (a reaction to the grade they received from an open ended grader type)
Returns a boolean success/fail and an error message
"""
event_info
=
dict
()
event_info
[
'problem_id'
]
=
s
elf
.
location
.
url
()
event_info
[
'student_id'
]
=
s
elf
.
s
ystem
.
anonymous_student_id
event_info
[
'problem_id'
]
=
s
ystem
.
location
.
url
()
event_info
[
'student_id'
]
=
system
.
anonymous_student_id
event_info
[
'survey_responses'
]
=
get
survey_responses
=
event_info
[
'survey_responses'
]
...
...
@@ -212,15 +213,15 @@ class OpenEndedModule():
log
.
exception
(
error_message
)
return
False
,
"There was an error saving your feedback. Please contact course staff."
qinterface
=
s
elf
.
s
ystem
.
xqueue
[
'interface'
]
qinterface
=
system
.
xqueue
[
'interface'
]
qtime
=
datetime
.
strftime
(
datetime
.
now
(),
xqueue_interface
.
dateformat
)
anonymous_student_id
=
s
elf
.
s
ystem
.
anonymous_student_id
queuekey
=
xqueue_interface
.
make_hashkey
(
str
(
s
elf
.
s
ystem
.
seed
)
+
qtime
+
anonymous_student_id
=
system
.
anonymous_student_id
queuekey
=
xqueue_interface
.
make_hashkey
(
str
(
system
.
seed
)
+
qtime
+
anonymous_student_id
+
self
.
answer_id
)
xheader
=
xqueue_interface
.
make_xheader
(
lms_callback_url
=
s
elf
.
s
ystem
.
xqueue
[
'callback_url'
],
lms_callback_url
=
system
.
xqueue
[
'callback_url'
],
lms_key
=
queuekey
,
queue_name
=
self
.
message_queue_name
)
...
...
@@ -246,7 +247,7 @@ class OpenEndedModule():
return
success
,
"Successfully submitted your feedback."
def
get_score
(
self
,
student_answers
):
def
get_score
(
self
,
student_answers
,
system
):
try
:
submission
=
student_answers
[
self
.
answer_id
]
except
KeyError
:
...
...
@@ -258,17 +259,17 @@ class OpenEndedModule():
# Prepare xqueue request
#------------------------------------------------------------
qinterface
=
s
elf
.
s
ystem
.
xqueue
[
'interface'
]
qinterface
=
system
.
xqueue
[
'interface'
]
qtime
=
datetime
.
strftime
(
datetime
.
now
(),
xqueue_interface
.
dateformat
)
anonymous_student_id
=
s
elf
.
s
ystem
.
anonymous_student_id
anonymous_student_id
=
system
.
anonymous_student_id
# Generate header
queuekey
=
xqueue_interface
.
make_hashkey
(
str
(
s
elf
.
s
ystem
.
seed
)
+
qtime
+
queuekey
=
xqueue_interface
.
make_hashkey
(
str
(
system
.
seed
)
+
qtime
+
anonymous_student_id
+
self
.
answer_id
)
xheader
=
xqueue_interface
.
make_xheader
(
lms_callback_url
=
s
elf
.
s
ystem
.
xqueue
[
'callback_url'
],
xheader
=
xqueue_interface
.
make_xheader
(
lms_callback_url
=
system
.
xqueue
[
'callback_url'
],
lms_key
=
queuekey
,
queue_name
=
self
.
queue_name
)
...
...
@@ -510,7 +511,7 @@ class OpenEndedModule():
return
ScoreMessage
(
valid
=
True
,
correct
=
correct
,
points
=
score_result
[
'score'
],
msg
=
feedback
)
def
handle_ajax
(
self
,
dispatch
,
get
):
def
handle_ajax
(
self
,
dispatch
,
get
,
system
):
'''
This is called by courseware.module_render, to handle an AJAX call.
"get" is request.POST.
...
...
@@ -532,7 +533,7 @@ class OpenEndedModule():
return
'Error'
before
=
self
.
get_progress
()
d
=
handlers
[
dispatch
](
get
)
d
=
handlers
[
dispatch
](
get
,
system
)
after
=
self
.
get_progress
()
d
.
update
({
'progress_changed'
:
after
!=
before
,
...
...
@@ -540,17 +541,17 @@ class OpenEndedModule():
})
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
def
get_problem
(
self
,
get
):
return
self
.
get_html
()
def
get_problem
(
self
,
get
,
system
):
return
self
.
get_html
(
system
)
def
reset_problem
(
self
,
get
):
def
reset_problem
(
self
,
get
,
system
):
self
.
change_state
(
self
.
INITIAL
)
return
{
'success'
:
True
}
def
save_problem
(
self
,
get
):
def
save_problem
(
self
,
get
,
system
):
pass
def
update_score
(
self
,
get
):
def
update_score
(
self
,
get
,
system
):
"""
Delivers grading response (e.g. from asynchronous code checking) to
the capa problem, so its score can be updated
...
...
@@ -563,11 +564,11 @@ class OpenEndedModule():
queuekey
=
get
[
'queuekey'
]
score_msg
=
get
[
'xqueue_body'
]
#TODO: Remove need for cmap
self
.
_update_score
(
score_msg
,
queuekey
)
self
.
_update_score
(
score_msg
,
queuekey
,
system
)
return
dict
()
# No AJAX return is needed
def
get_html
(
self
):
def
get_html
(
self
,
system
):
"""
Implement special logic: handle queueing state, and default input.
"""
...
...
@@ -593,7 +594,7 @@ class OpenEndedModule():
'value'
:
self
.
value
,
}
html
=
s
elf
.
s
ystem
.
render_template
(
"open_ended.html"
,
context
)
html
=
system
.
render_template
(
"open_ended.html"
,
context
)
return
html
def
change_state
(
self
,
new_state
):
...
...
@@ -659,7 +660,7 @@ class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor):
def
parse
(
k
):
"""Assumes that xml_object has child k"""
return
stringify_children
(
xml_object
.
xpath
(
k
)[
0
])
return
xml_object
.
xpath
(
k
)[
0
]
return
{
'rubric'
:
parse
(
'openendedrubric'
),
'prompt'
:
parse
(
'prompt'
),
...
...
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