From f26a2585982c796e6aa1be0835882c070e1f155c Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Wed, 8 May 2013 18:07:17 -0400 Subject: [PATCH] Add in test for grader reply --- .../open_ended_module.py | 2 +- .../xmodule/tests/test_combined_open_ended.py | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py index 4a8604ac30..afdfeef6de 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py @@ -516,7 +516,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): try: feedback_dict = json.loads(score_result['feedback']) except: - pass + feedback_dict = score_result.get('feedback', '') feedback_dicts = [feedback_dict] grader_ids = [score_result['grader_id']] submission_ids = [score_result['submission_id']] diff --git a/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py b/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py index d845a9a711..7cfec5fb62 100644 --- a/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py +++ b/common/lib/xmodule/xmodule/tests/test_combined_open_ended.py @@ -598,11 +598,27 @@ class OpenEndedModuleXmlTest(unittest.TestCase): except GradingServiceError: #This error is okay. We don't have a grading service to connect to! pass - #Move to the next step in the problem try: module.get_html() except GradingServiceError: #This error is okay. We don't have a grading service to connect to! pass - module.handle_ajax("get_combined_rubric", {}) + module.handle_ajax("get_combined_rubric", {}) + + queue_reply = { + 'queuekey' : "", + 'xqueue_body' : json.dumps({ + 'score' : 0, + 'feedback' : json.dumps({"spelling": "Spelling: Ok.", "grammar": "Grammar: Ok.", "markup-text": " all of us can think of a book that we hope none of our children or any other children have taken off the shelf . but if i have the right to remove that book from the shelf that work i abhor then you also have exactly the same right and so does everyone else . and then we have no books left on the shelf for any of us . katherine paterson , author write a persuasive essay to a newspaper reflecting your vies on censorship in libraries . do you believe that certain materials , such as books , music , movies , magazines , etc . , should be removed from the shelves if they are found offensive ? support your position with convincing arguments from your own experience , observations , and or reading . "}), + 'grader_type' : "ML", + 'success' : True, + 'grader_id' : 1, + 'submission_id' : 1, + 'rubric_xml' : "Writing Applications0 Language Conventions 0", + 'rubric_scores_complete' : True, + }) + } + + module.handle_ajax("score_update", queue_reply) +