Skip to content

Commit

Permalink
Jkantor/submission check (#2162)
Browse files Browse the repository at this point in the history
* fix: skip check when uuid not passed

* chore: version
  • Loading branch information
jansenk authored Jan 16, 2024
1 parent f3bab90 commit dc53d20
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 9 deletions.
2 changes: 1 addition & 1 deletion openassessment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Initialization Information for Open Assessment Module
"""

__version__ = '6.0.25'
__version__ = '6.0.26'
4 changes: 4 additions & 0 deletions openassessment/xblock/apis/assessments/peer_assessment_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
84 changes: 78 additions & 6 deletions openassessment/xblock/test/test_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit dc53d20

Please sign in to comment.