Commit 7e79b6bc by muzaffaryousaf

Refactoring the code for grade overriding and tests.

TNL-900
parent 71312efa
...@@ -1018,20 +1018,20 @@ def get_submission_cancellation(submission_uuid): ...@@ -1018,20 +1018,20 @@ def get_submission_cancellation(submission_uuid):
raise PeerAssessmentInternalError(error_message) raise PeerAssessmentInternalError(error_message)
def is_peer_workflow_submission_cancelled(submission_uuid): def is_workflow_submission_cancelled(submission_uuid):
""" """
Check if peer workflow submission is cancelled? Check if workflow submission is cancelled?
Args: Args:
submission_uuid (str): The UUID of the peer workflow's submission. submission_uuid (str): The UUID of the workflow's submission.
Returns:
True/False
""" """
# Users must submit a response before they can peer-assess.
if submission_uuid is None: if submission_uuid is None:
return False return False
try:
workflow = PeerWorkflow.get_by_submission_uuid(submission_uuid) workflow = PeerWorkflow.get_by_submission_uuid(submission_uuid)
if workflow: return workflow.is_cancelled if workflow else False
return workflow.is_cancelled except PeerAssessmentWorkflowError:
return False
return False \ No newline at end of file
...@@ -127,7 +127,7 @@ class PeerWorkflow(models.Model): ...@@ -127,7 +127,7 @@ class PeerWorkflow(models.Model):
Returns: Returns:
True/False True/False
""" """
return bool(self.cancellations.exists()) return self.cancellations.exists()
@classmethod @classmethod
def get_by_submission_uuid(cls, submission_uuid): def get_by_submission_uuid(cls, submission_uuid):
......
...@@ -952,7 +952,7 @@ class TestPeerApi(CacheResetTest): ...@@ -952,7 +952,7 @@ class TestPeerApi(CacheResetTest):
workflow = PeerWorkflow.get_by_submission_uuid(buffy_sub["uuid"]) workflow = PeerWorkflow.get_by_submission_uuid(buffy_sub["uuid"])
self.assertTrue(workflow.is_cancelled) self.assertTrue(workflow.is_cancelled)
def test_cancelled_submission_peerworkflow_score(self): def test_cancelled_submission_peerworkflow_final_score(self):
tim_sub, tim = self._create_student_and_submission("Tim", "Tim's answer") tim_sub, tim = self._create_student_and_submission("Tim", "Tim's answer")
bob_sub, bob = self._create_student_and_submission("Bob", "Bob's answer") bob_sub, bob = self._create_student_and_submission("Bob", "Bob's answer")
...@@ -981,12 +981,20 @@ class TestPeerApi(CacheResetTest): ...@@ -981,12 +981,20 @@ class TestPeerApi(CacheResetTest):
'must_be_graded_by': 1 'must_be_graded_by': 1
} }
# Check the final score it should be 6.
score = peer_api.get_score(bob_sub["uuid"], requirements)
self.assertEqual(score['points_earned'], 6)
# Cancel the workflow for bob submission.
peer_api.cancel_submission_peer_workflow( peer_api.cancel_submission_peer_workflow(
submission_uuid=bob_sub["uuid"], submission_uuid=bob_sub["uuid"],
comments="Inappropriate language", comments="Inappropriate language",
cancelled_by_id=bob['student_id'] cancelled_by_id=bob['student_id']
) )
# Check if the submission cancelled successfully.
self.assertTrue(peer_api.is_workflow_submission_cancelled(bob_sub["uuid"]))
# After cancellation the score should be 0.
score = peer_api.get_score(bob_sub["uuid"], requirements) score = peer_api.get_score(bob_sub["uuid"], requirements)
self.assertEqual(score['points_earned'], 0) self.assertEqual(score['points_earned'], 0)
......
...@@ -214,7 +214,7 @@ class PeerAssessmentMixin(object): ...@@ -214,7 +214,7 @@ class PeerAssessmentMixin(object):
"Submit your assessment & move to response #{response_number}" "Submit your assessment & move to response #{response_number}"
).format(response_number=(count + 2)) ).format(response_number=(count + 2))
if peer_api.is_peer_workflow_submission_cancelled(self.submission_uuid): if peer_api.is_workflow_submission_cancelled(self.submission_uuid):
path = 'openassessmentblock/peer/oa_peer_waiting.html' path = 'openassessmentblock/peer/oa_peer_waiting.html'
# Sets the XBlock boolean to signal to Message that it WAS able to grab a submission # Sets the XBlock boolean to signal to Message that it WAS able to grab a submission
self.no_peers = True self.no_peers = True
......
...@@ -250,7 +250,7 @@ class TestCourseStaff(XBlockHandlerTestCase): ...@@ -250,7 +250,7 @@ class TestCourseStaff(XBlockHandlerTestCase):
self.assertEquals("openassessmentblock/staff_debug/student_info.html", path) self.assertEquals("openassessmentblock/staff_debug/student_info.html", path)
@scenario('data/basic_scenario.xml', user_id='Bob') @scenario('data/basic_scenario.xml', user_id='Bob')
def test_cancelled_submission_peer_aseseement_render_path(self, xblock): def test_cancelled_submission_peer_assessment_render_path(self, xblock):
""" """
Test that peer assessment path should be oa_peer_waiting.html for a cancelled submission. Test that peer assessment path should be oa_peer_waiting.html for a cancelled submission.
""" """
......
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