starting to stub out the backend staff grading service [wip]
This commit is contained in:
committed by
Victor Shnayder
parent
9d8d6655c6
commit
ed6a8f68ac
57
lms/djangoapps/instructor/staff_grading_service.py
Normal file
57
lms/djangoapps/instructor/staff_grading_service.py
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
"""
|
||||||
|
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:
|
|||||||
'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
|
||||||
|
|||||||
Reference in New Issue
Block a user