Merge pull request #28268 from open-craft/agrendalath/bb-4503_library_content_block_completion

feat: allow marking Library Content Block as complete on view [BB-4503]
This commit is contained in:
Matjaz Gregoric
2022-03-25 08:27:13 +01:00
committed by GitHub
5 changed files with 58 additions and 1 deletions

View File

@@ -484,6 +484,19 @@ FEATURES = {
# .. toggle_target_removal_date: None
# .. toggle_tickets: 'https://openedx.atlassian.net/browse/MST-1348'
'ENABLE_INTEGRITY_SIGNATURE': False,
# .. toggle_name: MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: If enabled, the Library Content Block is marked as complete when users view it.
# Otherwise (by default), all children of this block must be completed.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2022-03-22
# .. toggle_target_removal_date: None
# .. toggle_tickets: https://github.com/edx/edx-platform/pull/28268
# .. toggle_warnings: For consistency in user-experience, keep the value in sync with the setting of the same name
# in the LMS and CMS.
'MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW': False,
}
# .. toggle_name: ENABLE_COPPA_COMPLIANCE

View File

@@ -10,6 +10,8 @@ from copy import copy
from gettext import ngettext
import bleach
from django.conf import settings
from django.utils.functional import classproperty
from lazy import lazy
from lxml import etree
from lxml.etree import XMLSyntaxError
@@ -116,7 +118,18 @@ class LibraryContentBlock(
show_in_read_only_mode = True
completion_mode = XBlockCompletionMode.AGGREGATOR
# noinspection PyMethodParameters
@classproperty
def completion_mode(cls): # pylint: disable=no-self-argument
"""
Allow overriding the completion mode with a feature flag.
This is a property, so it can be dynamically overridden in tests, as it is not evaluated at runtime.
"""
if settings.FEATURES.get('MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW', False):
return XBlockCompletionMode.COMPLETABLE
return XBlockCompletionMode.AGGREGATOR
display_name = String(
display_name=_("Display Name"),

View File

@@ -972,6 +972,19 @@ FEATURES = {
# .. toggle_target_removal_date: None
# .. toggle_tickets: 'https://openedx.atlassian.net/browse/MICROBA-1758'
'ENABLE_NEW_BULK_EMAIL_EXPERIENCE': False,
# .. toggle_name: MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: If enabled, the Library Content Block is marked as complete when users view it.
# Otherwise (by default), all children of this block must be completed.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2022-03-22
# .. toggle_target_removal_date: None
# .. toggle_tickets: https://github.com/edx/edx-platform/pull/28268
# .. toggle_warnings: For consistency in user-experience, keep the value in sync with the setting of the same name
# in the LMS and CMS.
'MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW': False,
}
# Specifies extra XBlock fields that should available when requested via the Course Blocks API

View File

@@ -7,6 +7,8 @@ import ddt
from completion.models import BlockCompletion
from completion.services import CompletionService
from completion.test_utils import CompletionWaffleTestMixin
from django.conf import settings
from django.test import override_settings
from opaque_keys.edx.keys import CourseKey
from xmodule.library_tools import LibraryToolsService
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
@@ -181,6 +183,19 @@ class CompletionServiceTestCase(CompletionWaffleTestMixin, SharedModuleStoreTest
assert self.completion_service.can_mark_block_complete_on_view(self.html) is True
assert self.completion_service.can_mark_block_complete_on_view(self.problem) is False
@override_settings(FEATURES={**settings.FEATURES, 'MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW': True})
def test_can_mark_library_content_complete_on_view(self):
library = LibraryFactory.create(modulestore=self.store)
lib_vertical = ItemFactory.create(parent=self.sequence, category='vertical', publish_item=False)
library_content_block = ItemFactory.create(
parent=lib_vertical,
category='library_content',
max_count=1,
source_library_id=str(library.location.library_key),
user_id=self.user.id,
)
self.assertTrue(self.completion_service.can_mark_block_complete_on_view(library_content_block))
def test_vertical_completion_with_library_content(self):
library = LibraryFactory.create(modulestore=self.store)
ItemFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id)
@@ -202,6 +217,9 @@ class CompletionServiceTestCase(CompletionWaffleTestMixin, SharedModuleStoreTest
source_library_id=str(library.location.library_key),
user_id=self.user.id,
)
# Library Content Block needs its children to be completed.
self.assertFalse(self.completion_service.can_mark_block_complete_on_view(library_content_block))
library_content_block.refresh_children()
lib_vertical = self.store.get_item(lib_vertical.location)
self._bind_course_module(lib_vertical)