Example #1
0
def can_view_assessments(app_context):
    return not courses.has_only_new_style_assessments(
        courses.Course(None, app_context=app_context))
Example #2
0
    def _get_top_nav(self, in_action, in_tab):
        current_action = in_action or self.request.get(
            'action') or self.default_action
        nav_bars = []
        nav = safe_dom.NodeList()
        for action, title in self.get_nav_mappings():
            if not self.can_view(action):
                continue
            class_name = 'selected' if action == current_action else ''
            action_href = 'dashboard?action=%s' % action
            nav.append(safe_dom.Element(
                'a', href=action_href, className=class_name).add_text(
                    title))

        if roles.Roles.is_super_admin():
            nav.append(safe_dom.Element(
                'a', href='admin?action=admin',
                className=('selected' if current_action == 'admin' else '')
            ).add_text('Site Admin'))

        nav.append(safe_dom.Element(
            'a',
            href='https://code.google.com/p/course-builder/wiki/Dashboard',
            target='_blank'
        ).add_text('Help'))

        nav.append(safe_dom.Element(
            'a',
            href=(
                'https://groups.google.com/forum/?fromgroups#!categories/'
                'course-builder-forum/general-troubleshooting'),
            target='_blank'
        ).add_text('Support'))
        nav_bars.append(nav)

        tab_group = tabs.Registry.get_tab_group(current_action)
        if tab_group:
            if current_action == 'assets':
                exclude_tabs = []
                course = self.get_course()
                if courses.has_only_new_style_assessments(course):
                    exclude_tabs.append('Assessments')
                if courses.has_only_new_style_activities(course):
                    exclude_tabs.append('Activities')
                    tab_group = [
                        t for t in tab_group if t.title not in exclude_tabs]
            tab_name = (in_tab or self.request.get('tab') or
                        self.default_subtab_action[current_action]
                        or tab_group[0].name)
            sub_nav = safe_dom.NodeList()
            for tab in tab_group:
                href = tab.href or 'dashboard?action=%s&tab=%s' % (
                        current_action, tab.name)
                target = tab.target or '_self'
                sub_nav.append(
                    safe_dom.A(
                        href,
                        className=('selected' if tab.name == tab_name else ''),
                        target=target)
                    .add_text(tab.title))
            nav_bars.append(sub_nav)
        return nav_bars