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>
This commit is contained in:
committed by
GitHub
parent
7cb3196a1a
commit
d5c50b5376
@@ -445,7 +445,7 @@ def get_component_templates(courselike, library=False): # lint-amnesty, pylint:
|
||||
# These modules should be specified as a list of strings, where the strings
|
||||
# are the names of the modules in ADVANCED_COMPONENT_TYPES that should be
|
||||
# enabled for the course.
|
||||
course_advanced_keys = courselike.advanced_modules
|
||||
course_advanced_keys = list(dict.fromkeys(courselike.advanced_modules + settings.DEFAULT_ADVANCED_MODULES))
|
||||
advanced_component_templates = {
|
||||
"type": "advanced",
|
||||
"templates": [],
|
||||
|
||||
@@ -2903,6 +2903,16 @@ class TestComponentTemplates(CourseTestCase):
|
||||
|
||||
self.templates = get_component_templates(self.course)
|
||||
|
||||
self.default_advanced_modules_titles = [
|
||||
"Google Calendar",
|
||||
"Google Document",
|
||||
"LTI Consumer",
|
||||
"Poll",
|
||||
"Content Experiment",
|
||||
"Survey",
|
||||
"Word cloud",
|
||||
]
|
||||
|
||||
def get_templates_of_type(self, template_type):
|
||||
"""
|
||||
Returns the templates for the specified type, or None if none is found.
|
||||
@@ -2956,7 +2966,12 @@ class TestComponentTemplates(CourseTestCase):
|
||||
self.assertGreater(len(self.get_templates_of_type("library")), 0)
|
||||
self.assertGreater(len(self.get_templates_of_type("html")), 0)
|
||||
self.assertGreater(len(self.get_templates_of_type("problem")), 0)
|
||||
self.assertIsNone(self.get_templates_of_type("advanced"))
|
||||
|
||||
# Check for default advanced modules
|
||||
advanced_templates = self.get_templates_of_type("advanced")
|
||||
self.assertEqual(len(advanced_templates), len(settings.DEFAULT_ADVANCED_MODULES))
|
||||
advanced_module_titles = [t['display_name'] for t in advanced_templates]
|
||||
self.assertEqual(advanced_module_titles, self.default_advanced_modules_titles)
|
||||
|
||||
# Now fully disable video through XBlockConfiguration
|
||||
XBlockConfiguration.objects.create(name="video", enabled=False)
|
||||
@@ -3004,29 +3019,38 @@ class TestComponentTemplates(CourseTestCase):
|
||||
"""
|
||||
Test the handling of advanced component templates.
|
||||
"""
|
||||
self.course.advanced_modules.append("word_cloud")
|
||||
self.course.advanced_modules.append("done")
|
||||
EXPECTED_ADVANCED_MODULES_LENGTH = len(settings.DEFAULT_ADVANCED_MODULES) + 1
|
||||
self.templates = get_component_templates(self.course)
|
||||
advanced_templates = self.get_templates_of_type("advanced")
|
||||
self.assertEqual(len(advanced_templates), 1)
|
||||
world_cloud_template = advanced_templates[0]
|
||||
self.assertEqual(world_cloud_template.get("category"), "word_cloud")
|
||||
self.assertEqual(world_cloud_template.get("display_name"), "Word cloud")
|
||||
self.assertIsNone(world_cloud_template.get("boilerplate_name", None))
|
||||
self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH)
|
||||
done_template = advanced_templates[0]
|
||||
self.assertEqual(done_template.get("category"), "done")
|
||||
self.assertEqual(done_template.get("display_name"), "Completion")
|
||||
self.assertIsNone(done_template.get("boilerplate_name", None))
|
||||
|
||||
# Verify that non-advanced components are not added twice
|
||||
# Verify that components are not added twice
|
||||
self.course.advanced_modules.append("video")
|
||||
self.course.advanced_modules.append("drag-and-drop-v2")
|
||||
# Already defined advanced modules
|
||||
self.course.advanced_modules.append("poll")
|
||||
self.course.advanced_modules.append("google-document")
|
||||
self.course.advanced_modules.append("survey")
|
||||
|
||||
self.templates = get_component_templates(self.course)
|
||||
advanced_templates = self.get_templates_of_type("advanced")
|
||||
self.assertEqual(len(advanced_templates), 1)
|
||||
self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH)
|
||||
only_template = advanced_templates[0]
|
||||
self.assertNotEqual(only_template.get("category"), "video")
|
||||
self.assertNotEqual(only_template.get("category"), "drag-and-drop-v2")
|
||||
self.assertNotEqual(only_template.get("category"), "poll")
|
||||
self.assertNotEqual(only_template.get("category"), "google-document")
|
||||
self.assertNotEqual(only_template.get("category"), "survey")
|
||||
|
||||
# Now fully disable word_cloud through XBlockConfiguration
|
||||
XBlockConfiguration.objects.create(name="word_cloud", enabled=False)
|
||||
# Now fully disable done through XBlockConfiguration
|
||||
XBlockConfiguration.objects.create(name="done", enabled=False)
|
||||
self.templates = get_component_templates(self.course)
|
||||
self.assertIsNone(self.get_templates_of_type("advanced"))
|
||||
self.assertTrue((not any(item.get("category") == "done" for item in self.get_templates_of_type("advanced"))))
|
||||
|
||||
def test_advanced_problems(self):
|
||||
"""
|
||||
@@ -3087,8 +3111,9 @@ class TestComponentTemplates(CourseTestCase):
|
||||
XBlockConfiguration) if XBlockStudioConfigurationFlag is False.
|
||||
"""
|
||||
XBlockStudioConfigurationFlag.objects.create(enabled=False)
|
||||
self.course.advanced_modules.extend(["annotatable", "survey"])
|
||||
self._verify_advanced_xblocks(["Annotation", "Survey"], [True, True])
|
||||
self.course.advanced_modules.extend(["annotatable", "done"])
|
||||
expected_xblocks = ["Annotation", "Completion"] + self.default_advanced_modules_titles
|
||||
self._verify_advanced_xblocks(expected_xblocks, [True] * len(expected_xblocks))
|
||||
|
||||
def test_xblock_masquerading_as_problem(self):
|
||||
"""
|
||||
|
||||
@@ -2938,3 +2938,16 @@ LIBRARY_ENABLED_BLOCKS = [
|
||||
'survey',
|
||||
'word_cloud',
|
||||
]
|
||||
|
||||
# .. setting_name: DEFAULT_ADVANCED_MODULES
|
||||
# .. setting_default: ['google-calendar', 'google-document', 'lti_consumer', 'poll', 'split_test', 'survey', 'word_cloud']
|
||||
# .. setting_description: List of advanced modules that are enabled by default
|
||||
DEFAULT_ADVANCED_MODULES = [
|
||||
'google-calendar',
|
||||
'google-document',
|
||||
'lti_consumer',
|
||||
'poll',
|
||||
'split_test',
|
||||
'survey',
|
||||
'word_cloud',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user