Centralize when json parsing of responses from controller_query_service happens
This commit is contained in:
@@ -165,9 +165,8 @@ def combined_notifications(course, user):
|
||||
|
||||
try:
|
||||
#Get the notifications from the grading controller
|
||||
controller_response = controller_qs.check_combined_notifications(course.id, student_id, user_is_staff,
|
||||
notifications = controller_qs.check_combined_notifications(course.id, student_id, user_is_staff,
|
||||
last_time_viewed)
|
||||
notifications = json.loads(controller_response)
|
||||
if notifications.get('success'):
|
||||
if (notifications.get('staff_needs_to_grade') or
|
||||
notifications.get('student_needs_to_peer_grade')):
|
||||
|
||||
@@ -62,10 +62,9 @@ class StudentProblemListMockQuery(object):
|
||||
def get_grading_status_list(self, *args, **kwargs):
|
||||
"""
|
||||
Get a mock grading status list with locations from the open_ended test course.
|
||||
@returns: json formatted grading status message.
|
||||
@returns: grading status message dictionary.
|
||||
"""
|
||||
grading_status_list = json.dumps(
|
||||
{
|
||||
return {
|
||||
"version": 1,
|
||||
"problem_list": [
|
||||
{
|
||||
@@ -95,8 +94,6 @@ class StudentProblemListMockQuery(object):
|
||||
],
|
||||
"success": True
|
||||
}
|
||||
)
|
||||
return grading_status_list
|
||||
|
||||
|
||||
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
|
||||
|
||||
@@ -118,12 +118,10 @@ class StudentProblemList(object):
|
||||
self.success = False
|
||||
try:
|
||||
#Get list of all open ended problems that the grading server knows about
|
||||
problem_list_json = self.controller_qs.get_grading_status_list(self.course_id, self.user_id)
|
||||
problem_list_dict = self.controller_qs.get_grading_status_list(self.course_id, self.user_id)
|
||||
except GradingServiceError:
|
||||
log.error("Problem contacting open ended grading service " + self.course_error_ending)
|
||||
return self.success
|
||||
try:
|
||||
problem_list_dict = json.loads(problem_list_json)
|
||||
except ValueError:
|
||||
log.error("Problem with results from external grading service for open ended" + self.course_error_ending)
|
||||
return self.success
|
||||
|
||||
@@ -197,8 +197,7 @@ def flagged_problem_list(request, course_id):
|
||||
# Make a service that can query edX ORA.
|
||||
controller_qs = create_controller_query_service()
|
||||
try:
|
||||
problem_list_json = controller_qs.get_flagged_problem_list(course_id)
|
||||
problem_list_dict = json.loads(problem_list_json)
|
||||
problem_list_dict = controller_qs.get_flagged_problem_list(course_id)
|
||||
success = problem_list_dict['success']
|
||||
if 'error' in problem_list_dict:
|
||||
error_text = problem_list_dict['error']
|
||||
@@ -326,7 +325,7 @@ def take_action_on_flags(request, course_id):
|
||||
controller_qs = create_controller_query_service()
|
||||
try:
|
||||
response = controller_qs.take_action_on_flags(course_id, student_id, submission_id, action_type)
|
||||
return HttpResponse(response, mimetype="application/json")
|
||||
return HttpResponse(json.dumps(response), mimetype="application/json")
|
||||
except GradingServiceError:
|
||||
log.exception(
|
||||
u"Error taking action on flagged peer grading submissions, "
|
||||
|
||||
Reference in New Issue
Block a user