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
c406be8c
Commit
c406be8c
authored
Aug 26, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check grader message has proper XML structure
parent
c1cd0758
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
common/lib/capa/capa/responsetypes.py
+16
-4
No files found.
common/lib/capa/capa/responsetypes.py
View file @
c406be8c
...
...
@@ -1165,7 +1165,7 @@ class CodeResponse(LoncapaResponse):
(
valid_score_msg
,
correct
,
points
,
msg
)
=
self
.
_parse_score_msg
(
score_msg
)
if
not
valid_score_msg
:
oldcmap
.
set
(
self
.
answer_id
,
msg
=
'
Error: Invalid grader reply
.'
)
oldcmap
.
set
(
self
.
answer_id
,
msg
=
'
Invalid grader reply. Please contact the course staff
.'
)
return
oldcmap
correctness
=
'correct'
if
correct
else
'incorrect'
...
...
@@ -1203,10 +1203,10 @@ class CodeResponse(LoncapaResponse):
Returns (valid_score_msg, correct, score, msg):
valid_score_msg: Flag indicating valid score_msg format (Boolean)
correct: Correctness of submission (Boolean)
score:
# TODO: Implement partial grading
score:
Points to be assigned (numeric, can be float)
msg: Message from grader to display to student (string)
'''
fail
=
(
False
,
False
,
-
1
,
''
)
fail
=
(
False
,
False
,
0
,
''
)
try
:
score_result
=
json
.
loads
(
score_msg
)
except
(
TypeError
,
ValueError
):
...
...
@@ -1216,7 +1216,19 @@ class CodeResponse(LoncapaResponse):
for
tag
in
[
'correct'
,
'score'
,
'msg'
]:
if
not
score_result
.
has_key
(
tag
):
return
fail
return
(
True
,
score_result
[
'correct'
],
score_result
[
'score'
],
score_result
[
'msg'
])
# 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'
]
try
:
etree
.
fromstring
(
msg
)
except
etree
.
XMLSyntaxError
as
err
:
log
.
error
(
"Unable to parse external grader message as valid XML: score_msg['msg']=
%
s"
%
msg
)
return
fail
return
(
True
,
score_result
[
'correct'
],
score_result
[
'score'
],
msg
)
#-----------------------------------------------------------------------------
...
...
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