From 8d0ada54c428b0c546119338d3661980ed4d23d2 Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:00:42 -0400 Subject: [PATCH] feat: add waffle flag for beta testing new problem editor parser (#35184) * feat: add waffle flag for beta testing new problem editor parser * chore: remove commented out code * fix: failing test --- cms/djangoapps/contentstore/toggles.py | 12 ++++++++++++ .../contentstore/views/tests/test_block.py | 7 ++++++- .../xblock_storage_handlers/view_handlers.py | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/toggles.py b/cms/djangoapps/contentstore/toggles.py index c55a0a8a2238..7c3a369fed62 100644 --- a/cms/djangoapps/contentstore/toggles.py +++ b/cms/djangoapps/contentstore/toggles.py @@ -159,6 +159,18 @@ def use_new_problem_editor(): return ENABLE_NEW_PROBLEM_EDITOR_FLAG.is_enabled() +# .. toggle_name: new_core_editors.use_advanced_problem_editor +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use of the new core problem xblock advanced editor as the default +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2024-07-25 +# .. toggle_target_removal_date: 2024-08-31 +# .. toggle_tickets: TNL-11694 +# .. toggle_warning: +ENABLE_DEFAULT_ADVANCED_PROBLEM_EDITOR_FLAG = WaffleFlag('new_core_editors.use_advanced_problem_editor', __name__) + + # .. toggle_name: new_editors.add_game_block_button # .. toggle_implementation: WaffleFlag # .. toggle_default: False diff --git a/cms/djangoapps/contentstore/views/tests/test_block.py b/cms/djangoapps/contentstore/views/tests/test_block.py index 2e8f60c01150..fc119c7edd58 100644 --- a/cms/djangoapps/contentstore/views/tests/test_block.py +++ b/cms/djangoapps/contentstore/views/tests/test_block.py @@ -521,6 +521,7 @@ def test_ancestor_info(self, field_type): problem1 = self.create_xblock( parent_usage_key=vert_usage_key, display_name="problem1", category="problem" ) + print(problem1) problem_usage_key = self.response_usage_key(problem1) def assert_xblock_info(xblock, xblock_info): @@ -556,7 +557,11 @@ def assert_xblock_info(xblock, xblock_info): xblock = parent_xblock else: self.assertNotIn("ancestors", response) - self.assertEqual(get_block_info(xblock), response) + xblock_info = get_block_info(xblock) + # TODO: remove after beta testing for the new problem editor parser + if xblock_info["category"] == "problem": + xblock_info["metadata"]["default_to_advanced"] = False + self.assertEqual(xblock_info, response) @ddt.ddt diff --git a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py index 4caaefccc265..e7dbec01f8e0 100644 --- a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py +++ b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py @@ -33,6 +33,7 @@ from xblock.fields import Scope from cms.djangoapps.contentstore.config.waffle import SHOW_REVIEW_RULES_FLAG +from cms.djangoapps.contentstore.toggles import ENABLE_DEFAULT_ADVANCED_PROBLEM_EDITOR_FLAG from cms.djangoapps.models.settings.course_grading import CourseGradingModel from cms.lib.ai_aside_summary_config import AiAsideSummaryConfig from common.djangoapps.static_replace import replace_static_urls @@ -184,6 +185,11 @@ def handle_xblock(request, usage_key_string=None): # TODO: pass fields to get_block_info and only return those with modulestore().bulk_operations(usage_key.course_key): response = get_block_info(get_xblock(usage_key, request.user)) + # TODO: remove after beta testing for the new problem editor parser + if response["category"] == "problem": + response["metadata"]["default_to_advanced"] = ( + ENABLE_DEFAULT_ADVANCED_PROBLEM_EDITOR_FLAG.is_enabled() + ) if "customReadToken" in fields: parent_children = _get_block_parent_children(get_xblock(usage_key, request.user)) response.update(parent_children)