Commit 88046f00 by Eric Fischer Committed by GitHub

Merge pull request #1043 from edx/ri/fix-learning-training-assessment-access

EDUCATOR-1263 Fix Learner Training Assessment assess
parents b0a9f6d3 f4986a86
......@@ -92,7 +92,7 @@ def update_assessments_format(assessments):
{'text': example['answer']}
]
}
if isinstance(example, dict) and isinstance(example['answer'], list) and example['answer'] > 0 :
if isinstance(example, dict) and isinstance(example['answer'], list) and example['answer']:
example['answer'] = {
'parts': [
{'text': example['answer'][0]}
......
......@@ -129,7 +129,11 @@ class StudentTrainingMixin(object):
examples
)
if example:
context['training_essay'] = create_submission_dict({'answer': example['answer']}, self.prompts)
# EDUCATOR-1263: some entries may be in an incorrect format, load them anyways
if isinstance(example, dict) and isinstance(example['answer'], list) and isinstance(example['answer'][0], basestring):
context['training_essay'] = create_submission_dict({'answer': {'parts': [{'text': example['answer'][0]}]}}, self.prompts)
else:
context['training_essay'] = create_submission_dict({'answer': example['answer']}, self.prompts)
context['training_rubric'] = {
'criteria': example['rubric']['criteria'],
'points_possible': example['rubric']['points_possible']
......
......@@ -55,6 +55,8 @@ class DataConversionTest(TestCase):
@ddt.data(
([{'answer': 'Ans'}], [{'answer': {'parts': [{'text': 'Ans'}]}}]),
([{'answer': ['Ans']}], [{'answer': {'parts': [{'text': 'Ans'}]}}]),
([{'answer': []}], [{'answer': []}]),
)
@ddt.unpack
def test_update_assessments_format(self, input, output):
......
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