|
75 | 75 | from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration |
76 | 76 | from openedx.core.djangoapps.content_tagging import api as tagging_api |
77 | 77 |
|
78 | | -from ..component import component_handler, get_component_templates |
| 78 | +from ..component import component_handler, DEFAULT_ADVANCED_MODULES, get_component_templates |
79 | 79 | from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import ( |
80 | 80 | ALWAYS, |
81 | 81 | VisibilityState, |
@@ -2900,6 +2900,16 @@ def setUp(self): |
2900 | 2900 |
|
2901 | 2901 | self.templates = get_component_templates(self.course) |
2902 | 2902 |
|
| 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 | + |
2903 | 2913 | def get_templates_of_type(self, template_type): |
2904 | 2914 | """ |
2905 | 2915 | Returns the templates for the specified type, or None if none is found. |
@@ -2953,7 +2963,11 @@ def test_basic_components(self): |
2953 | 2963 | self.assertGreater(len(self.get_templates_of_type("library")), 0) |
2954 | 2964 | self.assertGreater(len(self.get_templates_of_type("html")), 0) |
2955 | 2965 | 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) |
2957 | 2971 |
|
2958 | 2972 | # Now fully disable video through XBlockConfiguration |
2959 | 2973 | XBlockConfiguration.objects.create(name="video", enabled=False) |
@@ -3001,29 +3015,38 @@ def test_advanced_components(self): |
3001 | 3015 | """ |
3002 | 3016 | Test the handling of advanced component templates. |
3003 | 3017 | """ |
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 |
3005 | 3020 | self.templates = get_component_templates(self.course) |
3006 | 3021 | 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)) |
3012 | 3027 |
|
3013 | | - # Verify that non-advanced components are not added twice |
| 3028 | + # Verify that components are not added twice |
3014 | 3029 | self.course.advanced_modules.append("video") |
3015 | 3030 | 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 | + |
3016 | 3036 | self.templates = get_component_templates(self.course) |
3017 | 3037 | 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) |
3019 | 3039 | only_template = advanced_templates[0] |
3020 | 3040 | self.assertNotEqual(only_template.get("category"), "video") |
3021 | 3041 | 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") |
3022 | 3045 |
|
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) |
3025 | 3048 | 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")))) |
3027 | 3050 |
|
3028 | 3051 | def test_advanced_problems(self): |
3029 | 3052 | """ |
@@ -3084,8 +3107,9 @@ def test_create_support_level_flag_off(self): |
3084 | 3107 | XBlockConfiguration) if XBlockStudioConfigurationFlag is False. |
3085 | 3108 | """ |
3086 | 3109 | 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)) |
3089 | 3113 |
|
3090 | 3114 | def test_xblock_masquerading_as_problem(self): |
3091 | 3115 | """ |
|
0 commit comments