Merge pull request #5983 from edx/ammar/tnl-827
Remove ability to add new ORA 1 problems to courses
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import copy
|
||||
import mock
|
||||
from mock import patch
|
||||
import shutil
|
||||
import lxml
|
||||
|
||||
@@ -536,6 +537,7 @@ class MiscCourseTests(ContentStoreTestCase):
|
||||
for expected in expected_types:
|
||||
self.assertIn(expected, resp.content)
|
||||
|
||||
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', [])
|
||||
def test_advanced_components_in_edit_unit(self):
|
||||
# This could be made better, but for now let's just assert that we see the advanced modules mentioned in the page
|
||||
# response HTML
|
||||
|
||||
@@ -56,6 +56,13 @@ ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules'
|
||||
ADVANCED_PROBLEM_TYPES = settings.ADVANCED_PROBLEM_TYPES
|
||||
|
||||
|
||||
def _advanced_component_types():
|
||||
"""
|
||||
Return advanced component types which can be created.
|
||||
"""
|
||||
return [c_type for c_type in ADVANCED_COMPONENT_TYPES if c_type not in settings.DEPRECATED_ADVANCED_COMPONENT_TYPES]
|
||||
|
||||
|
||||
@require_GET
|
||||
@login_required
|
||||
def subsection_handler(request, usage_key_string):
|
||||
@@ -292,10 +299,11 @@ def get_component_templates(course):
|
||||
# enabled for the course.
|
||||
course_advanced_keys = course.advanced_modules
|
||||
advanced_component_templates = {"type": "advanced", "templates": [], "display_name": _("Advanced")}
|
||||
advanced_component_types = _advanced_component_types()
|
||||
# Set component types according to course policy file
|
||||
if isinstance(course_advanced_keys, list):
|
||||
for category in course_advanced_keys:
|
||||
if category in ADVANCED_COMPONENT_TYPES and not category in categories:
|
||||
if category in advanced_component_types and not category in categories:
|
||||
# boilerplates not supported for advanced components
|
||||
try:
|
||||
component_display_name = xblock_type_display_name(category, default_display_name=category)
|
||||
|
||||
@@ -1203,6 +1203,43 @@ class TestComponentTemplates(CourseTestCase):
|
||||
self.assertEqual(ora_template.get('category'), 'openassessment')
|
||||
self.assertIsNone(ora_template.get('boilerplate_name', None))
|
||||
|
||||
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', ["combinedopenended", "peergrading"])
|
||||
def test_ora1_no_advance_component_button(self):
|
||||
"""
|
||||
Test that there will be no `Advanced` button on unit page if `combinedopenended` and `peergrading` are
|
||||
deprecated provided that there are only 'combinedopenended', 'peergrading' modules in `Advanced Module List`
|
||||
"""
|
||||
self.course.advanced_modules.extend(['combinedopenended', 'peergrading'])
|
||||
templates = get_component_templates(self.course)
|
||||
button_names = [template['display_name'] for template in templates]
|
||||
self.assertNotIn('Advanced', button_names)
|
||||
|
||||
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', ["combinedopenended", "peergrading"])
|
||||
def test_cannot_create_ora1_problems(self):
|
||||
"""
|
||||
Test that we can't create ORA1 problems if `combinedopenended` and `peergrading` are deprecated
|
||||
"""
|
||||
self.course.advanced_modules.extend(['annotatable', 'combinedopenended', 'peergrading'])
|
||||
templates = get_component_templates(self.course)
|
||||
button_names = [template['display_name'] for template in templates]
|
||||
self.assertIn('Advanced', button_names)
|
||||
self.assertEqual(len(templates[0]['templates']), 1)
|
||||
template_display_names = [template['display_name'] for template in templates[0]['templates']]
|
||||
self.assertEqual(template_display_names, ['Annotation'])
|
||||
|
||||
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', [])
|
||||
def test_create_ora1_problems(self):
|
||||
"""
|
||||
Test that we can create ORA1 problems if `combinedopenended` and `peergrading` are not deprecated
|
||||
"""
|
||||
self.course.advanced_modules.extend(['annotatable', 'combinedopenended', 'peergrading'])
|
||||
templates = get_component_templates(self.course)
|
||||
button_names = [template['display_name'] for template in templates]
|
||||
self.assertIn('Advanced', button_names)
|
||||
self.assertEqual(len(templates[0]['templates']), 3)
|
||||
template_display_names = [template['display_name'] for template in templates[0]['templates']]
|
||||
self.assertEqual(template_display_names, ['Annotation', 'Open Response Assessment', 'Peer Grading Interface'])
|
||||
|
||||
|
||||
class TestXBlockInfo(ItemTest):
|
||||
"""
|
||||
|
||||
@@ -743,6 +743,10 @@ ADVANCED_COMPONENT_TYPES = [
|
||||
'notes',
|
||||
]
|
||||
|
||||
# Adding components in this list will disable the creation of new problem for those
|
||||
# compoenents in studio. Existing problems will work fine and one can edit them in studio
|
||||
DEPRECATED_ADVANCED_COMPONENT_TYPES = []
|
||||
|
||||
# Specify xblocks that should be treated as advanced problems. Each entry is a tuple
|
||||
# specifying the xblock name and an optional YAML template to be used.
|
||||
ADVANCED_PROBLEM_TYPES = [
|
||||
|
||||
Reference in New Issue
Block a user