Commit 246b8945 by Usman Khalid

Serialize prompts.

parent 4ccd5860
...@@ -168,7 +168,7 @@ def _serialize_criteria(criteria_root, criteria_list): ...@@ -168,7 +168,7 @@ def _serialize_criteria(criteria_root, criteria_list):
_serialize_options(criterion_el, options_list) _serialize_options(criterion_el, options_list)
def serialize_rubric(rubric_root, oa_block, include_prompt=False): def serialize_rubric(rubric_root, oa_block):
""" """
Serialize a rubric dictionary as XML, adding children to the XML Serialize a rubric dictionary as XML, adding children to the XML
with root node `rubric_root`. with root node `rubric_root`.
...@@ -182,17 +182,9 @@ def serialize_rubric(rubric_root, oa_block, include_prompt=False): ...@@ -182,17 +182,9 @@ def serialize_rubric(rubric_root, oa_block, include_prompt=False):
rubric_dict (dict): A dictionary representation of the rubric, of the form rubric_dict (dict): A dictionary representation of the rubric, of the form
described in the serialized Rubric model (peer grading serializers). described in the serialized Rubric model (peer grading serializers).
Kwargs:
include_prompt (bool): Whether or not to include the prompt in the
serialized format for a rubric. Defaults to True.
Returns: Returns:
None None
""" """
# Rubric prompt (default to empty text); None indicates no input element
if include_prompt and oa_block.prompt is not None:
prompt = etree.SubElement(rubric_root, 'prompt')
prompt.text = unicode(oa_block.prompt)
# Criteria # Criteria
criteria_list = oa_block.rubric_criteria criteria_list = oa_block.rubric_criteria
...@@ -702,6 +694,10 @@ def serialize_content_to_xml(oa_block, root): ...@@ -702,6 +694,10 @@ def serialize_content_to_xml(oa_block, root):
assessments_root = etree.SubElement(root, 'assessments') assessments_root = etree.SubElement(root, 'assessments')
serialize_assessments(assessments_root, oa_block) serialize_assessments(assessments_root, oa_block)
# Prompts
prompts_root = etree.SubElement(root, 'prompts')
_serialize_prompts(prompts_root, oa_block)
# Rubric # Rubric
rubric_root = etree.SubElement(root, 'rubric') rubric_root = etree.SubElement(root, 'rubric')
serialize_rubric(rubric_root, oa_block) serialize_rubric(rubric_root, oa_block)
...@@ -740,7 +736,7 @@ def serialize_rubric_to_xml_str(oa_block): ...@@ -740,7 +736,7 @@ def serialize_rubric_to_xml_str(oa_block):
""" """
rubric_root = etree.Element('rubric') rubric_root = etree.Element('rubric')
serialize_rubric(rubric_root, oa_block, include_prompt=False) serialize_rubric(rubric_root, oa_block)
return etree.tostring(rubric_root, pretty_print=True, encoding='unicode') return etree.tostring(rubric_root, pretty_print=True, encoding='unicode')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment