Commit ed6a8f68 by Victor Shnayder Committed by Victor Shnayder

starting to stub out the backend staff grading service [wip]

parent 9d8d6655
"""
This module provides views that proxy to the staff grading backend service.
"""
import json
import requests
import sys
from django.http import Http404
from django.http import HttpResponse
from util.json_request import expect_json
class GradingServiceError(Exception):
pass
class StaffGradingService(object):
"""
Interface to staff grading backend.
"""
def __init__(self, url):
self.url = url
# TODO: add auth
self.session = requests.session()
def get_next(course_id):
"""
Get the next thing to grade. Returns json, or raises GradingServiceError
if there's a problem.
"""
try:
r = self.session.get(url + 'get_next')
except requests.exceptions.ConnectionError as err:
# reraise as promised GradingServiceError, but preserve stacktrace.
raise GradingServiceError, str(err), sys.exc_info()[2]
return r.text
#@login_required
def get_next(request, course_id):
"""
"""
d = {'success': False}
return HttpResponse(json.dumps(d))
#@login_required
@expect_json
def save_grade(request, course_id):
"""
"""
d = {'success': False}
return HttpResponse(json.dumps(d))
...@@ -232,6 +232,10 @@ if settings.COURSEWARE_ENABLED: ...@@ -232,6 +232,10 @@ if settings.COURSEWARE_ENABLED:
'instructor.views.enroll_students', name='enroll_students'), 'instructor.views.enroll_students', name='enroll_students'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/staff_grading$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/staff_grading$',
'instructor.views.staff_grading', name='staff_grading'), 'instructor.views.staff_grading', name='staff_grading'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/staff_grading/get_next$',
'instructor.staff_grading_service.get_next', name='staff_grading_get_next'),
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/staff_grading/save_grade$',
'instructor.staff_grading_service.save_grade', name='staff_grading_save_grade'),
) )
# 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