From 074900632ae3ef0e339db6a3008209656552d5f3 Mon Sep 17 00:00:00 2001 From: noraiz-anwar Date: Wed, 19 Apr 2017 13:05:32 +0500 Subject: [PATCH] ORAs and Drag and Drop not supported in libraries, remove both from problem types in studio --- .../contentstore/views/component.py | 5 +++-- .../contentstore/views/tests/test_library.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 378c4b2fd2..0afd654db2 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -308,8 +308,9 @@ def get_component_templates(courselike, library=False): ) ) - # Add any advanced problem types. Note that these are different xblocks being stored as Advanced Problems. - if category == 'problem': + # Add any advanced problem types. Note that these are different xblocks being stored as Advanced Problems, + # currently not supported in libraries . + if category == 'problem' and not library: disabled_block_names = [block.name for block in disabled_xblocks()] advanced_problem_types = [advanced_problem_type for advanced_problem_type in ADVANCED_PROBLEM_TYPES if advanced_problem_type['component'] not in disabled_block_names] diff --git a/cms/djangoapps/contentstore/views/tests/test_library.py b/cms/djangoapps/contentstore/views/tests/test_library.py index 0e4c7b5521..e8514afe28 100644 --- a/cms/djangoapps/contentstore/views/tests/test_library.py +++ b/cms/djangoapps/contentstore/views/tests/test_library.py @@ -3,6 +3,7 @@ Unit tests for contentstore.views.library More important high-level tests are in contentstore/tests/test_libraries.py """ +from django.conf import settings from contentstore.tests.utils import AjaxEnabledTestClient, parse_json from contentstore.utils import reverse_course_url, reverse_library_url from contentstore.tests.utils import CourseTestCase @@ -251,6 +252,24 @@ class UnitTestLibraries(CourseTestCase): self.assertNotIn('discussion', templates) self.assertNotIn('advanced', templates) + def test_advanced_problem_types(self): + """ + Verify that advanced problem types are not provided in problem component for libraries. + """ + lib = LibraryFactory.create() + lib.save() + + problem_type_templates = next( + (component['templates'] for component in get_component_templates(lib, library=True) if component['type'] == 'problem'), + [] + ) + # Each problem template has a category which shows whether problem is a 'problem' + # or which of the advanced problem type (e.g drag-and-drop-v2). + problem_type_categories = [problem_template['category'] for problem_template in problem_type_templates] + + for advance_problem_type in settings.ADVANCED_PROBLEM_TYPES: + self.assertNotIn(advance_problem_type['component'], problem_type_categories) + def test_manage_library_users(self): """ Simple test that the Library "User Access" view works.