'Renders the user\'s course bookmarks as a fragment.'

def render_to_fragment(self, request, course_id=None, **kwargs):

    course_key = CourseKey.from_string(course_id)
    course = get_course_with_access(request.user, 'load', course_key, check_if_enrolled=True)
    context = {'csrf': csrf(request)['csrf_token'], 'course': course, 'bookmarks_api_url': reverse('bookmarks'), 'language_preference': 'en'}
    html = render_to_string('course_bookmarks/course-bookmarks-fragment.html', context)
    inline_js = render_to_string('course_bookmarks/course_bookmarks_js.template', context)
    fragment = Fragment(html)
    self.add_fragment_resource_urls(fragment)
    fragment.add_javascript(inline_js)
    return fragment
