'Renders the course\'s home page 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)
    dates_fragment = CourseDatesFragmentView().render_to_fragment(request, course_id=course_id, **kwargs)
    user_access = {'is_anonymous': request.user.is_anonymous(), 'is_enrolled': CourseEnrollment.is_enrolled(request.user, course_key), 'is_staff': has_access(request.user, 'staff', course_key)}
    if (user_access['is_enrolled'] or user_access['is_staff']):
        outline_fragment = CourseOutlineFragmentView().render_to_fragment(request, course_id=course_id, **kwargs)
        welcome_message_fragment = WelcomeMessageFragmentView().render_to_fragment(request, course_id=course_id, **kwargs)
        course_sock_fragment = CourseSockFragmentView().render_to_fragment(request, course=course, **kwargs)
        (has_visited_course, resume_course_url) = self._get_resume_course_info(request, course_id)
    else:
        if (not can_self_enroll_in_course(course_key)):
            raise CourseAccessRedirect(reverse('dashboard'))
        outline_fragment = None
        welcome_message_fragment = None
        course_sock_fragment = None
        has_visited_course = None
        resume_course_url = None
    handouts_html = self._get_course_handouts(request, course)
    course_tools = CourseToolsPluginManager.get_enabled_course_tools(request, course_key)
    course_home_message_fragment = CourseHomeMessageFragmentView().render_to_fragment(request, course_id=course_id, user_access=user_access, **kwargs)
    context = {'request': request, 'csrf': csrf(request)['csrf_token'], 'course': course, 'course_key': course_key, 'outline_fragment': outline_fragment, 'handouts_html': handouts_html, 'course_home_message_fragment': course_home_message_fragment, 'has_visited_course': has_visited_course, 'resume_course_url': resume_course_url, 'course_tools': course_tools, 'dates_fragment': dates_fragment, 'welcome_message_fragment': welcome_message_fragment, 'course_sock_fragment': course_sock_fragment, 'disable_courseware_js': True, 'uses_pattern_library': True}
    html = render_to_string('course_experience/course-home-fragment.html', context)
    return Fragment(html)
