Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,19 @@
# .. 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
Expand Down
15 changes: 14 additions & 1 deletion common/lib/xmodule/xmodule/library_content_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
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
Expand Down Expand Up @@ -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"),
Expand Down
13 changes: 13 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,19 @@
# .. 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
Expand Down
Empty file.
18 changes: 18 additions & 0 deletions openedx/tests/completion_integration/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
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
Expand Down Expand Up @@ -181,6 +183,19 @@ def test_can_mark_block_complete_on_view(self):
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)
Expand All @@ -202,6 +217,9 @@ def test_vertical_completion_with_library_content(self):
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)
Expand Down