Commit b98f4e02 by Waheed Ahmed

JSON serialization error fixed and added test for it.

ORA-195
parent f3f0e8a5
...@@ -651,7 +651,7 @@ class CombinedOpenEndedV1Module(): ...@@ -651,7 +651,7 @@ class CombinedOpenEndedV1Module():
last_post_evaluation = task.format_feedback_with_evaluation(self.system, last_post_assessment) last_post_evaluation = task.format_feedback_with_evaluation(self.system, last_post_assessment)
last_post_assessment = last_post_evaluation last_post_assessment = last_post_evaluation
try: try:
rubric_data = task._parse_score_msg(task.child_history[-1].get('post_assessment', ""), self.system) rubric_data = task._parse_score_msg(task.child_history[-1].get('post_assessment', "{}"), self.system)
except Exception: except Exception:
log.debug("Could not parse rubric data from child history. " log.debug("Could not parse rubric data from child history. "
"Likely we have not yet initialized a previous step, so this is perfectly fine.") "Likely we have not yet initialized a previous step, so this is perfectly fine.")
......
...@@ -503,6 +503,9 @@ class OpenEndedModule(openendedchild.OpenEndedChild): ...@@ -503,6 +503,9 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
fail['feedback'] = error_message fail['feedback'] = error_message
return fail return fail
if not score_result:
return fail
for tag in ['score', 'feedback', 'grader_type', 'success', 'grader_id', 'submission_id']: for tag in ['score', 'feedback', 'grader_type', 'success', 'grader_id', 'submission_id']:
if tag not in score_result: if tag not in score_result:
# This is a dev_facing_error # This is a dev_facing_error
...@@ -586,7 +589,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): ...@@ -586,7 +589,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
return "" return ""
feedback_dict = self._parse_score_msg( feedback_dict = self._parse_score_msg(
self.child_history[-1].get('post_assessment', ""), self.child_history[-1].get('post_assessment', "{}"),
system, system,
join_feedback=join_feedback join_feedback=join_feedback
) )
...@@ -756,7 +759,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): ...@@ -756,7 +759,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
""" """
attempt = self.child_history[index] attempt = self.child_history[index]
score = attempt.get('score') score = attempt.get('score')
post_assessment_data = self._parse_score_msg(attempt.get('post_assessment'), self.system) post_assessment_data = self._parse_score_msg(attempt.get('post_assessment', "{}"), self.system)
grader_types = post_assessment_data.get('grader_types') grader_types = post_assessment_data.get('grader_types')
# According to _parse_score_msg in ML grading there should be only one grader type. # According to _parse_score_msg in ML grading there should be only one grader type.
......
...@@ -390,6 +390,14 @@ class OpenEndedModuleTest(unittest.TestCase): ...@@ -390,6 +390,14 @@ class OpenEndedModuleTest(unittest.TestCase):
# Confirm that the answer is stored properly. # Confirm that the answer is stored properly.
self.assertEqual(test_module.latest_answer(), submitted_response) self.assertEqual(test_module.latest_answer(), submitted_response)
def test_parse_score_msg(self):
"""
Test _parse_score_msg with empty dict.
"""
assessment = self.openendedmodule._parse_score_msg("{}", self.test_system)
self.assertEqual(assessment.get("valid"), False)
class CombinedOpenEndedModuleTest(unittest.TestCase): class CombinedOpenEndedModuleTest(unittest.TestCase):
""" """
......
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