Commit c8fe87d5 by Will Daly

Merge pull request #387 from edx/will/ignore-peer-assesss-if-no-sub

Gracefully handle peer assessing before submitting a response
parents 2c265217 17e55e94
......@@ -57,6 +57,9 @@ class PeerAssessmentMixin(object):
if 'criterion_feedback' not in data:
return {'success': False, 'msg': _('Must provide feedback for criteria in the assessment')}
if self.submission_uuid is None:
return {'success': False, 'msg': _('You must submit a response before you can peer-assess.')}
assessment_ui_model = self.get_assessment_module('peer-assessment')
if assessment_ui_model:
rubric_dict = {
......
......@@ -83,6 +83,13 @@ class TestPeerAssessment(XBlockHandlerTestCase):
"Hal".encode('utf-8') in peer_response.body)
@scenario('data/peer_assessment_scenario.xml', user_id='Bob')
def test_peer_assess_before_submission(self, xblock):
# Submit a peer assessment without a submission
resp = self.request(xblock, 'peer_assess', json.dumps(self.ASSESSMENT), response_format='json')
self.assertEqual(resp['success'], False)
self.assertGreater(len(resp['msg']), 0)
@scenario('data/peer_assessment_scenario.xml', user_id='Bob')
def test_missing_keys_in_request(self, xblock):
for missing in ['criterion_feedback', 'overall_feedback', 'options_selected']:
assessment = copy.deepcopy(self.ASSESSMENT)
......
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