feat: Add a new way to enable/disable teams [BD-38] [TNL-9175] [BB-5066] (#29099)

* feat: Add a new way to enable/disable teams

Adds a new mechanism for enabling/disabling the team feature in a course using an 'enabled' field to the teams config.
If this field is set to true, teams is enabled (team sets/groups) still need to be defined. If this is set to false then teams is disabled whether or not team sets are defined.

* fix: review feedback
This commit is contained in:
Kshitij Sobti
2021-11-01 12:12:06 +00:00
committed by GitHub
parent 4583b639e6
commit ff61434893
5 changed files with 245 additions and 107 deletions

View File

@@ -12,6 +12,8 @@ from lms.djangoapps.courseware.tabs import EnrolledTab
from lms.djangoapps.teams.waffle import ENABLE_TEAMS_APP
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.course_apps.plugins import CourseApp
from openedx.core.lib.courses import get_course_by_id
from xmodule.modulestore.django import modulestore
from . import is_feature_enabled
@@ -64,11 +66,30 @@ class TeamsCourseApp(CourseApp):
@classmethod
def is_enabled(cls, course_key: CourseKey) -> bool:
"""
Returns the enabled status of teams.
Args:
course_key (CourseKey): The course for which to fetch the status of teams
"""
return CourseOverview.get_from_id(course_key).teams_enabled
@classmethod
def set_enabled(cls, course_key: CourseKey, enabled: bool, user: User) -> bool:
raise ValueError("Teams cannot be enabled/disabled via this API.")
"""
Returns the enabled status of teams.
Args:
course_key (CourseKey): The course for which to set the status of teams
enabled (bool): The new satus for the app.
user (User): The user performing the operation
Returns:
(bool): the new status of the app
"""
course = get_course_by_id(course_key)
course.teams_configuration.is_enabled = enabled
modulestore().update_item(course, user.id)
return enabled
@classmethod
def get_allowed_operations(cls, course_key: CourseKey, user: Optional[User] = None) -> Dict[str, bool]:
@@ -76,6 +97,6 @@ class TeamsCourseApp(CourseApp):
Return allowed operations for teams app.
"""
return {
"enable": False,
"enable": True,
"configure": True,
}