From 4237df625a5ab65c146e85f60ea206e7f63ec0c9 Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 12 Feb 2013 14:31:30 -0500 Subject: [PATCH] Add in a check function to see if students are allowed to submit peer grading --- .../open_ended_module.py | 1 + .../openendedchild.py | 23 +++++++++++++++++++ .../xmodule/xmodule/peer_grading_module.py | 1 + 3 files changed, 25 insertions(+) diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py index 95c631c8fd..5d22d6d1b4 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/open_ended_module.py @@ -73,6 +73,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild): self.send_to_grader(self.latest_answer(), system) self.created = False + def _parse(self, oeparam, prompt, rubric, system): ''' Parse OpenEndedResponse XML: diff --git a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py index 1700dcaa07..6c3fd46d19 100644 --- a/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py +++ b/common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py @@ -22,6 +22,7 @@ from xmodule.stringify import stringify_children from xmodule.xml_module import XmlDescriptor from xmodule.modulestore import Location from capa.util import * +from peer_grading_service import PeerGradingService from datetime import datetime @@ -104,7 +105,9 @@ class OpenEndedChild(object): # Used for progress / grading. Currently get credit just for # completion (doesn't matter if you self-assessed correct/incorrect). self._max_score = static_data['max_score'] + self.peer_gs = PeerGradingService(system.open_ended_grading_interface, system) + self.system = system self.setup_response(system, location, definition, descriptor) def setup_response(self, system, location, definition, descriptor): @@ -408,3 +411,23 @@ class OpenEndedChild(object): success = True return success, string + + def check_if_student_can_submit(self): + location = self.system.location.url() + student_id = self.system.anonymous_student_id + success = False + response = {} + try: + response = self.peer_gs.get_data_for_location(location, student_id) + count_graded = response['count_graded'] + count_required = response['count_required'] + success = True + except: + error_message = ("Need to peer grade more in order to make another submission. " + "You have graded {0}, {1} are required.").format(count_graded, count_required) + return success, False, error_message + if count_graded>=count_required: + return success, True, "" + else: + return success, False, "" + diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index 457c8ee72a..ba22e8d80c 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -155,6 +155,7 @@ class PeerGradingModule(XModule): count_graded = response['count_graded'] count_required = response['count_required'] if count_required > 0 and count_graded >= count_required: + #Ensures that once a student receives a final score for peer grading, that it does not change. self.student_data_for_location = response score_dict = {