diff --git a/openedx/core/djangoapps/course_live/tab.py b/openedx/core/djangoapps/course_live/tab.py new file mode 100644 index 0000000000..29f97eb8c9 --- /dev/null +++ b/openedx/core/djangoapps/course_live/tab.py @@ -0,0 +1,41 @@ +""" +Configurations to render Course Live Tab +""" +from django.utils.translation import gettext_lazy +from lti_consumer.models import LtiConfiguration + +from common.lib.xmodule.xmodule.course_module import CourseBlock +from common.lib.xmodule.xmodule.tabs import TabFragmentViewMixin +from lms.djangoapps.courseware.tabs import EnrolledTab +from openedx.core.djangoapps.course_live.config.waffle import ENABLE_COURSE_LIVE +from openedx.core.djangoapps.course_live.models import CourseLiveConfiguration +from openedx.core.lib.cache_utils import request_cached +from openedx.features.lti_course_tab.tab import LtiCourseLaunchMixin + + +class CourseLiveTab(LtiCourseLaunchMixin, TabFragmentViewMixin, EnrolledTab): + """ + Course tab that loads the associated LTI-based live provider in a tab. + """ + type = 'lti_live' + priority = 42 + allow_multiple = False + is_dynamic = True + title = gettext_lazy("Live") + + @request_cached() + def _get_lti_config(self, course: CourseBlock) -> LtiConfiguration: + """ + Get course live configurations + """ + return CourseLiveConfiguration.get(course.id).lti_configuration + + @classmethod + @request_cached() + def is_enabled(cls, course, user=None): + """ + Check if the tab is enabled. + """ + return (ENABLE_COURSE_LIVE.is_enabled(course.id) and + super().is_enabled(course, user) and + CourseLiveConfiguration.is_enabled(course.id)) diff --git a/setup.py b/setup.py index 159a0f94e9..ef1d2fc033 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ setup( "html_textbooks = lms.djangoapps.courseware.tabs:HtmlTextbookTabs", "instructor = lms.djangoapps.instructor.views.instructor_dashboard:InstructorDashboardTab", "lti_discussion = openedx.features.lti_course_tab.tab:DiscussionLtiCourseTab", + "lti_live = openedx.core.djangoapps.course_live.tab:CourseLiveTab", "lti_tab = openedx.features.lti_course_tab.tab:LtiCourseTab", "pdf_textbooks = lms.djangoapps.courseware.tabs:PDFTextbookTabs", "progress = lms.djangoapps.courseware.tabs:ProgressTab",