From a1a431f7ba4803a59bb0c4d7f8edb9f4bd4e4d66 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Thu, 19 Sep 2013 12:33:57 -0400 Subject: [PATCH] Fix staff-facing error with open ended --- .../open_ended_grading/staff_grading_service.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/open_ended_grading/staff_grading_service.py b/lms/djangoapps/open_ended_grading/staff_grading_service.py index 98391ce74c..526870f04d 100644 --- a/lms/djangoapps/open_ended_grading/staff_grading_service.py +++ b/lms/djangoapps/open_ended_grading/staff_grading_service.py @@ -264,15 +264,26 @@ def get_problem_list(request, course_id): min_for_ml: the number of responses that need to be graded before the ml can be run + 'error': if success is False, will have an error message with more info. """ _check_access(request.user, course_id) try: response = staff_grading_service().get_problem_list(course_id, unique_id_for_user(request.user)) response = json.loads(response) - problem_list = response['problem_list'] + + # If 'problem_list' is in the response, then we got a list of problems from the ORA server. + # If it is not, then ORA could not find any problems. + if 'problem_list' in response: + problem_list = response['problem_list'] + else: + problem_list = [] + # Make an error messages to reflect that we could not find anything to grade. + response['error'] = ("Cannot find any open response problems in this course. " + "Have you submitted answers to any open response assessment questions? " + "If not, please do so and return to this page.") valid_problem_list = [] for i in xrange(0,len(problem_list)): - #Needed to ensure that the 'location' key can be accessed + # Needed to ensure that the 'location' key can be accessed. try: problem_list[i] = json.loads(problem_list[i]) except Exception: