Commit ca9e48ae by Eric Fischer

Handle legacy problem definitions

parent f7faec7b
...@@ -126,7 +126,7 @@ class OpenAssessmentBlock(MessageMixin, ...@@ -126,7 +126,7 @@ class OpenAssessmentBlock(MessageMixin,
help="ISO-8601 formatted string representing the submission due date." help="ISO-8601 formatted string representing the submission due date."
) )
text_response = String( text_response_raw = String(
help="Specify whether learners must include a text based response to this problem's prompt.", help="Specify whether learners must include a text based response to this problem's prompt.",
default="required", default="required",
scope=Scope.settings scope=Scope.settings
...@@ -245,6 +245,24 @@ class OpenAssessmentBlock(MessageMixin, ...@@ -245,6 +245,24 @@ class OpenAssessmentBlock(MessageMixin,
return self._serialize_opaque_key(self.xmodule_runtime.course_id) # pylint:disable=E1101 return self._serialize_opaque_key(self.xmodule_runtime.course_id) # pylint:disable=E1101
@property @property
def text_response(self):
"""
Backward compatibility for existing blocks that were created without text_response
or file_upload_response fields. These blocks will be treated as required text.
"""
if not self.file_upload_response and not self.text_response_raw:
return 'required'
else:
return self.text_response_raw
@text_response.setter
def text_response(self, value):
"""
Setter for text_response_raw
"""
self.text_response_raw = value if value else None
@property
def file_upload_response(self): def file_upload_response(self):
""" """
Backward compatibility for existing block before that were created without Backward compatibility for existing block before that were created without
......
<openassessment>
<title>Open Assessment Test</title>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty? Please answer in a short essay of 200-300 words.</description>
</prompt>
</prompts>
<rubric>
<criterion>
<name>Concise</name>
<prompt>How concise is it?</prompt>
<option points="0">
<name>Neal Stephenson (late)</name>
<explanation>Neal Stephenson explanation</explanation>
</option>
<option points="1">
<name>HP Lovecraft</name>
<explanation>HP Lovecraft explanation</explanation>
</option>
</criterion>
</rubric>
<assessments>
<assessment name="peer-assessment" must_grade="1" must_be_graded_by="1" />
<assessment name="self-assessment" />
</assessments>
</openassessment>
...@@ -452,6 +452,13 @@ class TestOpenAssessment(XBlockHandlerTestCase): ...@@ -452,6 +452,13 @@ class TestOpenAssessment(XBlockHandlerTestCase):
xblock.prompts = [{'description': 'Prompt 4.'}, {'description': 'Prompt 5.'}] xblock.prompts = [{'description': 'Prompt 4.'}, {'description': 'Prompt 5.'}]
self.assertEqual(xblock.prompt, '[{"description": "Prompt 4."}, {"description": "Prompt 5."}]') self.assertEqual(xblock.prompt, '[{"description": "Prompt 4."}, {"description": "Prompt 5."}]')
@scenario('data/neither_response_type.xml')
def test_no_response_type(self, xblock):
"""
Ensure that legacy courses will still load properly.
"""
self.assertEqual(xblock.text_response, 'required')
class TestDates(XBlockHandlerTestCase): class TestDates(XBlockHandlerTestCase):
......
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