Skip to content

Commit 8dffb06

Browse files
committed
fix: enable teams with content groups connection only if teams is enabled
1 parent b955621 commit 8dffb06

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

cms/djangoapps/contentstore/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,8 +2197,10 @@ def get_group_configurations_context(course, store):
21972197
if should_show_enrollment_track:
21982198
displayable_partitions.insert(0, partition)
21992199
elif partition['scheme'] == TEAM_SCHEME:
2200-
should_show_team_partitions = len(partition['groups']) > 0 and CONTENT_GROUPS_FOR_TEAMS.is_enabled(
2201-
course_key
2200+
should_show_team_partitions = (
2201+
course.teams_enabled
2202+
and len(partition["groups"]) > 0
2203+
and CONTENT_GROUPS_FOR_TEAMS.is_enabled(course_key)
22022204
)
22032205
if should_show_team_partitions:
22042206
displayable_partitions.append(partition)

cms/djangoapps/models/settings/course_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def fill_teams_user_partitions_ids(cls, block, teams_config):
316316
This is used by the Dynamic Team Partition Generator to create the dynamic user partitions
317317
based on the team-sets defined in the course.
318318
"""
319-
if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(block.id):
319+
if not block.teams_enabled or not CONTENT_GROUPS_FOR_TEAMS.is_enabled(block.id):
320320
return teams_config
321321

322322
for team_set in teams_config.teamsets:

lms/djangoapps/teams/team_partition_scheme.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from lms.djangoapps.teams.models import CourseTeamMembership
1515
from openedx.core.lib.teams_config import CONTENT_GROUPS_FOR_TEAMS
1616

17+
from xmodule.modulestore.django import modulestore
1718
from xmodule.partitions.partitions import ( # lint-amnesty, pylint: disable=wrong-import-order
1819
Group,
1920
UserPartition
@@ -81,7 +82,8 @@ def get_group_for_user(cls, course_key, user, user_partition):
8182
Returns:
8283
Group: The group in the specified user partition
8384
"""
84-
if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course_key):
85+
course = modulestore().get_course(course_key)
86+
if not course.teams_enabled or not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course_key):
8587
return None
8688

8789
# First, check if we have to deal with masquerading.
@@ -128,7 +130,8 @@ def create_user_partition(cls, id, name, description, groups=None, parameters=No
128130
TeamUserPartition: The user partition.
129131
"""
130132
course_key = CourseKey.from_string(parameters["course_id"])
131-
if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course_key):
133+
course = modulestore().get_course(course_key)
134+
if not course.teams_enabled and not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course_key):
132135
return None
133136

134137
# Team-set used to create partition was created before this feature was

openedx/core/djangoapps/content/learning_sequences/api/processors/team_partition_groups.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from openedx.core import types
1111
from openedx.core.djangoapps.content.learning_sequences.api.processors.base import OutlineProcessor
1212
from openedx.core.lib.teams_config import create_team_set_partitions_with_course_id, CONTENT_GROUPS_FOR_TEAMS
13+
from xmodule.modulestore.django import modulestore
1314
from xmodule.partitions.partitions import Group
1415
from xmodule.partitions.partitions_service import get_user_partition_groups
1516

@@ -37,7 +38,8 @@ def load_data(self, _) -> None:
3738
"""
3839
Pull team groups for this course and which group the user is in.
3940
"""
40-
if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(self.course_key):
41+
course = modulestore().get_course(self.course_key)
42+
if not course.teams_enabled or not CONTENT_GROUPS_FOR_TEAMS.is_enabled(self.course_key):
4143
return
4244

4345
user_partitions = create_team_set_partitions_with_course_id(self.course_key)
@@ -61,7 +63,8 @@ def _is_user_excluded_by_partition_group(self, user_partition_groups):
6163
The user is excluded from the content if and only if, for a non-empty
6264
partition group, the user is not in any of the groups for that partition.
6365
"""
64-
if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(self.course_key):
66+
course = modulestore().get_course(self.course_key)
67+
if not course.teams_enabled or not CONTENT_GROUPS_FOR_TEAMS.is_enabled(self.course_key):
6568
return False
6669

6770
if not user_partition_groups:

openedx/core/lib/teams_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def create_team_set_partition(course):
400400
"""
401401
Get the dynamic enrollment track user partition based on the team-sets of the course.
402402
"""
403-
if not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course.id):
403+
if not course.teams_enabled or not CONTENT_GROUPS_FOR_TEAMS.is_enabled(course.id):
404404
return []
405405
return create_team_set_partitions_with_course_id(
406406
course.id,

0 commit comments

Comments
 (0)