Commit ed282c05 by Vik Paruchuri

Proper handling of submissions

parent 6cf2742e
...@@ -38,8 +38,10 @@ from peer_grading_service import peer_grading_service, GradingServiceError ...@@ -38,8 +38,10 @@ from peer_grading_service import peer_grading_service, GradingServiceError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
USE_FOR_SINGLE_LOCATION = False USE_FOR_SINGLE_LOCATION = False
LINK_TO_LOCATION = ""
TRUE_DICT = [True, "True", "true", "TRUE"] TRUE_DICT = [True, "True", "true", "TRUE"]
class PeerGradingModule(XModule): class PeerGradingModule(XModule):
_VERSION = 1 _VERSION = 1
...@@ -60,19 +62,24 @@ class PeerGradingModule(XModule): ...@@ -60,19 +62,24 @@ class PeerGradingModule(XModule):
# Load instance state # Load instance state
if instance_state is not None: if instance_state is not None:
instance_state = json.loads(instance_state) instance_state = json.loads(instance_state)
use_for_single_location = instance_state.get('use_for_single_location', USE_FOR_SINGLE_LOCATION)
else: else:
instance_state = {} instance_state = {}
#We need to set the location here so the child modules can use it #We need to set the location here so the child modules can use it
system.set('location', location) system.set('location', location)
log.debug("Location: {0}".format(location))
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) self.use_for_single_location = self.metadata.get('use_for_single_location', use_for_single_location)
if isinstance(self.use_for_single_location, basestring): if isinstance(self.use_for_single_location, basestring):
self.use_for_single_location = (self.use_for_single_location in TRUE_DICT) self.use_for_single_location = (self.use_for_single_location in TRUE_DICT)
self.link_to_location = self.metadata.get('link_to_location', USE_FOR_SINGLE_LOCATION)
if self.use_for_single_location ==True:
#This will raise an exception if the location is invalid
link_to_location_object = Location(self.link_to_location)
self.ajax_url = self.system.ajax_url self.ajax_url = self.system.ajax_url
if not self.ajax_url.endswith("/"): if not self.ajax_url.endswith("/"):
self.ajax_url = self.ajax_url + "/" self.ajax_url = self.ajax_url + "/"
...@@ -99,15 +106,13 @@ class PeerGradingModule(XModule): ...@@ -99,15 +106,13 @@ class PeerGradingModule(XModule):
if not self.use_for_single_location: if not self.use_for_single_location:
return self.peer_grading() return self.peer_grading()
else: else:
return self.peer_grading_problem({'location' : self.system.location}) return self.peer_grading_problem({'location' : self.link_to_location})
def handle_ajax(self, dispatch, get): def handle_ajax(self, dispatch, get):
""" """
Needs to be implemented by child modules. Handles AJAX events. Needs to be implemented by child modules. Handles AJAX events.
@return: @return:
""" """
log.debug(get)
handlers = { handlers = {
'get_next_submission': self.get_next_submission, 'get_next_submission': self.get_next_submission,
'show_calibration_essay': self.show_calibration_essay, 'show_calibration_essay': self.show_calibration_essay,
......
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