diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index 9fdbb425e51..a51e0bcfa6c 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -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): """ diff --git a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py index a7ee7f0ab0c..234c85172dd 100644 --- a/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py +++ b/cms/djangoapps/contentstore/views/tests/test_exam_settings_view.py @@ -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 @@ -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): diff --git a/cms/lib/utils.py b/cms/lib/utils.py new file mode 100644 index 00000000000..487c2f91dfa --- /dev/null +++ b/cms/lib/utils.py @@ -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) diff --git a/cms/templates/studio_xblock_wrapper.html b/cms/templates/studio_xblock_wrapper.html index 81a08a4d010..e79beb0aef0 100644 --- a/cms/templates/studio_xblock_wrapper.html +++ b/cms/templates/studio_xblock_wrapper.html @@ -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" diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index 48b818da95a..c0da15cfb12 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -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 %>