예제 #1
0
 def test_notes_enabled(self):
     '''
     Tests that notes are enabled when the course tab configuration contains
     a tab with type "notes."
     '''
     with self.settings(FEATURES={'ENABLE_STUDENT_NOTES': True}):
         self.course.advanced_modules = ["notes"]
         self.assertTrue(utils.notes_enabled_for_course(self.course))
예제 #2
0
 def test_notes_enabled(self):
     '''
     Tests that notes are enabled when the course tab configuration contains
     a tab with type "notes."
     '''
     with self.settings(FEATURES={'ENABLE_STUDENT_NOTES': True}):
         self.course.advanced_modules = ["notes"]
         self.assertTrue(utils.notes_enabled_for_course(self.course))
예제 #3
0
    def test_notes_enabled(self):
        """
        Tests that notes are enabled when the course tab configuration contains
        a tab with type "notes."
        """
        self.course.tabs = [{"type": "foo"}, {"name": "My Notes", "type": "notes"}, {"type": "bar"}]

        self.assertTrue(utils.notes_enabled_for_course(self.course))
예제 #4
0
파일: tests.py 프로젝트: alexmerser/lms
    def test_notes_enabled(self):
        '''
        Tests that notes are enabled when the course tab configuration contains
        a tab with type "notes."
        '''
        self.course.tabs = [{'type': 'foo'},
                            {'name': 'My Notes', 'type': 'notes'},
                            {'type': 'bar'}]

        self.assertTrue(utils.notes_enabled_for_course(self.course))
예제 #5
0
def notes(request, course_id):
    """ Displays the student's notes. """

    course = get_course_with_access(request.user, course_id, "load")
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_id, user=request.user).order_by("-created", "uri")
    context = {"course": course, "notes": notes}

    return render_to_response("notes.html", context)
예제 #6
0
def notes(request, course_id):
    ''' Displays the student's notes. '''

    course = get_course_with_access(request.user, course_id, 'load')
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_id,
                                user=request.user).order_by('-created', 'uri')
    context = {'course': course, 'notes': notes}

    return render_to_response('notes.html', context)
예제 #7
0
def notes(request, course_id):
    ''' Displays the student's notes. '''

    course = get_course_with_access(request.user, course_id, 'load')
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_id, user=request.user).order_by('-created', 'uri')
    context = {
        'course': course,
        'notes': notes
    }

    return render_to_response('notes.html', context)
예제 #8
0
파일: tests.py 프로젝트: jswope00/griffinx
    def test_notes_enabled(self):
        '''
        Tests that notes are enabled when the course tab configuration contains
        a tab with type "notes."
        '''
        self.course.tabs = [{
            'type': 'foo'
        }, {
            'name': 'My Notes',
            'type': 'notes'
        }, {
            'type': 'bar'
        }]

        self.assertTrue(utils.notes_enabled_for_course(self.course))
예제 #9
0
def html_index(request, course_id, book_index, chapter=None):
    """
    Display an HTML textbook.

    course_id: course for which to display text.  The course should have
      "html_textbooks" property defined.

    book index:  zero-based index of which HTML textbook to display.

    chapter:  (optional) one-based index into the chapter array of textbook HTML files to display.
        Defaults to first chapter.  Specifying this assumes that there are separate HTML files for
        each chapter in a textbook.
    """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_with_access(request.user, 'load', course_key)
    staff_access = bool(has_access(request.user, 'staff', course))
    notes_enabled = notes_enabled_for_course(course)

    book_index = int(book_index)
    if book_index < 0 or book_index >= len(course.html_textbooks):
        raise Http404("Invalid book index value: {0}".format(book_index))
    textbook = course.html_textbooks[book_index]

    if 'url' in textbook:
        textbook['url'] = remap_static_url(textbook['url'], course)
    # then remap all the chapter URLs as well, if they are provided.
    if 'chapters' in textbook:
        for entry in textbook['chapters']:
            entry['url'] = remap_static_url(entry['url'], course)

    student = request.user
    return render_to_response(
        'static_htmlbook.html',
        {
            'book_index': book_index,
            'course': course,
            'textbook': textbook,
            'chapter': chapter,
            'student': student,
            'staff_access': staff_access,
            'notes_enabled': notes_enabled,
            'storage': course.annotation_storage_url,
            'token': retrieve_token(student.email,
                                    course.annotation_token_secret),
        },
    )
예제 #10
0
def html_index(request, course_id, book_index, chapter=None):
    """
    Display an HTML textbook.

    course_id: course for which to display text.  The course should have
      "html_textbooks" property defined.

    book index:  zero-based index of which HTML textbook to display.

    chapter:  (optional) one-based index into the chapter array of textbook HTML files to display.
        Defaults to first chapter.  Specifying this assumes that there are separate HTML files for
        each chapter in a textbook.
    """
    course = get_course_with_access(request.user, course_id, 'load')
    staff_access = has_access(request.user, course, 'staff')
    notes_enabled = notes_enabled_for_course(course)

    book_index = int(book_index)
    if book_index < 0 or book_index >= len(course.html_textbooks):
        raise Http404("Invalid book index value: {0}".format(book_index))
    textbook = course.html_textbooks[book_index]

    def remap_static_url(original_url, course):
        input_url = "'" + original_url + "'"
        output_url = replace_static_urls(
            input_url,
            getattr(course, 'data_dir', None),
            course_namespace=course.location
        )
        # strip off the quotes again...
        return output_url[1:-1]

    if 'url' in textbook:
        textbook['url'] = remap_static_url(textbook['url'], course)
    # then remap all the chapter URLs as well, if they are provided.
    if 'chapters' in textbook:
        for entry in textbook['chapters']:
            entry['url'] = remap_static_url(entry['url'], course)

    return render_to_response('static_htmlbook.html',
                              {'book_index': book_index,
                               'course': course,
                               'textbook': textbook,
                               'chapter': chapter,
                               'staff_access': staff_access,
                               'notes_enabled': notes_enabled})
예제 #11
0
def html_index(request, course_id, book_index, chapter=None):
    """
    Display an HTML textbook.

    course_id: course for which to display text.  The course should have
      "html_textbooks" property defined.

    book index:  zero-based index of which HTML textbook to display.

    chapter:  (optional) one-based index into the chapter array of textbook HTML files to display.
        Defaults to first chapter.  Specifying this assumes that there are separate HTML files for
        each chapter in a textbook.
    """
    course = get_course_with_access(request.user, course_id, 'load')
    staff_access = has_access(request.user, course, 'staff')
    notes_enabled = notes_enabled_for_course(course)

    book_index = int(book_index)
    if book_index < 0 or book_index >= len(course.html_textbooks):
        raise Http404("Invalid book index value: {0}".format(book_index))
    textbook = course.html_textbooks[book_index]

    def remap_static_url(original_url, course):
        input_url = "'" + original_url + "'"
        output_url = replace_static_urls(input_url,
                                         getattr(course, 'data_dir', None),
                                         course_namespace=course.location)
        # strip off the quotes again...
        return output_url[1:-1]

    if 'url' in textbook:
        textbook['url'] = remap_static_url(textbook['url'], course)
    # then remap all the chapter URLs as well, if they are provided.
    if 'chapters' in textbook:
        for entry in textbook['chapters']:
            entry['url'] = remap_static_url(entry['url'], course)

    return render_to_response(
        'static_htmlbook.html', {
            'book_index': book_index,
            'course': course,
            'textbook': textbook,
            'chapter': chapter,
            'staff_access': staff_access,
            'notes_enabled': notes_enabled
        })
예제 #12
0
def html_index(request, course_id, book_index, chapter=None):
    """
    Display an HTML textbook.

    course_id: course for which to display text.  The course should have
      "html_textbooks" property defined.

    book index:  zero-based index of which HTML textbook to display.

    chapter:  (optional) one-based index into the chapter array of textbook HTML files to display.
        Defaults to first chapter.  Specifying this assumes that there are separate HTML files for
        each chapter in a textbook.
    """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_with_access(request.user, 'load', course_key)
    staff_access = bool(has_access(request.user, 'staff', course))
    notes_enabled = notes_enabled_for_course(course)

    book_index = int(book_index)
    if book_index < 0 or book_index >= len(course.html_textbooks):
        raise Http404("Invalid book index value: {0}".format(book_index))
    textbook = course.html_textbooks[book_index]

    if 'url' in textbook:
        textbook['url'] = remap_static_url(textbook['url'], course)
    # then remap all the chapter URLs as well, if they are provided.
    if 'chapters' in textbook:
        for entry in textbook['chapters']:
            entry['url'] = remap_static_url(entry['url'], course)

    student = request.user
    return render_to_response(
        'static_htmlbook.html',
        {
            'book_index': book_index,
            'course': course,
            'textbook': textbook,
            'chapter': chapter,
            'student': student,
            'staff_access': staff_access,
            'notes_enabled': notes_enabled,
            'storage': course.annotation_storage_url,
            'token': retrieve_token(student.email, course.annotation_token_secret),
        },
    )
예제 #13
0
def notes(request, course_id):
    ''' Displays the student's notes. '''

    course = get_course_with_access(request.user, course_id, 'load')
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_id, user=request.user).order_by('-created', 'uri')

    student = request.user
    storage = course.annotation_storage_url
    context = {
        'course': course,
        'notes': notes,
        'student': student,
        'storage': storage,
        'token': retrieve_token(student.email, course.annotation_token_secret),
    }
    return render_to_response('notes.html', context)
예제 #14
0
def html_index(request, course_id, book_index, chapter=None):
    """
    Display an HTML textbook.

    course_id: course for which to display text.  The course should have
      "html_textbooks" property defined.

    book index:  zero-based index of which HTML textbook to display.

    chapter:  (optional) one-based index into the chapter array of textbook HTML files to display.
        Defaults to first chapter.  Specifying this assumes that there are separate HTML files for
        each chapter in a textbook.
    """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_with_access(request.user, "load", course_key)
    staff_access = has_access(request.user, "staff", course)
    notes_enabled = notes_enabled_for_course(course)

    book_index = int(book_index)
    if book_index < 0 or book_index >= len(course.html_textbooks):
        raise Http404("Invalid book index value: {0}".format(book_index))
    textbook = course.html_textbooks[book_index]

    if "url" in textbook:
        textbook["url"] = remap_static_url(textbook["url"], course)
    # then remap all the chapter URLs as well, if they are provided.
    if "chapters" in textbook:
        for entry in textbook["chapters"]:
            entry["url"] = remap_static_url(entry["url"], course)

    student = request.user
    return render_to_response(
        "static_htmlbook.html",
        {
            "book_index": book_index,
            "course": course,
            "textbook": textbook,
            "chapter": chapter,
            "student": student,
            "staff_access": staff_access,
            "notes_enabled": notes_enabled,
        },
    )
예제 #15
0
def notes(request, course_id):
    ''' Displays the student's notes. '''

    course = get_course_with_access(request.user, 'load', course_id)
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_id, user=request.user).order_by('-created', 'uri')

    student = request.user
    storage = course.annotation_storage_url
    context = {
        'course': course,
        'notes': notes,
        'student': student,
        'storage': storage,
        'token': retrieve_token(student.email, course.annotation_token_secret),
    }

    return render_to_response('notes.html', context)
예제 #16
0
파일: views.py 프로젝트: ahmadiga/min_edx
def notes(request, course_id):
    """ Displays the student's notes. """
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_with_access(request.user, "load", course_key)
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_key, user=request.user).order_by("-created", "uri")

    student = request.user
    storage = course.annotation_storage_url
    context = {
        "course": course,
        "notes": notes,
        "student": student,
        "storage": storage,
        "token": retrieve_token(student.email, course.annotation_token_secret),
        "default_tab": "myNotes",
    }

    return render_to_response("notes.html", context)
예제 #17
0
def notes(request, course_id):
    ''' Displays the student's notes. '''
    course_key = CourseKey.from_string(course_id)
    course = get_course_with_access(request.user, 'load', course_key)
    if not notes_enabled_for_course(course):
        raise Http404

    notes = Note.objects.filter(course_id=course_key,
                                user=request.user).order_by('-created', 'uri')

    student = request.user
    storage = course.annotation_storage_url
    context = {
        'course': course,
        'notes': notes,
        'student': student,
        'storage': storage,
        'token': None,
        'default_tab': 'myNotes',
    }

    return render_to_response('notes.html', context)
예제 #18
0
def api_enabled(request, course_key):
    '''
    Returns True if the api is enabled for the course, otherwise False.
    '''
    course = _get_course(request, course_key)
    return notes_enabled_for_course(course)
예제 #19
0
파일: tests.py 프로젝트: jswope00/griffinx
 def test_notes_not_enabled(self):
     '''
     Tests that notes are disabled when the course tab configuration does NOT
     contain a tab with type "notes."
     '''
     self.assertFalse(utils.notes_enabled_for_course(self.course))
예제 #20
0
 def test_notes_not_enabled(self):
     '''
     Tests that notes are disabled when the course tab configuration does NOT
     contain a tab with type "notes."
     '''
     self.assertFalse(utils.notes_enabled_for_course(self.course))
예제 #21
0
def api_enabled(request, course_key):
    '''
    Returns True if the api is enabled for the course, otherwise False.
    '''
    course = _get_course(request, course_key)
    return notes_enabled_for_course(course)