[TNL-3962] moving DEPRECATED_ADVANCED_COMPONENT_TYPES to dJango admin

This commit is contained in:
Ehtesham
2016-01-20 17:45:35 +05:00
parent ba2c6b79fb
commit b9c8b3308d
7 changed files with 154 additions and 24 deletions

View File

@@ -29,6 +29,7 @@ from opaque_keys.edx.keys import UsageKey
from student.auth import has_course_author_access
from django.utils.translation import ugettext as _
from models.settings.course_grading import CourseGradingModel
from xblock_django.models import XBlockDisableConfig
__all__ = [
'container_handler',
@@ -57,7 +58,8 @@ 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]
disabled_create_block_types = XBlockDisableConfig.disabled_create_block_types()
return [c_type for c_type in ADVANCED_COMPONENT_TYPES if c_type not in disabled_create_block_types]
def _load_mixed_class(category):

View File

@@ -23,6 +23,7 @@ from contentstore.views.item import (
)
from contentstore.tests.utils import CourseTestCase
from student.tests.factories import UserFactory
from xblock_django.models import XBlockDisableConfig
from xmodule.capa_module import CapaDescriptor
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
@@ -1328,6 +1329,11 @@ class TestComponentTemplates(CourseTestCase):
super(TestComponentTemplates, self).setUp()
self.templates = get_component_templates(self.course)
# Initialize the deprecated modules settings with empty list
XBlockDisableConfig.objects.create(
disabled_create_blocks='', enabled=True
)
def get_templates_of_type(self, template_type):
"""
Returns the templates for the specified type, or None if none is found.
@@ -1384,22 +1390,24 @@ class TestComponentTemplates(CourseTestCase):
self.assertEqual(circuit_template.get('category'), 'problem')
self.assertEqual(circuit_template.get('boilerplate_name'), 'circuitschematic.yaml')
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', ["poll", "survey"])
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', [])
def test_deprecated_no_advance_component_button(self):
"""
Test that there will be no `Advanced` button on unit page if units are
deprecated provided that they are the only modules in `Advanced Module List`
"""
XBlockDisableConfig.objects.create(disabled_create_blocks='poll survey', enabled=True)
self.course.advanced_modules.extend(['poll', 'survey'])
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', ["poll", "survey"])
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', [])
def test_cannot_create_deprecated_problems(self):
"""
Test that we can't create problems if they are deprecated
"""
XBlockDisableConfig.objects.create(disabled_create_blocks='poll survey', enabled=True)
self.course.advanced_modules.extend(['annotatable', 'poll', 'survey'])
templates = get_component_templates(self.course)
button_names = [template['display_name'] for template in templates]
@@ -1408,7 +1416,7 @@ class TestComponentTemplates(CourseTestCase):
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', [])
@patch('django.conf.settings.DEPRECATED_ADVANCED_COMPONENT_TYPES', ['poll'])
def test_create_non_deprecated_problems(self):
"""
Test that we can create problems if they are not deprecated
@@ -1417,9 +1425,9 @@ class TestComponentTemplates(CourseTestCase):
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)
self.assertEqual(len(templates[0]['templates']), 2)
template_display_names = [template['display_name'] for template in templates[0]['templates']]
self.assertEqual(template_display_names, ['Annotation', 'Poll', 'Survey'])
self.assertEqual(template_display_names, ['Annotation', 'Survey'])
@ddt.ddt

View File

@@ -999,11 +999,6 @@ ENTRANCE_EXAM_MIN_SCORE_PCT = 50
### Default language for a new course
DEFAULT_COURSE_LANGUAGE = "en"
# Adding components in this list will disable the creation of new problem for
# those components 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
# dict:
# 'component': the entry-point name of the XBlock.
@@ -1055,6 +1050,30 @@ XBLOCK_SETTINGS = {
}
}
################################ XBlock Deprecation ################################
# The following settings are used for deprecating XBlocks.
# Adding an XBlock to this list does the following:
# 1. Shows a warning on the course outline if the XBlock is listed in
# "Advanced Module List" in "Advanced Settings" page.
# 2. List all instances of that XBlock on the top of the course outline page asking
# course authors to delete or replace the instances.
DEPRECATED_BLOCK_TYPES = [
'peergrading',
'combinedopenended',
'graphical_slider_tool',
]
# Adding components in this list will disable the creation of new problems for
# those advanced components in Studio. Existing problems will work fine
# and one can edit them in Studio.
# DEPRECATED. Please use /admin/xblock_django/xblockdisableconfig instead.
DEPRECATED_ADVANCED_COMPONENT_TYPES = []
# XBlocks can be disabled from rendering in LMS Courseware by adding them to
# /admin/xblock_django/xblockdisableconfig/.
################################ Settings for Credit Course Requirements ################################
# Initial delay used for retrying tasks.
# Additional retries use longer delays.
@@ -1070,16 +1089,6 @@ CREDIT_TASK_MAX_RETRIES = 5
# or denied for credit.
CREDIT_PROVIDER_TIMESTAMP_EXPIRATION = 15 * 60
################################ Deprecated Blocks Info ################################
DEPRECATED_BLOCK_TYPES = [
'peergrading',
'combinedopenended',
'graphical_slider_tool',
]
################################ Settings for Microsites ################################
### Select an implementation for the microsite backend
@@ -1094,8 +1103,7 @@ MICROSITE_TEMPLATE_BACKEND = 'microsite_configuration.backends.filebased.Filebas
# TTL for microsite database template cache
MICROSITE_DATABASE_TEMPLATE_CACHE_TTL = 5 * 60
#### PROCTORING CONFIGURATION DEFAULTS
############################### PROCTORING CONFIGURATION DEFAULTS ##############
PROCTORING_BACKEND_PROVIDER = {
'class': 'edx_proctoring.backends.null.NullBackendProvider',
'options': {},