Skip to content

Commit 3bd0105

Browse files
andrii-hantkovskyiAndrii
authored andcommitted
feat: [AXM-1899] add default advanced modules (#2634)
* feat: [AXM-1899] add default advanced modules * test: [AXM-1899] add check for default advanced modules list --------- Co-authored-by: Andrii <andrii.hantkovskyi@raccoongang.com>
1 parent 49a305f commit 3bd0105

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
lines changed

cms/djangoapps/contentstore/views/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def create_support_legend_dict():
445445
# These modules should be specified as a list of strings, where the strings
446446
# are the names of the modules in ADVANCED_COMPONENT_TYPES that should be
447447
# enabled for the course.
448-
course_advanced_keys = courselike.advanced_modules
448+
course_advanced_keys = list(dict.fromkeys(courselike.advanced_modules + settings.DEFAULT_ADVANCED_MODULES))
449449
advanced_component_templates = {
450450
"type": "advanced",
451451
"templates": [],

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

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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,12 @@ 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+
self.assertEqual(len(advanced_templates), len(settings.DEFAULT_ADVANCED_MODULES))
2970+
advanced_module_titles = [t['display_name'] for t in advanced_templates]
2971+
self.assertEqual(advanced_module_titles, self.default_advanced_modules_titles)
29572972

29582973
# Now fully disable video through XBlockConfiguration
29592974
XBlockConfiguration.objects.create(name="video", enabled=False)
@@ -3001,29 +3016,38 @@ def test_advanced_components(self):
30013016
"""
30023017
Test the handling of advanced component templates.
30033018
"""
3004-
self.course.advanced_modules.append("word_cloud")
3019+
self.course.advanced_modules.append("done")
3020+
EXPECTED_ADVANCED_MODULES_LENGTH = len(settings.DEFAULT_ADVANCED_MODULES) + 1
30053021
self.templates = get_component_templates(self.course)
30063022
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))
3023+
self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH)
3024+
done_template = advanced_templates[0]
3025+
self.assertEqual(done_template.get("category"), "done")
3026+
self.assertEqual(done_template.get("display_name"), "Completion")
3027+
self.assertIsNone(done_template.get("boilerplate_name", None))
30123028

3013-
# Verify that non-advanced components are not added twice
3029+
# Verify that components are not added twice
30143030
self.course.advanced_modules.append("video")
30153031
self.course.advanced_modules.append("drag-and-drop-v2")
3032+
# Already defined advanced modules
3033+
self.course.advanced_modules.append("poll")
3034+
self.course.advanced_modules.append("google-document")
3035+
self.course.advanced_modules.append("survey")
3036+
30163037
self.templates = get_component_templates(self.course)
30173038
advanced_templates = self.get_templates_of_type("advanced")
3018-
self.assertEqual(len(advanced_templates), 1)
3039+
self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH)
30193040
only_template = advanced_templates[0]
30203041
self.assertNotEqual(only_template.get("category"), "video")
30213042
self.assertNotEqual(only_template.get("category"), "drag-and-drop-v2")
3043+
self.assertNotEqual(only_template.get("category"), "poll")
3044+
self.assertNotEqual(only_template.get("category"), "google-document")
3045+
self.assertNotEqual(only_template.get("category"), "survey")
30223046

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

30283052
def test_advanced_problems(self):
30293053
"""
@@ -3084,8 +3108,9 @@ def test_create_support_level_flag_off(self):
30843108
XBlockConfiguration) if XBlockStudioConfigurationFlag is False.
30853109
"""
30863110
XBlockStudioConfigurationFlag.objects.create(enabled=False)
3087-
self.course.advanced_modules.extend(["annotatable", "survey"])
3088-
self._verify_advanced_xblocks(["Annotation", "Survey"], [True, True])
3111+
self.course.advanced_modules.extend(["annotatable", "done"])
3112+
expected_xblocks = ["Annotation", "Completion"] + self.default_advanced_modules_titles
3113+
self._verify_advanced_xblocks(expected_xblocks, [True] * len(expected_xblocks))
30893114

30903115
def test_xblock_masquerading_as_problem(self):
30913116
"""

cms/envs/common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,3 +2924,16 @@ def _should_send_learning_badge_events(settings):
29242924
'survey',
29252925
'word_cloud',
29262926
]
2927+
2928+
# .. setting_name: DEFAULT_ADVANCED_MODULES
2929+
# .. setting_default: ['google-calendar', 'google-document', 'lti_consumer', 'poll', 'split_test', 'survey', 'word_cloud']
2930+
# .. setting_description: List of advanced modules that are enabled by default
2931+
DEFAULT_ADVANCED_MODULES = [
2932+
'google-calendar',
2933+
'google-document',
2934+
'lti_consumer',
2935+
'poll',
2936+
'split_test',
2937+
'survey',
2938+
'word_cloud',
2939+
]

0 commit comments

Comments
 (0)