Merge pull request #18133 from edx/ai/EDUCATOR-2726_usage_key_none

Fix that when usage key none is not raise error.
This commit is contained in:
Attiya Ishaque
2018-05-04 15:47:20 +05:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@@ -212,6 +212,8 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
completion_service = self.runtime.service(self, 'completion')
usage_key = data.get('usage_key', None)
if not usage_key:
return None
item = self.get_child(UsageKey.from_string(usage_key))
if not item:
return None

View File

@@ -296,3 +296,15 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
self.assertIsNot(completion_return, None)
self.assertTrue('complete' in completion_return)
self.assertEqual(completion_return['complete'], True)
def test_handle_ajax_get_completion_return_none(self):
"""
Test that the completion data is returned successfully None
when usage key is None through ajax call
"""
usage_key = None
completion_return = self.sequence_3_1.handle_ajax(
'get_completion',
{'usage_key': usage_key}
)
self.assertIs(completion_return, None)