コード例 #1
0
ファイル: tabs.py プロジェクト: xzhuwu/edx-platform
def get_course_tab_list(user, course):
    """
    Retrieves the course tab list from xmodule.tabs and manipulates the set as necessary
    """
    xmodule_tab_list = CourseTabList.iterate_displayable(course, user=user)

    # Now that we've loaded the tabs for this course, perform the Entrance Exam work.
    # If the user has to take an entrance exam, we'll need to hide away all but the
    # "Courseware" tab. The tab is then renamed as "Entrance Exam".
    course_tab_list = []
    must_complete_ee = not user_can_skip_entrance_exam(user, course)
    for tab in xmodule_tab_list:
        if must_complete_ee:
            # Hide all of the tabs except for 'Courseware'
            # Rename 'Courseware' tab to 'Entrance Exam'
            if tab.type != 'courseware':
                continue
            tab.name = _("Entrance Exam")
        # TODO: LEARNER-611 - once the course_info tab is removed, remove this code
        if UNIFIED_COURSE_TAB_FLAG.is_enabled(course.id) and tab.type == 'course_info':
            continue
        if tab.type == 'static_tab' and tab.course_staff_only and \
                not bool(user and has_access(user, 'staff', course, course.id)):
            continue
        # We had initially created a CourseTab.load() for dates that ended up
        # persisting the dates tab tomodulestore on Course Run creation, but
        # ignoring any static dates tab here we can fix forward without
        # allowing the bug to continue to surface
        if tab.type == 'dates':
            continue
        course_tab_list.append(tab)

    # Add in any dynamic tabs, i.e. those that are not persisted
    course_tab_list += _get_dynamic_tabs(course, user)
    return course_tab_list
コード例 #2
0
ファイル: tabs.py プロジェクト: Lektorium-LLC/edx-platform
def get_course_tab_list(request, course):
    """
    Retrieves the course tab list from xmodule.tabs and manipulates the set as necessary
    """
    user = request.user
    xmodule_tab_list = CourseTabList.iterate_displayable(course, user=user)

    # Now that we've loaded the tabs for this course, perform the Entrance Exam work.
    # If the user has to take an entrance exam, we'll need to hide away all but the
    # "Courseware" tab. The tab is then renamed as "Entrance Exam".
    course_tab_list = []
    must_complete_ee = not user_can_skip_entrance_exam(user, course)
    for tab in xmodule_tab_list:
        if must_complete_ee:
            # Hide all of the tabs except for 'Courseware'
            # Rename 'Courseware' tab to 'Entrance Exam'
            if tab.type != 'courseware':
                continue
            tab.name = _("Entrance Exam")
        # TODO: LEARNER-611 - once the course_info tab is removed, remove this code
        if UNIFIED_COURSE_TAB_FLAG.is_enabled(course.id) and tab.type == 'course_info':
                continue
        if tab.type == 'static_tab' and tab.course_staff_only and \
                not bool(user and has_access(user, 'staff', course, course.id)):
            continue
        course_tab_list.append(tab)

    # Add in any dynamic tabs, i.e. those that are not persisted
    course_tab_list += _get_dynamic_tabs(course, user)
    return course_tab_list
コード例 #3
0
 def is_enabled(cls, course, user=None):
     """
     Returns true if this tab is enabled.
     """
     # If this is the unified course tab then it is always enabled
     if UNIFIED_COURSE_TAB_FLAG.is_enabled(course.id):
         return True
     return super(CoursewareTab, cls).is_enabled(course, user)
コード例 #4
0
ファイル: tabs.py プロジェクト: Lektorium-LLC/edx-platform
 def is_enabled(cls, course, user=None):
     """
     Returns true if this tab is enabled.
     """
     # If this is the unified course tab then it is always enabled
     if UNIFIED_COURSE_TAB_FLAG.is_enabled(course.id):
         return True
     return super(CoursewareTab, cls).is_enabled(course, user)
コード例 #5
0
 def is_enabled(cls, course, user=None):
     """
     The "Home" tab is not shown for the new unified course experience.
     """
     return not UNIFIED_COURSE_TAB_FLAG.is_enabled(course.id)
コード例 #6
0
ファイル: tabs.py プロジェクト: edx-solutions/edx-platform
 def is_enabled(cls, course, user=None):
     """
     The "Home" tab is not shown for the new unified course experience.
     """
     return not UNIFIED_COURSE_TAB_FLAG.is_enabled(course.id)
コード例 #7
0
def render_content(context, **pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        resume_course_url = context.get('resume_course_url', UNDEFINED)
        course_home_message_fragment = context.get(
            'course_home_message_fragment', UNDEFINED)
        upgrade_url = context.get('upgrade_url', UNDEFINED)
        has_goal_permission = context.get('has_goal_permission', UNDEFINED)
        update_message_fragment = context.get('update_message_fragment',
                                              UNDEFINED)
        course_tools = context.get('course_tools', UNDEFINED)
        handouts_html = context.get('handouts_html', UNDEFINED)
        course_key = context.get('course_key', UNDEFINED)

        def content():
            return render_content(context)

        course = context.get('course', UNDEFINED)
        goal_options = context.get('goal_options', UNDEFINED)
        static = _mako_get_namespace(context, 'static')
        course_sock_fragment = context.get('course_sock_fragment', UNDEFINED)
        current_goal = context.get('current_goal', UNDEFINED)
        dates_fragment = context.get('dates_fragment', UNDEFINED)
        course_expiration_fragment = context.get('course_expiration_fragment',
                                                 UNDEFINED)
        has_visited_course = context.get('has_visited_course', UNDEFINED)
        upgrade_price = context.get('upgrade_price', UNDEFINED)
        outline_fragment = context.get('outline_fragment', UNDEFINED)
        __M_writer = context.writer()
        __M_writer(
            u'\n<div class="course-view page-content-container" id="course-container">\n\n'
        )
        if ENABLE_DASHBOARD_TAB.is_enabled(course_key):
            __M_writer(u'        ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        static.renderReact(
                            component="UpsellExperimentModal",
                            id="upsell-modal",
                            props={},
                        ))))
            __M_writer(u'\n')
        __M_writer(u'\n')
        if INCLUDE_PORTFOLIO_UPSELL_MODAL.is_enabled():
            __M_writer(u'        ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        static.renderReact(
                            component="PortfolioExperimentUpsellModal",
                            id="portfolio-experiment-upsell-modal",
                            props={}))))
            __M_writer(u'\n')
        __M_writer(
            u'\n    <header class="page-header has-secondary">\n        <div class="page-header-main">\n            <nav aria-label="'
        )
        __M_writer(
            filters.html_escape(filters.decode.utf8(_('Course Outline'))))
        __M_writer(
            u'" class="sr-is-focusable" tabindex="-1">\n                <h2 class="hd hd-3 page-title">'
        )
        __M_writer(
            filters.html_escape(
                filters.decode.utf8(course.display_name_with_default)))
        __M_writer(
            u'</h2>\n            </nav>\n        </div>\n        <div class="page-header-secondary">\n'
        )
        if settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH'):
            __M_writer(
                u'                <div class="page-header-search">\n                    <form class="search-form input-group" role="search" action="'
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        reverse('openedx.course_search.course_search_results',
                                args=[course_key]))))
            __M_writer(
                u'">\n                        <label class="field-label sr-only" for="search" id="search-hint">'
            )
            __M_writer(
                filters.html_escape(filters.decode.utf8(
                    _('Search the course'))))
            __M_writer(
                u'</label>\n                        <input\n                                class="field-input input-text search-input form-control"\n                                type="search"\n                                name="query"\n                                id="search"\n                                placeholder="'
            )
            __M_writer(
                filters.html_escape(filters.decode.utf8(
                    _('Search the course'))))
            __M_writer(
                u'"\n                        />\n                        <span class="input-group-btn">\n                            <button class="btn btn-outline-primary search-button" type="submit">'
            )
            __M_writer(filters.html_escape(filters.decode.utf8(_('Search'))))
            __M_writer(
                u'</button>\n                        </span>\n                    </form>\n                </div>\n'
            )
        __M_writer(u'            <div class="form-actions">\n')
        if resume_course_url:
            __M_writer(
                u'                    <a class="btn btn-primary action-resume-course" href="'
            )
            __M_writer(
                filters.html_escape(filters.decode.utf8(resume_course_url)))
            __M_writer(u'">\n')
            if has_visited_course:
                __M_writer(
                    u'                            <span data-action-type="resume">'
                )
                __M_writer(
                    filters.html_escape(filters.decode.utf8(
                        _("Resume Course"))))
                __M_writer(u'</span>\n')
            else:
                __M_writer(
                    u'                            <span data-action-type="start">'
                )
                __M_writer(
                    filters.html_escape(filters.decode.utf8(
                        _("Start Course"))))
                __M_writer(u'</span>\n')
            __M_writer(u'                    </a>\n')
        __M_writer(
            u'            </div>\n        </div>\n    </header>\n    <div class="page-content">\n        <div class="page-content-main">\n'
        )
        if course_expiration_fragment:
            __M_writer(u'                ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        HTML(course_expiration_fragment.content))))
            __M_writer(u'\n')
        if course_home_message_fragment:
            __M_writer(u'                ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        HTML(course_home_message_fragment.body_html()))))
            __M_writer(u'\n')
        __M_writer(u'\n')
        if update_message_fragment and UNIFIED_COURSE_TAB_FLAG.is_enabled(
                course.id):
            __M_writer(
                u'                <div class="section section-update-message">\n                    '
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        HTML(update_message_fragment.body_html()))))
            __M_writer(u'\n                </div>\n')
        __M_writer(u'\n')
        if outline_fragment:
            __M_writer(u'                ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(HTML(outline_fragment.body_html()))))
            __M_writer(u'\n')
        __M_writer(
            u'        </div>\n        <aside class="page-content-secondary course-sidebar">\n'
        )
        if has_goal_permission:
            __M_writer(u'                <div class="section section-goals ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8('' if current_goal else 'hidden')))
            __M_writer(
                u'">\n                    <div class="current-goal-container">\n                        <label class="title title-label hd-6" for="goal">\n                            <h3 class="hd-6">'
            )
            __M_writer(filters.html_escape(filters.decode.utf8(_("Goal: "))))
            __M_writer(
                u'</h3>\n                        </label>\n                        <h3 class="title hd-6">'
            )
            __M_writer(filters.html_escape(filters.decode.utf8(_("Goal: "))))
            __M_writer(
                u'</h3>\n                        <div class="goal">\n                            <span class="text">'
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(goal_options[current_goal.goal_key]
                                        if current_goal else "")))
            __M_writer(
                u'</span>\n                        </div>\n                        <select class="edit-goal-select" id="goal">\n'
            )
            for goal, goal_text in goal_options.items():
                __M_writer(u'                                <option value="')
                __M_writer(filters.html_escape(filters.decode.utf8(goal)))
                __M_writer(u'" ')
                __M_writer(
                    filters.html_escape(
                        filters.decode.utf8(
                            "selected" if current_goal
                            and current_goal.goal_key == goal else "")))
                __M_writer(u'>')
                __M_writer(filters.html_escape(filters.decode.utf8(goal_text)))
                __M_writer(u'</option>\n')
            __M_writer(
                u'                        </select>\n                        <span class="sr sr-update-response-msg" aria-live="polite"></span>\n                        <span class="response-icon" aria-hidden="true"></span>\n                        <span class="sr">'
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(_("Edit your course goal:"))))
            __M_writer(
                u'</span>\n                        <button class="edit-icon">\n                            <span class="sr">'
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(_("Edit your course goal:"))))
            __M_writer(
                u'</span>\n                            <span class="fa fa-pencil" aria-hidden="true"></span>\n                        </button>\n                    </div>\n                </div>\n'
            )
        if course_tools:
            __M_writer(
                u'                <div class="section section-tools">\n                    <h3 class="hd-6 section-title">'
            )
            __M_writer(
                filters.html_escape(filters.decode.utf8(_("Course Tools"))))
            __M_writer(
                u'</h3>\n                    <ul class="list-unstyled">\n')
            for course_tool in course_tools:
                __M_writer(
                    u'                            <li class="course-tool">\n                                <a class="course-tool-link" data-analytics-id="'
                )
                __M_writer(
                    filters.html_escape(
                        filters.decode.utf8(course_tool.analytics_id())))
                __M_writer(u'" href="')
                __M_writer(
                    filters.html_escape(
                        filters.decode.utf8(course_tool.url(course_key))))
                __M_writer(
                    u'">\n                                    <span class="icon '
                )
                __M_writer(
                    filters.html_escape(
                        filters.decode.utf8(course_tool.icon_classes())))
                __M_writer(
                    u'" aria-hidden="true"></span>\n                                    '
                )
                __M_writer(
                    filters.html_escape(
                        filters.decode.utf8(course_tool.title())))
                __M_writer(
                    u'\n                                </a>\n                            </li>\n'
                )
            __M_writer(u'                    </ul>\n                </div>\n')
        if upgrade_url and upgrade_price:
            __M_writer(
                u'                <div class="section section-upgrade course-home-sidebar-upgrade">\n                    <h3 class="hd hd-6">'
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(_("Pursue a verified certificate"))))
            __M_writer(
                u'</h3>\n                        <img src="https://courses.edx.org/static/images/edx-verified-mini-cert.png" alt="">\n                        <div class="upgrade-container">\n                            <p>\n                                <a class="btn-brand btn-upgrade"\n                                   href="'
            )
            __M_writer(filters.html_escape(filters.decode.utf8(upgrade_url)))
            __M_writer(
                u'"\n                                   data-creative="sidebarupsell"\n                                   data-position="sidebar-message">\n                                   '
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(
                        _("Upgrade ({price})").format(price=upgrade_price))))
            __M_writer(
                u'\n                                </a>\n                            </p>\n                    <p><button class="btn-link btn-small promo-learn-more">'
            )
            __M_writer(
                filters.html_escape(filters.decode.utf8(_('Learn More'))))
            __M_writer(
                u'</button></p>\n                        </div>\n                </div>\n'
            )
        if dates_fragment:
            __M_writer(
                u'                <div class="section section-dates">\n                    '
            )
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(HTML(dates_fragment.body_html()))))
            __M_writer(u'\n                </div>\n')
        if handouts_html:
            __M_writer(
                u'                <div class="section section-handouts">\n                    <h3 class="hd-6 section-title">'
            )
            __M_writer(
                filters.html_escape(filters.decode.utf8(_("Course Handouts"))))
            __M_writer(u'</h3>\n                    ')
            __M_writer(
                filters.html_escape(filters.decode.utf8(HTML(handouts_html))))
            __M_writer(u'\n                </div>\n')
        __M_writer(u'        </aside>\n    </div>\n')
        if course_sock_fragment:
            __M_writer(u'        ')
            __M_writer(
                filters.html_escape(
                    filters.decode.utf8(HTML(
                        course_sock_fragment.body_html()))))
            __M_writer(u'\n')
        __M_writer(u'</div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()