plugins.py 923 Bytes
Newer Older
1 2 3 4
"""
Registers the CCX feature for the edX platform.
"""

5
from django.conf import settings
6
from django.utils.translation import ugettext_noop
7

8
from xmodule.tabs import CourseTab
9 10 11
from student.roles import CourseCcxCoachRole


12
class CcxCourseTab(CourseTab):
13
    """
14
    The representation of the CCX course tab
15 16
    """

17
    type = "ccx_coach"
18
    title = ugettext_noop("CCX Coach")
19
    view_name = "ccx_coach_dashboard"
20
    is_dynamic = True    # The CCX view is dynamically added to the set of tabs when it is enabled
21 22

    @classmethod
23
    def is_enabled(cls, course, user=None):
24 25 26 27 28 29 30 31 32
        """
        Returns true if CCX has been enabled and the specified user is a coach
        """
        if not user:
            return True
        if not settings.FEATURES.get('CUSTOM_COURSES_EDX', False) or not course.enable_ccx:
            return False
        role = CourseCcxCoachRole(course.id)
        return role.has_user(user)