diff --git a/openassessment/__init__.py b/openassessment/__init__.py index f4a42b0cee..0f902e2e07 100644 --- a/openassessment/__init__.py +++ b/openassessment/__init__.py @@ -2,4 +2,4 @@ Initialization Information for Open Assessment Module """ -__version__ = '6.0.25' +__version__ = '6.0.26' diff --git a/openassessment/xblock/apis/assessments/peer_assessment_api.py b/openassessment/xblock/apis/assessments/peer_assessment_api.py index fcdb4eb812..46b266d15c 100644 --- a/openassessment/xblock/apis/assessments/peer_assessment_api.py +++ b/openassessment/xblock/apis/assessments/peer_assessment_api.py @@ -167,6 +167,10 @@ def assert_assessing_valid_submission(self, uuid_client): if submission is None: raise ServerClientUUIDMismatchException() + if uuid_client is None: + # If we don't have a uuid from the client, we can't do the next check + return + uuid_server = submission.get("uuid", None) # If the server and client don't agree, raise diff --git a/openassessment/xblock/test/test_peer.py b/openassessment/xblock/test/test_peer.py index 8af38b1972..77dfe26eab 100644 --- a/openassessment/xblock/test/test_peer.py +++ b/openassessment/xblock/test/test_peer.py @@ -14,6 +14,7 @@ import pytz from openassessment.assessment.api import peer as peer_api +from openassessment.assessment.models.base import Assessment from openassessment.assessment.models.peer import PeerWorkflowItem from openassessment.workflow import api as workflow_api from openassessment.xblock.apis.assessments.errors import ServerClientUUIDMismatchException @@ -318,18 +319,18 @@ def test_assess_expired_peer_item(self, xblock, client_uuid): # Create two submissions, one for sally and one for Hal student_item = xblock.get_student_item_dict() - sally_student_item = copy.deepcopy(student_item) - sally_student_item['student_id'] = "Sally" - sally_submission = self.create_test_submission( - xblock, student_item=sally_student_item, submission_text=("Sally's answer 1", "Sally's answer 2") - ) - hal_student_item = copy.deepcopy(student_item) hal_student_item['student_id'] = "Hal" hal_submission = self.create_test_submission( xblock, student_item=hal_student_item, submission_text=("Hal's answer 1", "Hal's answer 2") ) + sally_student_item = copy.deepcopy(student_item) + sally_student_item['student_id'] = "Sally" + sally_submission = self.create_test_submission( + xblock, student_item=sally_student_item, submission_text=("Sally's answer 1", "Sally's answer 2") + ) + # Sally is given Hal to assess hal_sub = peer_api.get_submission_to_assess(sally_submission['uuid'], 1) assert hal_sub['uuid'] == hal_submission['uuid'] @@ -355,6 +356,77 @@ def test_assess_expired_peer_item(self, xblock, client_uuid): assessed_submission_uuid=client_uuid ) + @scenario('data/peer_assessment_scenario.xml', user_id='Sally') + def test_peer_assess_mismatch(self, xblock): + # Create two submissions, one for sally and one for Hal + student_item = xblock.get_student_item_dict() + + hal_student_item = copy.deepcopy(student_item) + hal_student_item['student_id'] = "Hal" + hal_submission = self.create_test_submission( + xblock, student_item=hal_student_item, submission_text=("Hal's answer 1", "Hal's answer 2") + ) + + sally_student_item = copy.deepcopy(student_item) + sally_student_item['student_id'] = "Sally" + sally_submission = self.create_test_submission( + xblock, student_item=sally_student_item, submission_text=("Sally's answer 1", "Sally's answer 2") + ) + + # Sally is given Hal to assess + hal_sub = peer_api.get_submission_to_assess(sally_submission['uuid'], 1) + assert hal_sub['uuid'] == hal_submission['uuid'] + assert peer_api.get_active_assessment_submission(sally_submission['uuid']) == hal_sub + + # An error should raised when sally tried to submit an assessment + # that doesn't match behal's uuid + with self.assertRaises(ServerClientUUIDMismatchException): + peer_assess( + self.ASSESSMENT['options_selected'], + self.ASSESSMENT['overall_feedback'], + self.ASSESSMENT['criterion_feedback'], + xblock.config_data, + xblock.workflow_data, + xblock.peer_assessment_data(), + assessed_submission_uuid='some-other-uuid' + ) + + @scenario('data/peer_assessment_scenario.xml', user_id='Sally') + def test_peer_assess_no_client_id(self, xblock): + + # Create two submissions, one for sally and one for Hal + student_item = xblock.get_student_item_dict() + hal_student_item = copy.deepcopy(student_item) + hal_student_item['student_id'] = "Hal" + hal_submission = self.create_test_submission( + xblock, student_item=hal_student_item, submission_text=("Hal's answer 1", "Hal's answer 2") + ) + + sally_student_item = copy.deepcopy(student_item) + sally_student_item['student_id'] = "Sally" + sally_submission = self.create_test_submission( + xblock, student_item=sally_student_item, submission_text=("Sally's answer 1", "Sally's answer 2") + ) + + # Sally is given Hal to assess + hal_sub = peer_api.get_submission_to_assess(sally_submission['uuid'], 1) + assert hal_sub['uuid'] == hal_submission['uuid'] + assert peer_api.get_active_assessment_submission(sally_submission['uuid']) == hal_sub + + peer_assess( + self.ASSESSMENT['options_selected'], + self.ASSESSMENT['overall_feedback'], + self.ASSESSMENT['criterion_feedback'], + xblock.config_data, + xblock.workflow_data, + xblock.peer_assessment_data(), + assessed_submission_uuid=None + ) + + assessment = Assessment.objects.last() + assert assessment.scorer_id == 'Sally' + assert assessment.submission_uuid == hal_sub['uuid'] + @ddt.ddt class TestPeerAssessmentRender(XBlockHandlerTestCase, SubmissionTestMixin): diff --git a/package-lock.json b/package-lock.json index ee5dff1efa..61a2936e6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.0.25", + "version": "6.0.26", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 8892c37007..7bf982f86a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edx-ora2", - "version": "6.0.25", + "version": "6.0.26", "repository": "https://github.com/openedx/edx-ora2.git", "dependencies": { "@edx/frontend-build": "8.0.6",