Commit f742b7d8 by Vik Paruchuri

Start to integrate peer grading xmodule back into notifications

parent 5ac6439c
...@@ -33,7 +33,9 @@ class CombinedOpenEndedRubric(object): ...@@ -33,7 +33,9 @@ class CombinedOpenEndedRubric(object):
'view_only': self.view_only}) 'view_only': self.view_only})
success = True success = True
except: except:
raise RubricParsingError("[render_rubric] Could not parse the rubric with xml: {0}".format(rubric_xml)) error_message = "[render_rubric] Could not parse the rubric with xml: {0}".format(rubric_xml)
log.error(error_message)
raise RubricParsingError(error_message)
return success, html return success, html
def extract_categories(self, element): def extract_categories(self, element):
......
from django.conf import settings from django.conf import settings
from staff_grading_service import StaffGradingService from staff_grading_service import StaffGradingService
from peer_grading_service import PeerGradingService
from open_ended_grading.controller_query_service import ControllerQueryService from open_ended_grading.controller_query_service import ControllerQueryService
import json import json
from student.models import unique_id_for_user from student.models import unique_id_for_user
...@@ -10,6 +9,7 @@ import logging ...@@ -10,6 +9,7 @@ import logging
from courseware.access import has_access from courseware.access import has_access
from util.cache import cache from util.cache import cache
import datetime import datetime
from xmodule import peer_grading_service
log=logging.getLogger(__name__) log=logging.getLogger(__name__)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import logging import logging
import urllib import urllib
import re
from django.conf import settings from django.conf import settings
from django.views.decorators.cache import cache_control from django.views.decorators.cache import cache_control
...@@ -24,6 +25,10 @@ import open_ended_notifications ...@@ -24,6 +25,10 @@ import open_ended_notifications
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore import search from xmodule.modulestore import search
from xmodule import peer_grading_module
from xmodule import peer_grading_service
from mitxmako.shortcuts import render_to_string
from xmodule.x_module import ModuleSystem
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
...@@ -87,41 +92,35 @@ def peer_grading(request, course_id): ...@@ -87,41 +92,35 @@ def peer_grading(request, course_id):
''' '''
Show a peer grading interface Show a peer grading interface
''' '''
course = get_course_with_access(request.user, course_id, 'load')
# call problem list service ajax_url = ajax_url = _reverse_with_slash('peer_grading', course_id)
success = False track_function = None
error_text = "" get_module = None
problem_list = [] render_template = render_to_string
try: replace_urls = None
problem_list_json = peer_gs.get_problem_list(course_id, unique_id_for_user(request.user)) anonymous_student_id= unique_id_for_user(request.user)
problem_list_dict = json.loads(problem_list_json)
success = problem_list_dict['success'] system = ModuleSystem(
if 'error' in problem_list_dict: ajax_url,
error_text = problem_list_dict['error'] track_function,
get_module,
problem_list = problem_list_dict['problem_list'] render_template,
replace_urls,
course_id = course_id,
anonymous_student_id = anonymous_student_id
)
except GradingServiceError: location = ""
error_text = "Error occured while contacting the grading service" definition = "<peergrading use_for_single_location = 'False'></peergrading>"
success = False descriptor = peer_grading_module.PeerGradingDescriptor
# catch error if if the json loads fails instance_state = {}
except ValueError: pg_url = re.sub("/courses", "i4x://", ajax_url)
error_text = "Could not get problem list"
success = False
ajax_url = _reverse_with_slash('peer_grading', course_id) pg_module = peer_grading_module.PeerGradingModule(system, pg_url, definition, descriptor, instance_state)
return render_to_response('peer_grading/peer_grading.html', { course = get_course_with_access(request.user, course_id, 'load')
'course': course,
'course_id': course_id,
'ajax_url': ajax_url,
'success': success,
'problem_list': problem_list,
'error_text': error_text,
# Checked above
'staff_access': False, })
return pg_module.get_html()
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @cache_control(no_cache=True, no_store=True, must_revalidate=True)
def peer_grading_problem(request, course_id): def peer_grading_problem(request, course_id):
...@@ -317,7 +316,7 @@ def take_action_on_flags(request, course_id): ...@@ -317,7 +316,7 @@ def take_action_on_flags(request, course_id):
response = controller_qs.take_action_on_flags(course_id, student_id, submission_id, action_type) response = controller_qs.take_action_on_flags(course_id, student_id, submission_id, action_type)
return HttpResponse(response, mimetype="application/json") return HttpResponse(response, mimetype="application/json")
except GradingServiceError: except GradingServiceError:
log.exception("Error saving calibration grade, location: {0}, submission_id: {1}, submission_key: {2}, grader_id: {3}".format(location, submission_id, submission_key, grader_id)) log.exception("Error saving calibration grade, submission_id: {0}, submission_key: {1}, grader_id: {2}".format(submission_id, submission_key, grader_id))
return _err_response('Could not connect to grading service') return _err_response('Could not connect to grading service')
...@@ -297,6 +297,9 @@ if settings.COURSEWARE_ENABLED: ...@@ -297,6 +297,9 @@ if settings.COURSEWARE_ENABLED:
# Open Ended Notifications # Open Ended Notifications
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/open_ended_notifications$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/open_ended_notifications$',
'open_ended_grading.views.combined_notifications', name='open_ended_notifications'), 'open_ended_grading.views.combined_notifications', name='open_ended_notifications'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading$',
'open_ended_grading.views.peer_grading', name='peer_grading'),
) )
# discussion forums live within courseware, so courseware must be enabled first # discussion forums live within courseware, so courseware must be enabled first
......
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