Commit 70c6eaaa by Will Daly

Merge pull request #170 from edx/will/fix-studio-preview-warning

Fix warning for submission in Studio preview
parents 3600e562 8f95ae7a
...@@ -61,7 +61,9 @@ class SubmissionMixin(object): ...@@ -61,7 +61,9 @@ class SubmissionMixin(object):
# Short-circuit if no user is defined (as in Studio Preview mode) # Short-circuit if no user is defined (as in Studio Preview mode)
# Since students can't submit, they will never be able to progress in the workflow # Since students can't submit, they will never be able to progress in the workflow
if student_item_dict['student_id'] is None: # Studio Preview provides an anonymous student ID, so we need to check the scope ids directly
# to check that we are in preview mode.
if self.scope_ids.user_id is None:
return False, 'ENOPREVIEW', self.submit_errors['ENOPREVIEW'] return False, 'ENOPREVIEW', self.submit_errors['ENOPREVIEW']
workflow = self.get_workflow_info() workflow = self.get_workflow_info()
......
...@@ -3,7 +3,7 @@ Test submission to the OpenAssessment XBlock. ...@@ -3,7 +3,7 @@ Test submission to the OpenAssessment XBlock.
""" """
import json import json
from mock import patch from mock import patch, Mock
from submissions import api as sub_api from submissions import api as sub_api
from submissions.api import SubmissionRequestError, SubmissionInternalError from submissions.api import SubmissionRequestError, SubmissionInternalError
from openassessment.xblock.submission_mixin import SubmissionMixin from openassessment.xblock.submission_mixin import SubmissionMixin
...@@ -50,6 +50,15 @@ class SubmissionTest(XBlockHandlerTestCase): ...@@ -50,6 +50,15 @@ class SubmissionTest(XBlockHandlerTestCase):
# In Studio preview mode, the runtime sets the user ID to None # In Studio preview mode, the runtime sets the user ID to None
@scenario('data/basic_scenario.xml', user_id=None) @scenario('data/basic_scenario.xml', user_id=None)
def test_cannot_submit_in_preview_mode(self, xblock,): def test_cannot_submit_in_preview_mode(self, xblock,):
# The Studio runtime apparently provides an anonymous student ID,
# even though we're running in Preview mode. We should check the scope id
# to determine whether we're in Preview mode or not.
xblock.xmodule_runtime = Mock(
course_id='test_course',
anonymous_student_id='test_student'
)
resp = self.request(xblock, 'submit', self.SUBMISSION, response_format='json') resp = self.request(xblock, 'submit', self.SUBMISSION, response_format='json')
self.assertFalse(resp[0]) self.assertFalse(resp[0])
self.assertEqual(resp[1], "ENOPREVIEW") self.assertEqual(resp[1], "ENOPREVIEW")
......
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