Commit 78948210 by Diana Huang

Use different template when peer grading is closed.

parent 977e1904
...@@ -20,6 +20,7 @@ import copy ...@@ -20,6 +20,7 @@ import copy
import itertools import itertools
import json import json
import logging import logging
import datetime.datetime
from lxml.html import rewrite_links from lxml.html import rewrite_links
import os import os
from pkg_resources import resource_string from pkg_resources import resource_string
...@@ -71,6 +72,16 @@ class PeerGradingModule(XModule): ...@@ -71,6 +72,16 @@ class PeerGradingModule(XModule):
self.system = system self.system = system
self.peer_gs = peer_grading_service(self.system) self.peer_gs = peer_grading_service(self.system)
self.use_for_single_location = self.metadata.get('use_for_single_location', USE_FOR_SINGLE_LOCATION)
if isinstance(self.use_for_single_location, basestring):
self.use_for_single_location = (self.use_for_single_location in TRUE_DICT)
self.is_graded = self.metadata.get('is_graded', IS_GRADED)
if isinstance(self.is_graded, basestring):
self.is_graded = (self.is_graded in TRUE_DICT)
#TODO: do we only want to allow this for single locations?
display_due_date_string = self.metadata.get('due', None) display_due_date_string = self.metadata.get('due', None)
grace_period_string = self.metadata.get('graceperiod', None) grace_period_string = self.metadata.get('graceperiod', None)
...@@ -82,14 +93,6 @@ class PeerGradingModule(XModule): ...@@ -82,14 +93,6 @@ class PeerGradingModule(XModule):
self.display_due_date = self.timeinfo.display_due_date self.display_due_date = self.timeinfo.display_due_date
self.use_for_single_location = self.metadata.get('use_for_single_location', USE_FOR_SINGLE_LOCATION)
if isinstance(self.use_for_single_location, basestring):
self.use_for_single_location = (self.use_for_single_location in TRUE_DICT)
self.is_graded = self.metadata.get('is_graded', IS_GRADED)
if isinstance(self.is_graded, basestring):
self.is_graded = (self.is_graded in TRUE_DICT)
self.link_to_location = self.metadata.get('link_to_location', USE_FOR_SINGLE_LOCATION) self.link_to_location = self.metadata.get('link_to_location', USE_FOR_SINGLE_LOCATION)
if self.use_for_single_location ==True: if self.use_for_single_location ==True:
#This will raise an exception if the location is invalid #This will raise an exception if the location is invalid
...@@ -105,6 +108,11 @@ class PeerGradingModule(XModule): ...@@ -105,6 +108,11 @@ class PeerGradingModule(XModule):
#This could result in an exception, but not wrapping in a try catch block so it moves up the stack #This could result in an exception, but not wrapping in a try catch block so it moves up the stack
self.max_grade = int(self.max_grade) self.max_grade = int(self.max_grade)
def closed(self):
if self.timeinfo.close_date is not None and datetime.utcnow() > self.timeinfo.close_date:
return True
return False
def _err_response(self, msg): def _err_response(self, msg):
""" """
Return a HttpResponse with a json dump with success=False, and the given error message. Return a HttpResponse with a json dump with success=False, and the given error message.
...@@ -124,6 +132,8 @@ class PeerGradingModule(XModule): ...@@ -124,6 +132,8 @@ class PeerGradingModule(XModule):
Needs to be implemented by inheritors. Renders the HTML that students see. Needs to be implemented by inheritors. Renders the HTML that students see.
@return: @return:
""" """
if self.closed():
return self.peer_grading_closed()
if not self.use_for_single_location: if not self.use_for_single_location:
return self.peer_grading() return self.peer_grading()
else: else:
...@@ -410,6 +420,16 @@ class PeerGradingModule(XModule): ...@@ -410,6 +420,16 @@ class PeerGradingModule(XModule):
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, location: {0}, submission_id: {1}, submission_key: {2}, grader_id: {3}".format(location, submission_id, submission_key, grader_id))
return self._err_response('Could not connect to grading service') return self._err_response('Could not connect to grading service')
def peer_grading_closed(self):
'''
Show the Peer grading closed template
'''
html = self.system.render_template('peer_grading/peer_grading_closed.html', {
'use_for_single_location': self.use_single_location
})
return html
def peer_grading(self, get = None): def peer_grading(self, get = None):
''' '''
Show a peer grading interface Show a peer grading interface
......
<section class="container peer-grading-container">
% if use_for_single_location:
<p>Peer grading for this problem is closed at this time.</p>
%else:
<p>Peer grading is closed at this time.</p>
%endif
</section>
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