plugins.py 1.36 KB
Newer Older
1 2 3
"""
Registers the "edX Notes" feature for the edX platform.
"""
4
from django.conf import settings
5
from django.utils.translation import ugettext_noop
6

7
from courseware.tabs import EnrolledTab
8 9


10
class EdxNotesTab(EnrolledTab):
11
    """
12
    The representation of the edX Notes course tab type.
13 14
    """

15
    type = "edxnotes"
16
    title = ugettext_noop("Notes")
17 18 19
    view_name = "edxnotes"

    @classmethod
20
    def is_enabled(cls, course, user=None):
21 22 23 24 25 26 27
        """Returns true if the edX Notes feature is enabled in the course.

        Args:
            course (CourseDescriptor): the course using the feature
            settings (dict): a dict of configuration settings
            user (User): the user interacting with the course
        """
28
        if not super(EdxNotesTab, cls).is_enabled(course, user=user):
29
            return False
30 31 32 33

        if not settings.FEATURES.get("ENABLE_EDXNOTES") or is_harvard_notes_enabled(course):
            return False

34
        return course.edxnotes
35 36 37 38 39 40 41 42 43 44 45 46


def is_harvard_notes_enabled(course):
    """
    Returns True if Harvard Annotation Tool is enabled for the course,
    False otherwise.

    Checks for 'textannotation', 'imageannotation', 'videoannotation' in the list
    of advanced modules of the course.
    """
    modules = set(['textannotation', 'imageannotation', 'videoannotation'])
    return bool(modules.intersection(course.advanced_modules))