Allow Studio override of Feature Based Enrollment status for individual xblocks
This commit is contained in:
@@ -15,6 +15,7 @@ from six import text_type
|
||||
from django_comment_common.models import assign_default_role
|
||||
from django_comment_common.utils import seed_permissions_roles
|
||||
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration
|
||||
from openedx.features.course_duration_limits.config import CONTENT_TYPE_GATING_STUDIO_UI_FLAG
|
||||
from student import auth
|
||||
from student.models import CourseEnrollment
|
||||
from student.roles import CourseInstructorRole, CourseStaffRole
|
||||
@@ -457,6 +458,9 @@ def get_visibility_partition_info(xblock, course=None):
|
||||
if len(partition["groups"]) > 1 or any(group["selected"] for group in partition["groups"]):
|
||||
selectable_partitions.append(partition)
|
||||
|
||||
if CONTENT_TYPE_GATING_STUDIO_UI_FLAG.is_enabled():
|
||||
selectable_partitions += get_user_partition_info(xblock, schemes=["content_type_gate"], course=course)
|
||||
|
||||
# Now add the cohort user partitions.
|
||||
selectable_partitions = selectable_partitions + get_user_partition_info(xblock, schemes=["cohort"], course=course)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Test the partitions and partitions service
|
||||
"""
|
||||
|
||||
from unittest import TestCase
|
||||
from mock import Mock
|
||||
from mock import Mock, patch
|
||||
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from stevedore.extension import Extension, ExtensionManager
|
||||
@@ -434,6 +434,18 @@ class PartitionServiceBaseClass(PartitionTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(PartitionServiceBaseClass, self).setUp()
|
||||
|
||||
content_gating_flag_patcher = patch(
|
||||
'openedx.features.content_type_gating.partitions.CONTENT_TYPE_GATING_FLAG.is_enabled',
|
||||
return_value=True,
|
||||
).start()
|
||||
self.addCleanup(content_gating_flag_patcher.stop)
|
||||
content_gating_ui_flag_patcher = patch(
|
||||
'openedx.features.content_type_gating.partitions.CONTENT_TYPE_GATING_STUDIO_UI_FLAG.is_enabled',
|
||||
return_value=True,
|
||||
).start()
|
||||
self.addCleanup(content_gating_ui_flag_patcher.stop)
|
||||
|
||||
self.course = Mock(id=CourseLocator('org_0', 'course_0', 'run_0'))
|
||||
self.partition_service = self._create_service("ma")
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ class TestGradeIteration(SharedModuleStoreTestCase):
|
||||
else mock_course_grade.return_value
|
||||
for student in self.students
|
||||
]
|
||||
with self.assertNumQueries(4):
|
||||
with self.assertNumQueries(6):
|
||||
all_course_grades, all_errors = self._course_grades_and_errors_for(self.course, self.students)
|
||||
self.assertEqual(
|
||||
{student: text_type(all_errors[student]) for student in all_errors},
|
||||
|
||||
@@ -413,7 +413,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
|
||||
|
||||
RequestCache.clear_all_namespaces()
|
||||
|
||||
expected_query_count = 43
|
||||
expected_query_count = 45
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
|
||||
with check_mongo_calls(mongo_count):
|
||||
with self.assertNumQueries(expected_query_count):
|
||||
|
||||
@@ -15,6 +15,10 @@ from lms.djangoapps.courseware.masquerade import (
|
||||
get_masquerading_user_group,
|
||||
)
|
||||
from xmodule.partitions.partitions import Group, UserPartition, UserPartitionError
|
||||
from openedx.features.course_duration_limits.config import (
|
||||
CONTENT_TYPE_GATING_FLAG,
|
||||
CONTENT_TYPE_GATING_STUDIO_UI_FLAG,
|
||||
)
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -34,6 +38,9 @@ def create_content_gating_partition(course):
|
||||
Create and return the Content Gating user partition.
|
||||
"""
|
||||
|
||||
if not (CONTENT_TYPE_GATING_FLAG.is_enabled() or CONTENT_TYPE_GATING_STUDIO_UI_FLAG.is_enabled()):
|
||||
return None
|
||||
|
||||
try:
|
||||
content_gate_scheme = UserPartition.get_scheme("content_type_gate")
|
||||
except UserPartitionError:
|
||||
@@ -56,7 +63,7 @@ def create_content_gating_partition(course):
|
||||
|
||||
partition = content_gate_scheme.create_user_partition(
|
||||
id=CONTENT_GATING_PARTITION_ID,
|
||||
name=_(u"Content Type Gating"),
|
||||
name=_(u"Feature-based Enrollments"),
|
||||
description=_(u"Partition for segmenting users by access to gated content types"),
|
||||
parameters={"course_id": unicode(course.id)}
|
||||
)
|
||||
|
||||
@@ -11,3 +11,9 @@ CONTENT_TYPE_GATING_FLAG = WaffleFlag(
|
||||
flag_name=u'debug',
|
||||
flag_undefined_default=False
|
||||
)
|
||||
|
||||
CONTENT_TYPE_GATING_STUDIO_UI_FLAG = WaffleFlag(
|
||||
waffle_namespace=WAFFLE_FLAG_NAMESPACE,
|
||||
flag_name=u'studio_ui',
|
||||
flag_undefined_default=False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user