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
from courseware.tabs import EnrolledTab
7 8


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

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

    @classmethod
19
    def is_enabled(cls, course, user=None):
20 21 22 23 24 25 26
        """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
        """
27
        if not super(EdxNotesTab, cls).is_enabled(course, user=user):
28
            return False
29 30 31 32

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

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


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))