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
e25754e2
Commit
e25754e2
authored
Mar 16, 2015
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update assessments format when serializing.
parent
2754222e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
openassessment/xblock/data_conversion.py
+3
-2
openassessment/xblock/test/test_xml.py
+3
-4
openassessment/xblock/xml.py
+3
-2
No files found.
openassessment/xblock/data_conversion.py
View file @
e25754e2
...
...
@@ -83,9 +83,10 @@ def update_assessments_format(assessments):
list of dict
"""
for
assessment
in
assessments
:
if
'examples'
in
assessment
:
if
'examples'
in
assessment
and
assessment
[
'examples'
]
:
for
example
in
assessment
[
'examples'
]:
if
isinstance
(
example
[
'answer'
],
unicode
)
or
isinstance
(
example
[
'answer'
],
str
):
if
(
isinstance
(
example
,
dict
)
and
(
isinstance
(
example
[
'answer'
],
unicode
)
or
isinstance
(
example
[
'answer'
],
str
))):
example
[
'answer'
]
=
{
'parts'
:
[
{
'text'
:
example
[
'answer'
]}
...
...
openassessment/xblock/test/test_xml.py
View file @
e25754e2
...
...
@@ -120,9 +120,8 @@ class TestSerializeContent(TestCase):
self
.
oa_block
.
submission_start
=
data
.
get
(
'submission_start'
)
self
.
oa_block
.
submission_due
=
data
.
get
(
'submission_due'
)
self
.
oa_block
.
rubric_criteria
=
data
.
get
(
'criteria'
,
copy
.
deepcopy
(
self
.
BASIC_CRITERIA
))
self
.
oa_block
.
rubric_assessments
=
update_assessments_format
(
data
.
get
(
'assessments'
,
copy
.
deepcopy
(
self
.
BASIC_ASSESSMENTS
))
)
self
.
oa_block
.
rubric_assessments
=
data
.
get
(
'assessments'
,
copy
.
deepcopy
(
self
.
BASIC_ASSESSMENTS
))
self
.
oa_block
.
allow_file_upload
=
data
.
get
(
'allow_file_upload'
)
self
.
oa_block
.
allow_latex
=
data
.
get
(
'allow_latex'
)
self
.
oa_block
.
leaderboard_show
=
data
.
get
(
'leaderboard_show'
,
0
)
...
...
@@ -231,7 +230,7 @@ class TestSerializeContent(TestCase):
def
test_mutated_assessments_dict
(
self
):
self
.
_configure_xblock
({})
for
assessment_dict
in
update_assessments_format
(
self
.
BASIC_ASSESSMENTS
)
:
for
assessment_dict
in
self
.
BASIC_ASSESSMENTS
:
for
mutated_dict
in
self
.
_dict_mutations
(
assessment_dict
):
self
.
oa_block
.
rubric_assessments
=
[
mutated_dict
]
xml
=
serialize_content
(
self
.
oa_block
)
...
...
openassessment/xblock/xml.py
View file @
e25754e2
...
...
@@ -6,6 +6,7 @@ import lxml.etree as etree
import
pytz
import
dateutil.parser
import
defusedxml.ElementTree
as
safe_etree
from
data_conversion
import
update_assessments_format
from
defaults
import
DEFAULT_RUBRIC_FEEDBACK_TEXT
...
...
@@ -630,7 +631,7 @@ def serialize_assessments(assessments_root, oa_block):
None
"""
for
assessment_dict
in
oa_block
.
rubric_assessments
:
for
assessment_dict
in
update_assessments_format
(
oa_block
.
rubric_assessments
)
:
assessment
=
etree
.
SubElement
(
assessments_root
,
'assessment'
)
...
...
@@ -760,7 +761,7 @@ def serialize_examples_to_xml_str(assessment):
A unicode string of the XML serialized examples.
"""
examples
=
assessment
.
get
(
'examples'
,
[])
examples
=
update_assessments_format
([
assessment
])[
0
]
.
get
(
'examples'
,
[])
if
not
isinstance
(
examples
,
list
):
examples
=
[]
examples_root
=
etree
.
Element
(
'examples'
)
...
...
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