Skip to content

Commit 5445314

Browse files
authored
Merge pull request #36532 from raccoongang/axm-default-advanced-modules
Allow Default Advanced Modules Configuration
2 parents ce00b16 + dcd7c1b commit 5445314

2 files changed

Lines changed: 50 additions & 16 deletions

File tree

cms/djangoapps/contentstore/views/component.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@
8282
"edit-title-button", "edit-upstream-alert",
8383
]
8484

85+
DEFAULT_ADVANCED_MODULES = [
86+
'google-calendar',
87+
'google-document',
88+
'lti_consumer',
89+
'poll',
90+
'split_test',
91+
'survey',
92+
'word_cloud',
93+
]
94+
8595

8696
def _advanced_component_types(show_unsupported):
8797
"""
@@ -445,7 +455,7 @@ def create_support_legend_dict():
445455
# These modules should be specified as a list of strings, where the strings
446456
# are the names of the modules in ADVANCED_COMPONENT_TYPES that should be
447457
# enabled for the course.
448-
course_advanced_keys = courselike.advanced_modules
458+
course_advanced_keys = list(dict.fromkeys(courselike.advanced_modules + DEFAULT_ADVANCED_MODULES))
449459
advanced_component_templates = {
450460
"type": "advanced",
451461
"templates": [],

cms/djangoapps/contentstore/views/tests/test_block.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration
7676
from openedx.core.djangoapps.content_tagging import api as tagging_api
7777

78-
from ..component import component_handler, get_component_templates
78+
from ..component import component_handler, DEFAULT_ADVANCED_MODULES, get_component_templates
7979
from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import (
8080
ALWAYS,
8181
VisibilityState,
@@ -2900,6 +2900,16 @@ def setUp(self):
29002900

29012901
self.templates = get_component_templates(self.course)
29022902

2903+
self.default_advanced_modules_titles = [
2904+
"Google Calendar",
2905+
"Google Document",
2906+
"LTI Consumer",
2907+
"Poll",
2908+
"Content Experiment",
2909+
"Survey",
2910+
"Word cloud",
2911+
]
2912+
29032913
def get_templates_of_type(self, template_type):
29042914
"""
29052915
Returns the templates for the specified type, or None if none is found.
@@ -2953,7 +2963,11 @@ def test_basic_components(self):
29532963
self.assertGreater(len(self.get_templates_of_type("library")), 0)
29542964
self.assertGreater(len(self.get_templates_of_type("html")), 0)
29552965
self.assertGreater(len(self.get_templates_of_type("problem")), 0)
2956-
self.assertIsNone(self.get_templates_of_type("advanced"))
2966+
2967+
# Check for default advanced modules
2968+
advanced_templates = self.get_templates_of_type("advanced")
2969+
advanced_module_keys = [t['category'] for t in advanced_templates]
2970+
self.assertCountEqual(advanced_module_keys, DEFAULT_ADVANCED_MODULES)
29572971

29582972
# Now fully disable video through XBlockConfiguration
29592973
XBlockConfiguration.objects.create(name="video", enabled=False)
@@ -3001,29 +3015,38 @@ def test_advanced_components(self):
30013015
"""
30023016
Test the handling of advanced component templates.
30033017
"""
3004-
self.course.advanced_modules.append("word_cloud")
3018+
self.course.advanced_modules.append("done")
3019+
EXPECTED_ADVANCED_MODULES_LENGTH = len(DEFAULT_ADVANCED_MODULES) + 1
30053020
self.templates = get_component_templates(self.course)
30063021
advanced_templates = self.get_templates_of_type("advanced")
3007-
self.assertEqual(len(advanced_templates), 1)
3008-
world_cloud_template = advanced_templates[0]
3009-
self.assertEqual(world_cloud_template.get("category"), "word_cloud")
3010-
self.assertEqual(world_cloud_template.get("display_name"), "Word cloud")
3011-
self.assertIsNone(world_cloud_template.get("boilerplate_name", None))
3022+
self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH)
3023+
done_template = advanced_templates[0]
3024+
self.assertEqual(done_template.get("category"), "done")
3025+
self.assertEqual(done_template.get("display_name"), "Completion")
3026+
self.assertIsNone(done_template.get("boilerplate_name", None))
30123027

3013-
# Verify that non-advanced components are not added twice
3028+
# Verify that components are not added twice
30143029
self.course.advanced_modules.append("video")
30153030
self.course.advanced_modules.append("drag-and-drop-v2")
3031+
# Already defined advanced modules
3032+
self.course.advanced_modules.append("poll")
3033+
self.course.advanced_modules.append("google-document")
3034+
self.course.advanced_modules.append("survey")
3035+
30163036
self.templates = get_component_templates(self.course)
30173037
advanced_templates = self.get_templates_of_type("advanced")
3018-
self.assertEqual(len(advanced_templates), 1)
3038+
self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH)
30193039
only_template = advanced_templates[0]
30203040
self.assertNotEqual(only_template.get("category"), "video")
30213041
self.assertNotEqual(only_template.get("category"), "drag-and-drop-v2")
3042+
self.assertNotEqual(only_template.get("category"), "poll")
3043+
self.assertNotEqual(only_template.get("category"), "google-document")
3044+
self.assertNotEqual(only_template.get("category"), "survey")
30223045

3023-
# Now fully disable word_cloud through XBlockConfiguration
3024-
XBlockConfiguration.objects.create(name="word_cloud", enabled=False)
3046+
# Now fully disable done through XBlockConfiguration
3047+
XBlockConfiguration.objects.create(name="done", enabled=False)
30253048
self.templates = get_component_templates(self.course)
3026-
self.assertIsNone(self.get_templates_of_type("advanced"))
3049+
self.assertTrue((not any(item.get("category") == "done" for item in self.get_templates_of_type("advanced"))))
30273050

30283051
def test_advanced_problems(self):
30293052
"""
@@ -3084,8 +3107,9 @@ def test_create_support_level_flag_off(self):
30843107
XBlockConfiguration) if XBlockStudioConfigurationFlag is False.
30853108
"""
30863109
XBlockStudioConfigurationFlag.objects.create(enabled=False)
3087-
self.course.advanced_modules.extend(["annotatable", "survey"])
3088-
self._verify_advanced_xblocks(["Annotation", "Survey"], [True, True])
3110+
self.course.advanced_modules.extend(["annotatable", "done"])
3111+
expected_xblocks = ["Annotation", "Completion"] + self.default_advanced_modules_titles
3112+
self._verify_advanced_xblocks(expected_xblocks, [True] * len(expected_xblocks))
30893113

30903114
def test_xblock_masquerading_as_problem(self):
30913115
"""

0 commit comments

Comments
 (0)