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
941ef528
Commit
941ef528
authored
Nov 07, 2012
by
Vik Paruchuri
Committed by
Victor Shnayder
Nov 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs, fix some logic
parent
dba8a7a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
common/lib/capa/capa/responsetypes.py
+16
-12
No files found.
common/lib/capa/capa/responsetypes.py
View file @
941ef528
...
...
@@ -1867,8 +1867,8 @@ class OpenEndedResponse(LoncapaResponse):
grader_payload
=
json
.
dumps
(
grader_payload
)
except
Exception
as
err
:
log
.
error
(
"Grader payload is not a json object!"
)
self
.
payload
=
{
'grader_payload'
:
grader_payload
}
self
.
payload
=
{
'grader_payload'
:
grader_payload
}
#Parse initial display
initial_display
=
oeparam
.
find
(
'initial_display'
)
...
...
@@ -1882,16 +1882,15 @@ class OpenEndedResponse(LoncapaResponse):
if
answer_display
is
not
None
:
self
.
answer
=
answer_display
.
text
else
:
self
.
answer
=
"No answer
available
."
self
.
answer
=
"No answer
given
."
def
get_score
(
self
,
student_answers
):
try
:
# Note that submission can be a file
submission
=
student_answers
[
self
.
answer_id
]
except
Exception
as
err
:
log
.
error
(
'Error in OpenEndedResponse
%
s: cannot get student answer for
%
s;'
' student_answers=
%
s'
%
(
err
,
self
.
answer_id
,
convert_files_to_filenames
(
student_answers
)))
' student_answers=
%
s'
,
err
,
self
.
answer_id
)
raise
Exception
(
err
)
# Prepare xqueue request
...
...
@@ -1906,6 +1905,7 @@ class OpenEndedResponse(LoncapaResponse):
queuekey
=
xqueue_interface
.
make_hashkey
(
str
(
self
.
system
.
seed
)
+
qtime
+
anonymous_student_id
+
self
.
answer_id
)
xheader
=
xqueue_interface
.
make_xheader
(
lms_callback_url
=
self
.
system
.
xqueue
[
'callback_url'
],
lms_key
=
queuekey
,
queue_name
=
self
.
queue_name
)
...
...
@@ -1918,11 +1918,11 @@ class OpenEndedResponse(LoncapaResponse):
student_info
=
{
'anonymous_student_id'
:
anonymous_student_id
,
'submission_time'
:
qtime
,
}
contents
.
update
({
'student_info'
:
json
.
dumps
(
student_info
)})
#
Submit request. When successful, 'msg' is the prior length of the queue
contents
.
update
({
'student_response'
:
submission
})
#
Update contents with student response and student info
contents
.
update
({
'student_
info'
:
json
.
dumps
(
student_info
),
'student_
response'
:
submission
})
# Submit request. When successful, 'msg' is the prior length of the queue
(
error
,
msg
)
=
qinterface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
...
...
@@ -1988,7 +1988,9 @@ class OpenEndedResponse(LoncapaResponse):
Grader reply is a JSON-dump of the following dict
{ 'correct': True/False,
'score': Numeric value (floating point is okay) to assign to answer
'msg': grader_msg }
'msg': grader_msg
'feedback' : feedback from grader
}
Returns (valid_score_msg, correct, score, msg):
valid_score_msg: Flag indicating valid score_msg format (Boolean)
...
...
@@ -2012,22 +2014,24 @@ class OpenEndedResponse(LoncapaResponse):
log
.
error
(
"External grader message is missing one or more required"
" tags: 'correct', 'score', 'msg', 'feedback"
)
return
fail
#Extract feedback from score_result
feedback
=
score_result
[
'feedback'
]
# Next, we need to check that the contents of the external grader message
# is safe for the LMS.
# 1) Make sure that the message is valid XML (proper opening/closing tags)
# 2) TODO: Is the message actually HTML?
msg
=
score_result
[
'msg'
]
feedback
=
score_result
[
'feedback'
]
try
:
etree
.
fromstring
(
msg
)
etree
.
fromstring
(
feedback
)
except
etree
.
XMLSyntaxError
as
err
:
log
.
error
(
"Unable to parse external grader message as valid"
" XML: score_msg['msg']=
%
s"
%
msg
)
" Msg: score_msg['msg']=
%
r "
"
\n
Feedback : score_result['feedback'] =
%
r"
,
msg
,
feedback
)
return
fail
#Currently ignore msg and only return feedback (which takes the place of msg)
return
(
True
,
score_result
[
'correct'
],
score_result
[
'score'
],
feedback
)
#-----------------------------------------------------------------------------
...
...
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