Add complete on view support to render_xblock view.

This commit is contained in:
Usman Khalid
2018-05-27 01:26:50 +05:00
committed by Alex Dusenbery
parent 9ef11139d6
commit 8b1aad080a
25 changed files with 556 additions and 189 deletions

View File

@@ -100,7 +100,7 @@ class TestXblockUtils(SharedModuleStoreTestCase):
block=course,
view='baseview',
frag=fragment,
context=None,
context={"wrap_xblock_data": {"custom-attribute": "custom-value"}},
usage_id_serializer=lambda usage_id: quote_slashes(unicode(usage_id)),
request_token=uuid.uuid1().get_hex()
)
@@ -109,6 +109,7 @@ class TestXblockUtils(SharedModuleStoreTestCase):
self.assertIn('data-runtime-class="TestRuntime"', test_wrap_output.content)
self.assertIn(data_usage_id, test_wrap_output.content)
self.assertIn('<h1>Test!</h1>', test_wrap_output.content)
self.assertIn('data-custom-attribute="custom-value"', test_wrap_output.content)
self.assertEqual(test_wrap_output.resources[0].data, u'body {background-color:red;}')
self.assertEqual(test_wrap_output.resources[1].data, 'alert("Hi!");')

View File

@@ -92,6 +92,9 @@ def wrap_xblock(
data = {}
data.update(extra_data)
if context:
data.update(context.get('wrap_xblock_data', {}))
css_classes = [
'xblock',
'xblock-{}'.format(markupsafe.escape(view)),

View File

@@ -36,6 +36,10 @@ class CompletionServiceTestCase(CompletionWaffleTestMixin, SharedModuleStoreTest
parent=cls.sequence,
category='vertical',
)
cls.html = ItemFactory.create(
parent=cls.vertical,
category='html',
)
cls.problem = ItemFactory.create(
parent=cls.vertical,
category="problem",
@@ -70,6 +74,13 @@ class CompletionServiceTestCase(CompletionWaffleTestMixin, SharedModuleStoreTest
self.completion_service = CompletionService(self.user, self.course_key)
# Proper completions for the given runtime
BlockCompletion.objects.submit_completion(
user=self.user,
course_key=self.course_key,
block_key=self.html.location,
completion=1.0,
)
for idx, block_key in enumerate(self.block_keys[0:3]):
BlockCompletion.objects.submit_completion(
user=self.user,
@@ -148,3 +159,12 @@ class CompletionServiceTestCase(CompletionWaffleTestMixin, SharedModuleStoreTest
self.completion_service.vertical_is_complete(self.vertical),
False,
)
def test_can_mark_block_complete_on_view(self):
self.assertEqual(self.completion_service.can_mark_block_complete_on_view(self.course), False)
self.assertEqual(self.completion_service.can_mark_block_complete_on_view(self.chapter), False)
self.assertEqual(self.completion_service.can_mark_block_complete_on_view(self.sequence), False)
self.assertEqual(self.completion_service.can_mark_block_complete_on_view(self.vertical), False)
self.assertEqual(self.completion_service.can_mark_block_complete_on_view(self.html), True)
self.assertEqual(self.completion_service.can_mark_block_complete_on_view(self.problem), False)