Commit 4c5e59e8 by Vik Paruchuri

Start to fix up instance states

parent ed282c05
...@@ -40,6 +40,7 @@ log = logging.getLogger(__name__) ...@@ -40,6 +40,7 @@ log = logging.getLogger(__name__)
USE_FOR_SINGLE_LOCATION = False USE_FOR_SINGLE_LOCATION = False
LINK_TO_LOCATION = "" LINK_TO_LOCATION = ""
TRUE_DICT = [True, "True", "true", "TRUE"] TRUE_DICT = [True, "True", "true", "TRUE"]
MAX_SCORE = 1
class PeerGradingModule(XModule): class PeerGradingModule(XModule):
...@@ -62,7 +63,6 @@ class PeerGradingModule(XModule): ...@@ -62,7 +63,6 @@ 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 = {}
...@@ -84,6 +84,12 @@ class PeerGradingModule(XModule): ...@@ -84,6 +84,12 @@ class PeerGradingModule(XModule):
if not self.ajax_url.endswith("/"): if not self.ajax_url.endswith("/"):
self.ajax_url = self.ajax_url + "/" self.ajax_url = self.ajax_url + "/"
self.student_data_for_location = instance_state.get('student_data_for_location', {})
self.max_score = instance_state.get('max_score', MAX_SCORE)
if not isinstance(self.max_score, (int, long)):
#This could result in an exception, but not wrapping in a try catch block so it moves up the stack
self.max_score = int(self.max_score)
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.
...@@ -135,6 +141,18 @@ class PeerGradingModule(XModule): ...@@ -135,6 +141,18 @@ class PeerGradingModule(XModule):
def get_score(self): def get_score(self):
pass pass
def max_score(self):
''' Maximum score. Two notes:
* This is generic; in abstract, a problem could be 3/5 points on one
randomization, and 5/7 on another
'''
max_score = None
if self.check_if_done_and_scored():
last_response = self.get_last_response(self.current_task_number)
max_score = last_response['max_score']
return max_score
def get_next_submission(self, get): def get_next_submission(self, get):
""" """
Makes a call to the grading controller for the next essay that should be graded Makes a call to the grading controller for the next essay that should be graded
...@@ -399,6 +417,19 @@ class PeerGradingModule(XModule): ...@@ -399,6 +417,19 @@ class PeerGradingModule(XModule):
return {'html' : html, 'success' : True} return {'html' : html, 'success' : True}
def get_instance_state(self):
"""
Returns the current instance state. The module can be recreated from the instance state.
Input: None
Output: A dictionary containing the instance state.
"""
state = {
'student_data_for_location' : self.student_data_for_location,
}
return json.dumps(state)
class PeerGradingDescriptor(XmlDescriptor, EditingDescriptor): class PeerGradingDescriptor(XmlDescriptor, EditingDescriptor):
""" """
Module for adding combined open ended questions Module for adding combined open ended questions
......
...@@ -32,8 +32,14 @@ class PeerGradingService(): ...@@ -32,8 +32,14 @@ class PeerGradingService():
self.save_calibration_essay_url = self.url + '/save_calibration_essay/' self.save_calibration_essay_url = self.url + '/save_calibration_essay/'
self.get_problem_list_url = self.url + '/get_problem_list/' self.get_problem_list_url = self.url + '/get_problem_list/'
self.get_notifications_url = self.url + '/get_notifications/' self.get_notifications_url = self.url + '/get_notifications/'
self.get_data_for_location_url = self.url + '/get_data_for_location/'
self.system = system self.system = system
def get_data_for_location(self, problem_location, student_id):
response = self.get(self.get_data_for_location_url,
{'location': problem_location, 'student_id': student_id})
return self._render_rubric(response)
def get_next_submission(self, problem_location, grader_id): def get_next_submission(self, problem_location, grader_id):
response = self.get(self.get_next_submission_url, response = self.get(self.get_next_submission_url,
{'location': problem_location, 'grader_id': grader_id}) {'location': problem_location, 'grader_id': grader_id})
......
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