def get_edit_lesson(self):
     """Shows the lesson/activity editor."""
     key = self.request.get('key')
     course = courses.Course(self)
     lesson = course.find_lesson_by_id(None, key)
     annotations_dict = (None if lesson.has_activity else
                         UnitLessonEditor.HIDE_ACTIVITY_ANNOTATIONS)
     schema = LessonRESTHandler.get_schema(course, key)
     if courses.has_only_new_style_activities(course):
         schema.get_property('objectives').extra_schema_dict_values[
             'excludedCustomTags'] = set(['gcb-activity'])
     self._render_edit_form_for(LessonRESTHandler,
                                'Lessons and Activities',
                                schema=schema,
                                annotations_dict=annotations_dict,
                                delete_xsrf_token='delete-lesson')
 def get_edit_lesson(self):
     """Shows the lesson/activity editor."""
     key = self.request.get('key')
     course = courses.Course(self)
     lesson = course.find_lesson_by_id(None, key)
     annotations_dict = (
         None if lesson.has_activity
         else UnitLessonEditor.HIDE_ACTIVITY_ANNOTATIONS)
     schema = LessonRESTHandler.get_schema(course, key)
     if courses.has_only_new_style_activities(course):
         schema.get_property('objectives').extra_schema_dict_values[
           'excludedCustomTags'] = set(['gcb-activity'])
     self._render_edit_form_for(
         LessonRESTHandler, 'Lessons and Activities',
         schema=schema,
         annotations_dict=annotations_dict,
         delete_xsrf_token='delete-lesson')
 def get_edit_lesson(cls, handler):
     """Shows the lesson/activity editor."""
     key = handler.request.get("key")
     course = courses.Course(handler)
     lesson = course.find_lesson_by_id(None, key)
     annotations_dict = None if lesson.has_activity else cls.HIDE_ACTIVITY_ANNOTATIONS
     schema = LessonRESTHandler.get_schema(course, key)
     if courses.has_only_new_style_activities(course):
         schema.get_property("objectives").extra_schema_dict_values["excludedCustomTags"] = set(["gcb-activity"])
     return cls._render_edit_form_for(
         handler,
         LessonRESTHandler,
         "Lessons and Activities",
         schema,
         annotations_dict=annotations_dict,
         delete_xsrf_token="delete-lesson",
         extra_js_files=["lesson_editor.js"],
     )
    def get_in_place_lesson_editor(cls, handler):
        """Shows the lesson editor iframed inside a lesson page."""
        if not handler.app_context.is_editable_fs():
            return

        key = handler.request.get('key')

        course = courses.Course(handler)
        lesson = course.find_lesson_by_id(None, key)
        annotations_dict = (None if lesson.has_activity else
                            cls.HIDE_ACTIVITY_ANNOTATIONS)
        schema = LessonRESTHandler.get_schema(course, key)
        annotations_dict = schema.get_schema_dict() + annotations_dict

        if courses.has_only_new_style_activities(course):
            schema.get_property('objectives').extra_schema_dict_values[
                'excludedCustomTags'] = set(['gcb-activity'])

        extra_js_files = [
            'lesson_editor.js', 'in_place_lesson_editor_iframe.js'
        ] + LessonRESTHandler.EXTRA_JS_FILES

        form_html = oeditor.ObjectEditor.get_html_for(
            handler,
            schema.get_json_schema(),
            annotations_dict,
            key,
            handler.canonicalize_url(LessonRESTHandler.URI),
            None,
            additional_dirs=LessonRESTHandler.ADDITIONAL_DIRS,
            display_types=schema.get_display_types(),
            extra_css_files=LessonRESTHandler.EXTRA_CSS_FILES,
            extra_js_files=extra_js_files)
        template = handler.get_template('in_place_lesson_editor.html', [])
        template_values = {
            'form_html': form_html,
            'extra_css_href_list': handler.EXTRA_CSS_HREF_LIST,
            'extra_js_href_list': handler.EXTRA_JS_HREF_LIST
        }
        handler.response.write(template.render(template_values))
    def get_in_place_lesson_editor(self):
        """Shows the lesson editor iframed inside a lesson page."""
        if not self.app_context.is_editable_fs():
            return

        key = self.request.get('key')

        course = courses.Course(self)
        lesson = course.find_lesson_by_id(None, key)
        annotations_dict = (
            None if lesson.has_activity
            else UnitLessonEditor.HIDE_ACTIVITY_ANNOTATIONS)
        schema = LessonRESTHandler.get_schema(course, key)
        annotations_dict = schema.get_schema_dict() + annotations_dict

        if courses.has_only_new_style_activities(course):
            schema.get_property('objectives').extra_schema_dict_values[
              'excludedCustomTags'] = set(['gcb-activity'])

        extra_js_files = [
            'lesson_editor.js', 'in_place_lesson_editor_iframe.js'
        ] + LessonRESTHandler.EXTRA_JS_FILES

        form_html = oeditor.ObjectEditor.get_html_for(
            self,
            schema.get_json_schema(),
            annotations_dict,
            key, self.canonicalize_url(LessonRESTHandler.URI), None,
            required_modules=LessonRESTHandler.REQUIRED_MODULES,
            additional_dirs=LessonRESTHandler.ADDITIONAL_DIRS,
            extra_css_files=LessonRESTHandler.EXTRA_CSS_FILES,
            extra_js_files=extra_js_files)
        template = self.get_template('in_place_lesson_editor.html', [])
        template_values = {
            'form_html': form_html,
            'extra_css_href_list': self.EXTRA_CSS_HREF_LIST,
            'extra_js_href_list': self.EXTRA_JS_HREF_LIST
        }
        self.response.write(template.render(template_values))
    def get_in_place_lesson_editor(cls, handler):
        """Shows the lesson editor iframed inside a lesson page."""
        if not handler.app_context.is_editable_fs():
            return

        key = handler.request.get("key")

        course = courses.Course(handler)
        lesson = course.find_lesson_by_id(None, key)
        annotations_dict = None if lesson.has_activity else cls.HIDE_ACTIVITY_ANNOTATIONS
        schema = LessonRESTHandler.get_schema(course, key)
        annotations_dict = schema.get_schema_dict() + annotations_dict

        if courses.has_only_new_style_activities(course):
            schema.get_property("objectives").extra_schema_dict_values["excludedCustomTags"] = set(["gcb-activity"])

        extra_js_files = ["lesson_editor.js", "in_place_lesson_editor_iframe.js"] + LessonRESTHandler.EXTRA_JS_FILES

        form_html = oeditor.ObjectEditor.get_html_for(
            handler,
            schema.get_json_schema(),
            annotations_dict,
            key,
            handler.canonicalize_url(LessonRESTHandler.URI),
            None,
            additional_dirs=LessonRESTHandler.ADDITIONAL_DIRS,
            display_types=schema.get_display_types(),
            extra_css_files=LessonRESTHandler.EXTRA_CSS_FILES,
            extra_js_files=extra_js_files,
        )
        template = handler.get_template("in_place_lesson_editor.html", [])
        template_values = {
            "form_html": form_html,
            "extra_css_href_list": handler.EXTRA_CSS_HREF_LIST,
            "extra_js_href_list": handler.EXTRA_JS_HREF_LIST,
        }
        handler.response.write(template.render(template_values))
Esempio n. 7
0
def can_view_activities(app_context):
    return not courses.has_only_new_style_activities(
        courses.Course(None, app_context=app_context))
Esempio n. 8
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
Esempio n. 9
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
Esempio n. 10
0
def can_view_activities(app_context):
    return not courses.has_only_new_style_activities(
        courses.Course(None, app_context=app_context))