Skip to content

Commit

Permalink
feat: add a new tenant setting to enable the Course Authoring MFE
Browse files Browse the repository at this point in the history
* fix: modify some test to be according to the new behavior
  • Loading branch information
bra-i-am committed Mar 1, 2024
1 parent cf6e266 commit 44f230c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cms/djangoapps/contentstore/views/tests/test_course_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,10 @@ def test_verify_warn_only_on_enabled_blocks(self, enabled_block_types, deprecate
expected_block_types
)

@override_settings(FEATURES={'ENABLE_EXAM_SETTINGS_HTML_VIEW': True})
@override_settings(FEATURES={
'ENABLE_EXAM_SETTINGS_HTML_VIEW': True,
'ENABLE_MFE_FOR_TESTING': True
})
@patch('cms.djangoapps.models.settings.course_metadata.CourseMetadata.validate_proctoring_settings')
def test_proctoring_link_is_visible(self, mock_validate_proctoring_settings):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
FEATURES_WITH_EXAM_SETTINGS_ENABLED = FEATURES_WITH_CERTS_ENABLED.copy()
FEATURES_WITH_EXAM_SETTINGS_ENABLED['ENABLE_EXAM_SETTINGS_HTML_VIEW'] = True
FEATURES_WITH_EXAM_SETTINGS_ENABLED['ENABLE_PROCTORED_EXAMS'] = True
FEATURES_WITH_EXAM_SETTINGS_ENABLED['ENABLE_MFE_FOR_TESTING'] = True

FEATURES_WITH_EXAM_SETTINGS_DISABLED = FEATURES_WITH_CERTS_ENABLED.copy()
FEATURES_WITH_EXAM_SETTINGS_DISABLED['ENABLE_EXAM_SETTINGS_HTML_VIEW'] = False
Expand Down Expand Up @@ -179,7 +180,10 @@ def test_exam_settings_alert_not_shown(self, page_handler):
alert_nodes = parsed_html.find_class('exam-settings-alert')
assert len(alert_nodes) == 0

@override_settings(FEATURES={'ENABLE_EXAM_SETTINGS_HTML_VIEW': True})
@override_settings(FEATURES={
'ENABLE_EXAM_SETTINGS_HTML_VIEW': True,
'ENABLE_MFE_FOR_TESTING': True
})
@patch('cms.djangoapps.models.settings.course_metadata.CourseMetadata.validate_proctoring_settings')
def test_proctoring_link_is_visible(self, mock_validate_proctoring_settings):

Expand Down
28 changes: 28 additions & 0 deletions cms/lib/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Helper methods for the CMS.
"""

from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from edx_toggles.toggles import SettingDictToggle


def use_course_authoring_mfe(org) -> bool:
"""
Checks with the org if the tenant enables the
Course Authoring MFE.
Returns:
True if the MFE setting is activated, by default
the MFE is deactivated
"""

ENABLE_MFE_FOR_TESTING = SettingDictToggle(
"FEATURES", "ENABLE_MFE_FOR_TESTING", default=False, module_name=__name__
).is_enabled()

use_microfrontend = configuration_helpers.get_value_for_org(
org, "ENABLE_COURSE_AUTHORING_MFE", ENABLE_MFE_FOR_TESTING or False
)

print("=====================================\nIS WORKING\n=============================\nTHE VALUE IS\n", use_microfrontend)

return bool(use_microfrontend)
7 changes: 4 additions & 3 deletions cms/templates/studio_xblock_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
dump_js_escaped_json, js_escaped_string
)
from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor
from cms.lib.utils import use_course_authoring_mfe
%>
<%
use_new_editor_text = use_new_text_editor()
use_new_editor_video = use_new_video_editor()
use_new_editor_problem = use_new_problem_editor()
use_new_editor_text = use_course_authoring_mfe(xblock.location.course_key.org) and use_new_text_editor()
use_new_editor_video = use_course_authoring_mfe(xblock.location.course_key.org) and use_new_video_editor()
use_new_editor_problem = use_course_authoring_mfe(xblock.location.course_key.org) and use_new_problem_editor()
xblock_url = xblock_studio_url(xblock)
show_inline = xblock.has_children and not xblock_url
section_class = "level-nesting" if show_inline else "level-element"
Expand Down
3 changes: 2 additions & 1 deletion cms/templates/widgets/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from cms.djangoapps.contentstore.utils import get_pages_and_resources_url
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
from openedx.core.djangoapps.lang_pref.api import header_language_selector_is_enabled, released_languages
from cms.lib.utils import use_course_authoring_mfe
%>
<div class="wrapper-header wrapper" id="view-top">
<header class="primary" role="banner">
Expand Down Expand Up @@ -45,7 +46,7 @@ <h1 class="branding">
if settings.FEATURES.get("CERTIFICATES_HTML_VIEW") and context_course.cert_html_view_enabled:
certificates_url = reverse('certificates_list_handler', kwargs={'course_key_string': six.text_type(course_key)})
checklists_url = reverse('checklists_handler', kwargs={'course_key_string': six.text_type(course_key)})
pages_and_resources_mfe_enabled = ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND.is_enabled(context_course.id)
pages_and_resources_mfe_enabled = use_course_authoring_mfe(course_key.org) and ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND.is_enabled(context_course.id)
%>
<h2 class="info-course">
<span class="sr">${_("Current Course:")}</span>
Expand Down

0 comments on commit 44f230c

Please sign in to comment.