New peer grading view on the lms side
This commit is contained in:
@@ -36,5 +36,59 @@ class PeerGradingService(GradingService):
|
||||
'submission_id' : submission_id,
|
||||
'score' : score,
|
||||
'feedback' : feedback,
|
||||
'submission_key', submission_key}
|
||||
'submission_key': submission_key}
|
||||
return self.post(self.save_grade_url, False, data)
|
||||
|
||||
|
||||
def peer_grading_service():
|
||||
"""
|
||||
Return a peer grading service instance--if settings.MOCK_PEER_GRADING is True,
|
||||
returns a mock one, otherwise a real one.
|
||||
|
||||
Caches the result, so changing the setting after the first call to this
|
||||
function will have no effect.
|
||||
"""
|
||||
global _service
|
||||
if _service is not None:
|
||||
return _service
|
||||
|
||||
_service = PeerGradingService(settings.PEER_GRADING_INTERFACE)
|
||||
|
||||
return _service
|
||||
|
||||
def _err_response(msg):
|
||||
"""
|
||||
Return a HttpResponse with a json dump with success=False, and the given error message.
|
||||
"""
|
||||
return HttpResponse(json.dumps({'success': False, 'error': msg}),
|
||||
mimetype="application/json")
|
||||
|
||||
def get_next_submission(request, course_id):
|
||||
required = set(['location'])
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
actual = set(request.POST.keys())
|
||||
missing = required - actual
|
||||
if len(missing) > 0:
|
||||
return _err_response('Missing required keys {0}'.format(
|
||||
', '.join(missing)))
|
||||
grader_id = request.user.id
|
||||
p = request.POST
|
||||
location = p['location']
|
||||
|
||||
return HttpResponse(_get_next(course_id, request.user.id, location),
|
||||
mimetype="application/json")
|
||||
|
||||
def _get_next_submission(course_id, grader_id, location):
|
||||
"""
|
||||
Implementation of get_next (also called from save_grade) -- returns a json string
|
||||
"""
|
||||
try:
|
||||
return peer_grading_service().get_next_submission(location, grader_id)
|
||||
except GradingServiceError:
|
||||
log.exception("Error from grading service. server url: {0}"
|
||||
.format(staff_grading_service().url))
|
||||
return json.dumps({'success': False,
|
||||
'error': 'Could not connect to grading service'})
|
||||
|
||||
|
||||
|
||||
@@ -48,10 +48,30 @@ def staff_grading(request, course_id):
|
||||
ajax_url += '/'
|
||||
|
||||
return render_to_response('instructor/staff_grading.html', {
|
||||
'view_html': grading.get_html(),
|
||||
'view_html': '',
|
||||
'course': course,
|
||||
'course_id': course_id,
|
||||
'ajax_url': ajax_url,
|
||||
# Checked above
|
||||
'staff_access': True, })
|
||||
|
||||
|
||||
def peer_grading(request, course_id):
|
||||
'''
|
||||
Show a peer grading interface
|
||||
'''
|
||||
course = get_course_with_access(request.user, course_id, 'load')
|
||||
|
||||
ajax_url = reverse('peer_grading', kwargs={'course_id': course_id})
|
||||
if not ajax_url.endswith('/'):
|
||||
ajax_url += '/'
|
||||
|
||||
return render_to_response('peer_grading/peer_grading.html', {
|
||||
'view_html': '',
|
||||
'course': course,
|
||||
'course_id': course_id,
|
||||
'ajax_url': ajax_url,
|
||||
# Checked above
|
||||
'staff_access': False, })
|
||||
|
||||
|
||||
|
||||
@@ -418,6 +418,7 @@ main_vendor_js = [
|
||||
discussion_js = sorted(glob2.glob(PROJECT_ROOT / 'static/coffee/src/discussion/**/*.coffee'))
|
||||
|
||||
staff_grading_js = sorted(glob2.glob(PROJECT_ROOT / 'static/coffee/src/staff_grading/**/*.coffee'))
|
||||
peer_grading_js = sorted(glob2.glob(PROJECT_ROOT / 'static/coffee/src/peer_grading/**/*.coffee'))
|
||||
|
||||
|
||||
# Load javascript from all of the available xmodules, and
|
||||
@@ -526,8 +527,11 @@ PIPELINE_JS = {
|
||||
'staff_grading' : {
|
||||
'source_filenames': [pth.replace(PROJECT_ROOT / 'static/', '') for pth in staff_grading_js],
|
||||
'output_filename': 'js/staff_grading.js'
|
||||
},
|
||||
'peer_grading' : {
|
||||
'source_filenames': [pth.replace(PROJECT_ROOT / 'static/', '') for pth in peer_grading_js],
|
||||
'output_filename': 'js/peer_grading.js'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PIPELINE_DISABLE_WRAPPER = True
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
</div>
|
||||
<div class="message-container">
|
||||
</div>
|
||||
|
||||
<! -- Problem List View -->
|
||||
<section class="problem-list-container">
|
||||
<h2>Instructions</h2>
|
||||
<div class="instructions">
|
||||
@@ -35,6 +37,8 @@
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- Grading View -->
|
||||
|
||||
<section class="prompt-wrapper">
|
||||
<h2 class="prompt-name"></h2>
|
||||
<div class="meta-info-wrapper">
|
||||
|
||||
22
lms/templates/peer_grading/peer_grading.html
Normal file
22
lms/templates/peer_grading/peer_grading.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<%inherit file="/main.html" />
|
||||
<%block name="bodyclass">${course.css_class}</%block>
|
||||
<%namespace name='static' file='/static_content.html'/>
|
||||
|
||||
<%block name="headextra">
|
||||
<%static:css group='course'/>
|
||||
</%block>
|
||||
|
||||
<%block name="title"><title>${course.number} Peer Grading</title></%block>
|
||||
|
||||
<%include file="/courseware/course_navigation.html" args="active_page='staff_grading'" />
|
||||
|
||||
<%block name="js_extra">
|
||||
<%static:js group='peer_grading'/>
|
||||
</%block>
|
||||
|
||||
<section class="container">
|
||||
<div class="peer-grading">
|
||||
<div class="problem-list">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -250,6 +250,11 @@ if settings.COURSEWARE_ENABLED:
|
||||
'open_ended_grading.staff_grading_service.save_grade', name='staff_grading_save_grade'),
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/staff_grading/get_problem_list$',
|
||||
'open_ended_grading.staff_grading_service.get_problem_list', name='staff_grading_get_problem_list'),
|
||||
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading/get_next_submission$',
|
||||
'open_ended_grading.peer_grading_service.get_next_submission', name='peer_grading_get_next_submission'),
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user