Пример #1
0
 def author_preview_view(self, context):
     fragment = super(XBlockWithComponentsMixin,
                      self).author_preview_view(context)
     add_resource(self, 'css', 'public/css/group_project.css', fragment)
     add_resource(self, 'css', 'public/css/group_project_preview.css',
                  fragment)
     return fragment
Пример #2
0
    def student_view(self, context):
        fragment = Fragment()
        # Could be a TA not in the group.
        if self.stage.is_group_member:
            user_details = [
                self.stage.project_api.get_member_data(self.stage.user_id)
            ]
        else:
            user_details = []
        render_context = {
            'team_members': user_details + self.stage.team_members,
            'course_id': self.stage.course_id,
            'group_id': self.stage.workgroup.id
        }
        render_context.update(context)

        fragment.add_content(
            loader.render_template(
                "templates/html/components/project_team.html", render_context))
        add_resource(self, 'css', "public/css/components/project_team.css",
                     fragment)
        add_resource(self, 'javascript',
                     "public/js/components/project_team.js", fragment)
        fragment.initialize_js("ProjectTeamXBlock")
        return fragment
Пример #3
0
    def get_stage_content_fragment(self, context, view='student_view'):
        fragment = Fragment()
        children_fragments = self.render_children_fragments(context, view=view)
        render_context = {
            'stage': self,
            'children_contents': [frag.content for frag in children_fragments]
        }

        for frag in children_fragments:
            fragment.add_fragment_resources(frag)

        render_context.update(context)
        fragment.add_content(
            loader.render_django_template(
                self.STAGE_CONTENT_TEMPLATE,
                render_context,
                i18n_service=self.i18n_service,
            ))

        if self.js_file:
            add_resource(self, 'javascript', self.js_file, fragment)

        if self.js_init:
            fragment.initialize_js(self.js_init)

        return fragment
Пример #4
0
 def selector_view(self, context):
     """
     Selector view - this view is used by GroupProjectNavigatorXBlock to render selector buttons
     """
     fragment = super(PrivateDiscussionViewXBlock, self).selector_view(context)
     add_resource(self, 'javascript', self.JS_BASE + self.js_file, fragment)
     fragment.initialize_js(self.initialize_js_function)
     return fragment
 def selector_view(self, context):
     """
     Selector view - this view is used by GroupProjectNavigatorXBlock to render selector buttons
     """
     fragment = super(PrivateDiscussionViewXBlock, self).selector_view(context)
     add_resource(self, 'javascript', self.JS_BASE + self.js_file, fragment)
     fragment.initialize_js(self.initialize_js_function)
     return fragment
Пример #6
0
 def author_edit_view(self, context):
     """
     Add some HTML to the author view that allows authors to add child blocks.
     """
     fragment = super(XBlockWithComponentsMixin, self).author_edit_view(context)
     add_resource(self, 'css', 'public/css/group_project.css', fragment)
     add_resource(self, 'css', 'public/css/group_project_edit.css', fragment)
     return fragment
    def studio_view(self, context):
        fragment = super(GroupProjectReviewQuestionXBlock, self).studio_view(context)

        # TODO: StudioEditableXBlockMixin should really support Codemirror XML editor
        add_resource(self, 'css', "public/css/components/question_edit.css", fragment)
        add_resource(self, 'javascript', "public/js/components/question_edit.js", fragment)
        fragment.initialize_js("GroupProjectQuestionEdit")
        return fragment
Пример #8
0
    def student_view(self, context):
        ctx = self._sanitize_context(context)

        fragment = Fragment()
        render_context = {
            'project': self,
            'course_id': self.course_id,
            'group_id': self.workgroup.id
        }

        render_context.update(context)

        def render_child_fragment(child, content_key, fallback_message, extra_context=None):
            """
            Renders child, appends child fragment resources to parent fragment and
            updates parent's rendering context
            """
            internal_context = dict(ctx)
            if extra_context:
                internal_context.update(extra_context)

            child_fragment = self._render_child_fragment_with_fallback(
                child, internal_context, fallback_message, 'student_view'
            )
            fragment.add_fragment_resources(child_fragment)
            render_context[content_key] = child_fragment.content

        target_block_id = self.get_block_id_from_string(ctx.get(Constants.ACTIVATE_BLOCK_ID_PARAMETER_NAME, None))
        target_stage = self.get_stage_to_display(target_block_id)

        child_context = {}
        if target_stage:
            child_context[Constants.CURRENT_STAGE_ID_PARAMETER_NAME] = target_stage.id

        # activity should be rendered first, as some stages might report completion in student-view - this way stage
        # PN sees updated state.
        target_activity = target_stage.activity if target_stage else None
        render_child_fragment(target_activity, 'activity_content', self._(messages.NO_ACTIVITIES), child_context)

        # TODO: project nav is slow, mostly due to navigation view. It might make sense to rework it into
        # asynchronously loading navigation and stage states.
        project_navigator = self.get_child_of_category(GroupProjectNavigatorXBlock.CATEGORY)
        render_child_fragment(
            project_navigator, 'project_navigator_content', self._(messages.NO_PROJECT_NAVIGATOR), child_context
        )

        discussion = self.get_child_of_category(DiscussionXBlockShim.CATEGORY)
        render_child_fragment(discussion, 'discussion_content', self._(messages.NO_DISCUSSION), child_context)

        fragment.add_content(self.render_template('student_view', render_context))

        add_resource(self, 'css', 'public/css/group_project.css', fragment)
        add_resource(self, 'css', 'public/css/group_project_common.css', fragment)
        add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True)
        add_resource(self, 'javascript', 'public/js/group_project.js', fragment)
        add_resource(self, 'javascript', 'public/js/group_project_common.js', fragment)
        fragment.initialize_js("GroupProjectBlock")
        return fragment
    def student_view(self, context):
        ctx = self._sanitize_context(context)

        fragment = Fragment()
        render_context = {
            'project': self,
            'course_id': self.course_id,
            'group_id': self.workgroup.id
        }

        render_context.update(context)

        def render_child_fragment(child, content_key, fallback_message, extra_context=None):
            """
            Renders child, appends child fragment resources to parent fragment and
            updates parent's rendering context
            """
            internal_context = dict(ctx)
            if extra_context:
                internal_context.update(extra_context)

            child_fragment = self._render_child_fragment_with_fallback(
                child, internal_context, fallback_message, 'student_view'
            )
            fragment.add_frag_resources(child_fragment)
            render_context[content_key] = child_fragment.content

        target_block_id = self.get_block_id_from_string(ctx.get(Constants.ACTIVATE_BLOCK_ID_PARAMETER_NAME, None))
        target_stage = self.get_stage_to_display(target_block_id)

        child_context = {}
        if target_stage:
            child_context[Constants.CURRENT_STAGE_ID_PARAMETER_NAME] = target_stage.id

        # activity should be rendered first, as some stages might report completion in student-view - this way stage
        # PN sees updated state.
        target_activity = target_stage.activity if target_stage else None
        render_child_fragment(target_activity, 'activity_content', messages.NO_ACTIVITIES, child_context)

        # TODO: project nav is slow, mostly due to navigation view. It might make sense to rework it into
        # asynchronously loading navigation and stage states.
        project_navigator = self.get_child_of_category(GroupProjectNavigatorXBlock.CATEGORY)
        render_child_fragment(
            project_navigator, 'project_navigator_content', messages.NO_PROJECT_NAVIGATOR, child_context
        )

        discussion = self.get_child_of_category(DiscussionXBlockShim.CATEGORY)
        render_child_fragment(discussion, 'discussion_content', messages.NO_DISCUSSION, child_context)

        fragment.add_content(self.render_template('student_view', render_context))

        add_resource(self, 'css', 'public/css/group_project.css', fragment)
        add_resource(self, 'css', 'public/css/group_project_common.css', fragment)
        add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True)
        add_resource(self, 'javascript', 'public/js/group_project.js', fragment)
        add_resource(self, 'javascript', 'public/js/group_project_common.js', fragment)
        fragment.initialize_js("GroupProjectBlock")
        return fragment
 def submissions_view(self, context):
     fragment = Fragment()
     uploading_allowed = (self.stage.available_now and self.stage.is_group_member) or self.stage.is_admin_grader
     render_context = {'submission': self, 'upload': self.upload, 'disabled': not uploading_allowed}
     render_context.update(context)
     fragment.add_content(loader.render_template(self.PROJECT_NAVIGATOR_VIEW_TEMPLATE, render_context))
     add_resource(self, 'javascript', 'public/js/components/submission.js', fragment)
     fragment.initialize_js("GroupProjectSubmissionBlock")
     return fragment
 def student_view(self, context):
     fragment = Fragment()
     render_context = {'selector': self, 'review_subjects': self.get_review_subject_repr()}
     render_context.update(context)
     add_resource(self, 'css', "public/css/components/review_subject_selector.css", fragment)
     add_resource(self, 'javascript', "public/js/components/review_subject_selector.js", fragment)
     fragment.add_content(loader.render_template(self.STUDENT_TEMPLATE, render_context))
     fragment.initialize_js('ReviewSubjectSelectorXBlock')
     return fragment
Пример #12
0
 def author_edit_view(self, context):
     """
     Add some HTML to the author view that allows authors to add child blocks.
     """
     fragment = super(XBlockWithComponentsMixin,
                      self).author_edit_view(context)
     add_resource(self, 'css', 'public/css/group_project.css', fragment)
     add_resource(self, 'css', 'public/css/group_project_edit.css',
                  fragment)
     return fragment
Пример #13
0
    def studio_view(self, context):
        fragment = super(GroupProjectReviewQuestionXBlock,
                         self).studio_view(context)

        # TODO: StudioEditableXBlockMixin should really support Codemirror XML editor
        add_resource(self, 'css', "public/css/components/question_edit.css",
                     fragment)
        add_resource(self, 'javascript',
                     "public/js/components/question_edit.js", fragment)
        fragment.initialize_js("GroupProjectQuestionEdit")
        return fragment
Пример #14
0
    def student_view(self, context):
        """
        Student view
        """
        fragment = Fragment()
        children_items = []
        for view in self._sorted_child_views():
            item = {
                'id': str(view.scope_ids.usage_id).replace("/", ";_"),
                'type': view.type,
            }

            if not view.skip_content:
                child_fragment = view.render('student_view', context)
                item['content'] = child_fragment.content
                fragment.add_fragment_resources(child_fragment)
            else:
                item['content'] = ''

            if not view.skip_selector:
                child_selector_fragment = view.render('selector_view', context)
                item['selector'] = child_selector_fragment.content
                fragment.add_fragment_resources(child_selector_fragment)
            else:
                item['selector'] = ''

            children_items.append(item)

        activate_block_id = self.get_block_id_from_string(
            context.get('activate_block_id', None))

        js_parameters = {
            'selected_view': self._get_activated_view_type(activate_block_id)
        }

        fragment.add_content(
            loader.render_django_template(
                'templates/html/project_navigator/project_navigator.html',
                {'children': children_items},
                i18n_service=self.i18n_service,
            ))
        add_resource(self, 'css',
                     'public/css/project_navigator/project_navigator.css',
                     fragment)
        add_resource(self, 'javascript',
                     'public/js/project_navigator/project_navigator.js',
                     fragment)
        fragment.add_javascript(self.get_translation_content())
        fragment.initialize_js("GroupProjectNavigatorBlock", js_parameters)

        return fragment
    def author_preview_view(self, context):
        fragment = Fragment()
        children_contents = []
        for child in self._children:
            child_fragment = child.render('preview_view', context)
            fragment.add_frag_resources(child_fragment)
            children_contents.append(child_fragment.content)

        fragment.add_content(loader.render_template(
            "templates/html/project_navigator/project_navigator_author_view.html",
            {'navigator': self, 'children_contents': children_contents}
        ))
        add_resource(self, 'css', 'public/css/project_navigator/project_navigator.css', fragment)
        return fragment
    def dashboard_detail_view(self, context):
        ctx = self._sanitize_context(context)
        self._add_students_and_workgroups_to_context(ctx)

        fragment = Fragment()
        render_context = {
            'project': self,
            'course_id': self.course_id,
            'group_id': self.workgroup.id
        }

        render_context.update(ctx)

        target_block_id = self.get_block_id_from_string(ctx.get(Constants.ACTIVATE_BLOCK_ID_PARAMETER_NAME, None))
        target_activity = self._get_target_block(target_block_id)
        if target_activity is None and self.activities:
            target_activity = self.activities[0]

        activity_fragment = self._render_child_fragment_with_fallback(
            target_activity, ctx, messages.NO_ACTIVITIES, view='dashboard_detail_view'
        )
        render_context['activity_content'] = activity_fragment.content
        fragment.add_frag_resources(activity_fragment)

        fragment.add_content(self.render_template('dashboard_detail_view', render_context))
        add_resource(self, 'css', 'public/css/group_project_common.css', fragment)
        add_resource(self, 'css', 'public/css/group_project_dashboard.css', fragment)
        add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True)
        add_resource(self, 'javascript', 'public/js/group_project_dashboard_detail.js', fragment)

        fragment.initialize_js('GroupProjectBlockDashboardDetailsView')

        return fragment
Пример #17
0
    def author_preview_view(self, context):
        fragment = Fragment()
        children_contents = []
        for child in self._children:
            child_fragment = child.render('preview_view', context)
            fragment.add_frag_resources(child_fragment)
            children_contents.append(child_fragment.content)

        fragment.add_content(loader.render_template(
            "templates/html/project_navigator/project_navigator_author_view.html",
            {'navigator': self, 'children_contents': children_contents}
        ))
        add_resource(self, 'css', 'public/css/project_navigator/project_navigator.css', fragment)
        return fragment
Пример #18
0
    def dashboard_detail_view(self, context):
        ctx = self._sanitize_context(context)
        self._add_students_and_workgroups_to_context(ctx)

        fragment = Fragment()
        render_context = {
            'project': self,
            'course_id': self.course_id,
            'group_id': self.workgroup.id
        }

        render_context.update(ctx)

        target_block_id = self.get_block_id_from_string(ctx.get(Constants.ACTIVATE_BLOCK_ID_PARAMETER_NAME, None))
        target_activity = self._get_target_block(target_block_id)
        if target_activity is None and self.activities:
            target_activity = self.activities[0]

        activity_fragment = self._render_child_fragment_with_fallback(
            target_activity, ctx, self._(messages.NO_ACTIVITIES), view='dashboard_detail_view'
        )
        render_context['activity_content'] = activity_fragment.content
        fragment.add_fragment_resources(activity_fragment)

        fragment.add_content(self.render_template('dashboard_detail_view', render_context))
        add_resource(self, 'css', 'public/css/group_project_common.css', fragment)
        add_resource(self, 'css', 'public/css/group_project_dashboard.css', fragment)
        add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True)
        add_resource(self, 'javascript', 'public/js/group_project_dashboard_detail.js', fragment)

        fragment.initialize_js('GroupProjectBlockDashboardDetailsView')

        return fragment
Пример #19
0
 def student_view(self, context):
     fragment = Fragment()
     render_context = {
         'selector': self,
         'review_subjects': self.get_review_subject_repr()
     }
     render_context.update(context)
     add_resource(self, 'css',
                  "public/css/components/review_subject_selector.css",
                  fragment)
     add_resource(self, 'javascript',
                  "public/js/components/review_subject_selector.js",
                  fragment)
     fragment.add_content(
         loader.render_template(self.STUDENT_TEMPLATE, render_context))
     fragment.initialize_js('ReviewSubjectSelectorXBlock')
     return fragment
    def student_view(self, context):
        """
        Student view
        """
        fragment = Fragment()
        children_items = []
        for view in self._sorted_child_views():
            item = {
                'id': str(view.scope_ids.usage_id).replace("/", ";_"),
                'type': view.type,
            }

            if not view.skip_content:
                child_fragment = view.render('student_view', context)
                item['content'] = child_fragment.content
                fragment.add_frag_resources(child_fragment)
            else:
                item['content'] = ''

            if not view.skip_selector:
                child_selector_fragment = view.render('selector_view', context)
                item['selector'] = child_selector_fragment.content
                fragment.add_frag_resources(child_selector_fragment)
            else:
                item['selector'] = ''

            children_items.append(item)

        activate_block_id = self.get_block_id_from_string(context.get('activate_block_id', None))

        js_parameters = {
            'selected_view': self._get_activated_view_type(activate_block_id)
        }

        fragment.add_content(
            loader.render_template(
                'templates/html/project_navigator/project_navigator.html',
                {'children': children_items}
            )
        )
        add_resource(self, 'css', 'public/css/project_navigator/project_navigator.css', fragment)
        add_resource(self, 'javascript', 'public/js/project_navigator/project_navigator.js', fragment)
        fragment.initialize_js("GroupProjectNavigatorBlock", js_parameters)

        return fragment
Пример #21
0
 def submissions_view(self, context):
     fragment = Fragment()
     uploading_allowed = (
         self.stage.available_now
         and self.stage.is_group_member) or self.stage.is_admin_grader
     render_context = {
         'submission': self,
         'upload': self.upload,
         'disabled': not uploading_allowed
     }
     render_context.update(context)
     fragment.add_content(
         loader.render_template(self.PROJECT_NAVIGATOR_VIEW_TEMPLATE,
                                render_context))
     add_resource(self, 'javascript', 'public/js/components/submission.js',
                  fragment)
     fragment.initialize_js("GroupProjectSubmissionBlock")
     return fragment
    def student_view(self, context):
        fragment = Fragment()
        # Could be a TA not in the group.
        if self.stage.is_group_member:
            user_details = [self.stage.project_api.get_member_data(self.stage.user_id)]
        else:
            user_details = []
        render_context = {
            'team_members': user_details + self.stage.team_members,
            'course_id': self.stage.course_id,
            'group_id': self.stage.workgroup.id
        }
        render_context.update(context)

        fragment.add_content(loader.render_template("templates/html/components/project_team.html", render_context))
        add_resource(self, 'css', "public/css/components/project_team.css", fragment)
        add_resource(self, 'javascript', "public/js/components/project_team.js", fragment)
        fragment.initialize_js("ProjectTeamXBlock")
        return fragment
Пример #23
0
    def get_stage_content_fragment(self, context, view='student_view'):
        fragment = Fragment()
        children_fragments = self.render_children_fragments(context, view=view)
        render_context = {
            'stage': self,
            'children_contents': [frag.content for frag in children_fragments]
        }

        for frag in children_fragments:
            fragment.add_frag_resources(frag)

        render_context.update(context)
        fragment.add_content(loader.render_template(self.STAGE_CONTENT_TEMPLATE, render_context))

        if self.js_file:
            add_resource(self, 'javascript', self.js_file, fragment)

        if self.js_init:
            fragment.initialize_js(self.js_init)

        return fragment
Пример #24
0
    def dashboard_view(self, context):
        fragment = Fragment()

        children_context = self._sanitize_context(context)
        self._add_students_and_workgroups_to_context(children_context)

        activity_fragments = self._render_children('dashboard_view',
                                                   children_context,
                                                   self.activities)
        activity_contents = [frag.content for frag in activity_fragments]
        fragment.add_frags_resources(activity_fragments)

        render_context = {
            'project': self,
            'activity_contents': activity_contents
        }
        fragment.add_content(
            self.render_template('dashboard_view', render_context))
        add_resource(self, 'css', 'public/css/group_project_common.css',
                     fragment)
        add_resource(self, 'css', 'public/css/group_project_dashboard.css',
                     fragment)
        add_resource(self,
                     'css',
                     'public/css/vendor/font-awesome/font-awesome.css',
                     fragment,
                     via_url=True)

        return fragment
Пример #25
0
    def render_student_view(self, context, add_resources_from=None):
        """
        Common code to render student view
        """
        fragment = Fragment()
        fragment.add_content(
            loader.render_django_template(
                self.TEMPLATE_BASE + self.template,
                context,
                i18n_service=self.i18n_service,
            ))

        if self.css_file:
            add_resource(self, 'css', self.CSS_BASE + self.css_file, fragment)

        if self.js_file:
            add_resource(self, 'javascript', self.JS_BASE + self.js_file,
                         fragment)

        if self.initialize_js_function:
            fragment.initialize_js(self.initialize_js_function)

        for js_file in self.additional_js_files:
            add_resource(self, 'javascript', js_file, fragment, via_url=True)

        if add_resources_from:
            for frag in add_resources_from:
                fragment.add_fragment_resources(frag)
        return fragment
    def dashboard_view(self, context):
        fragment = Fragment()

        children_context = self._sanitize_context(context)
        self._add_students_and_workgroups_to_context(children_context)

        activity_fragments = self._render_children('dashboard_view', children_context, self.activities)
        activity_contents = [frag.content for frag in activity_fragments]
        fragment.add_frags_resources(activity_fragments)

        render_context = {'project': self, 'activity_contents': activity_contents}
        fragment.add_content(self.render_template('dashboard_view', render_context))
        add_resource(self, 'css', 'public/css/group_project_common.css', fragment)
        add_resource(self, 'css', 'public/css/group_project_dashboard.css', fragment)
        add_resource(self, 'css', 'public/css/vendor/font-awesome/font-awesome.css', fragment, via_url=True)

        return fragment
    def render_student_view(self, context, add_resources_from=None):
        """
        Common code to render student view
        """
        fragment = Fragment()
        fragment.add_content(loader.render_template(self.TEMPLATE_BASE + self.template, context))

        if self.css_file:
            add_resource(self, 'css', self.CSS_BASE + self.css_file, fragment)

        if self.js_file:
            add_resource(self, 'javascript', self.JS_BASE + self.js_file, fragment)

        if self.initialize_js_function:
            fragment.initialize_js(self.initialize_js_function)

        for js_file in self.additional_js_files:
            add_resource(self, 'javascript', js_file, fragment, via_url=True)

        if add_resources_from:
            for frag in add_resources_from:
                fragment.add_frag_resources(frag)

        return fragment
Пример #28
0
 def author_view(self, context):
     fragment = self.student_view(context)
     add_resource(self, 'css', "public/css/components/question_edit.css",
                  fragment)
     return fragment
Пример #29
0
 def author_preview_view(self, context):
     fragment = super(XBlockWithComponentsMixin, self).author_preview_view(context)
     add_resource(self, 'css', 'public/css/group_project.css', fragment)
     add_resource(self, 'css', 'public/css/group_project_preview.css', fragment)
     return fragment
 def author_view(self, context):
     fragment = self.student_view(context)
     add_resource(self, 'css', "public/css/components/question_edit.css", fragment)
     return fragment