Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
1b8b8871
Commit
1b8b8871
authored
Dec 08, 2017
by
Alex Dusenbery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1817 | be defensive about serializing training examples, log an exception when it occurs.
parent
8c195c0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
openassessment/xblock/xml.py
+19
-3
No files found.
openassessment/xblock/xml.py
View file @
1b8b8871
...
...
@@ -2,6 +2,7 @@
Serialize and deserialize OpenAssessment XBlock content to/from XML.
"""
from
uuid
import
uuid4
as
uuid
import
logging
import
dateutil.parser
import
defusedxml.ElementTree
as
safe_etree
...
...
@@ -11,6 +12,9 @@ import pytz
from
openassessment.xblock.data_conversion
import
update_assessments_format
log
=
logging
.
getLogger
(
__name__
)
class
UpdateFromXmlError
(
Exception
):
"""
Error occurred while deserializing the OpenAssessment XBlock content from XML.
...
...
@@ -606,9 +610,21 @@ def serialize_training_examples(examples, assessment_el):
# Answer provided in the example (default to empty string)
answer_el
=
etree
.
SubElement
(
example_el
,
'answer'
)
for
part
in
example_dict
.
get
(
'answer'
,
{})
.
get
(
'parts'
,
[]):
part_el
=
etree
.
SubElement
(
answer_el
,
'part'
)
part_el
.
text
=
unicode
(
part
.
get
(
'text'
,
u''
))
try
:
answer
=
example_dict
.
get
(
'answer'
)
if
answer
is
None
:
parts
=
[]
elif
isinstance
(
answer
,
dict
):
parts
=
answer
.
get
(
'parts'
,
[])
elif
isinstance
(
answer
,
list
):
parse
=
answer
for
part
in
example_dict
.
get
(
'answer'
,
{})
.
get
(
'parts'
,
[]):
part_el
=
etree
.
SubElement
(
answer_el
,
'part'
)
part_el
.
text
=
unicode
(
part
.
get
(
'text'
,
u''
))
except
:
# excuse the bare-except, looking for more information on EDUCATOR-1817
log
.
exception
(
'Error parsing training exapmle:
%
s'
,
example_dict
)
raise
# Options selected from the rubric
options_selected
=
example_dict
.
get
(
'options_selected'
,
[])
...
...
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