def get_html(self):
        if self.contents is None:
            self.contents = [{
                'id': child.id,
                'content': child.get_html(),
                'direct_term': self.direct_term,
                'progress_detail': Progress.to_js_detail_str(self.get_progress())
            } for child in self.get_display_items()]

        return self.system.render_template('vert_module.html', {
            'items': self.contents
        })
Beispiel #2
0
    def student_view(self, context):
        # If we're rendering this sequence, but no position is set yet,
        # default the position to the first element
        if self.position is None:
            self.position = 1

        ## Returns a set of all types of all sub-children
        contents = []

        fragment = Fragment()

        for child in self.get_display_items():
            progress = child.get_progress()
            rendered_child = child.render('student_view', context)
            fragment.add_frag_resources(rendered_child)

            childinfo = {
                'content':
                rendered_child.content,
                'title':
                "\n".join(grand_child.display_name
                          for grand_child in child.get_children()
                          if grand_child.display_name is not None),
                'progress_status':
                Progress.to_js_status_str(progress),
                'progress_detail':
                Progress.to_js_detail_str(progress),
                'type':
                child.get_icon_class(),
                'id':
                child.id,
            }
            if childinfo['title'] == '':
                childinfo['title'] = child.display_name_with_default
            contents.append(childinfo)

        params = {
            'items': contents,
            'element_id': self.location.html_id(),
            'item_id': self.id,
            'position': self.position,
            'tag': self.location.category,
            'ajax_url': self.system.ajax_url,
        }

        fragment.add_content(
            self.system.render_template('seq_module.html', params))

        return fragment
Beispiel #3
0
    def student_view(self, context):
        # If we're rendering this sequence, but no position is set yet,
        # default the position to the first element
        if self.position is None:
            self.position = 1

        ## Returns a set of all types of all sub-children
        contents = []

        fragment = Fragment()

        for child in self.get_display_items():
            progress = child.get_progress()
            rendered_child = child.render("student_view", context)
            fragment.add_frag_resources(rendered_child)

            childinfo = {
                "content": rendered_child.content,
                "title": "\n".join(
                    grand_child.display_name
                    for grand_child in child.get_children()
                    if grand_child.display_name is not None
                ),
                "progress_status": Progress.to_js_status_str(progress),
                "progress_detail": Progress.to_js_detail_str(progress),
                "type": child.get_icon_class(),
                "id": child.id,
            }
            if childinfo["title"] == "":
                childinfo["title"] = child.display_name_with_default
            contents.append(childinfo)

        params = {
            "items": contents,
            "element_id": self.location.html_id(),
            "item_id": self.id,
            "position": self.position,
            "tag": self.location.category,
            "ajax_url": self.system.ajax_url,
        }

        fragment.add_content(self.system.render_template("seq_module.html", params))

        return fragment
Beispiel #4
0
    def student_view(self, context):
        # If we're rendering this sequence, but no position is set yet,
        # default the position to the first element
        if self.position is None:
            self.position = 1

        ## Returns a set of all types of all sub-children
        contents = []

        fragment = Fragment()

        for child in self.get_display_items():
            progress = child.get_progress()
            rendered_child = child.render('student_view', context)
            fragment.add_frag_resources(rendered_child)

            childinfo = {
                'content': rendered_child.content,
                'title': "\n".join(
                    grand_child.display_name
                    for grand_child in child.get_children()
                    if grand_child.display_name is not None
                ),
                'progress_status': Progress.to_js_status_str(progress),
                'progress_detail': Progress.to_js_detail_str(progress),
                'type': child.get_icon_class(),
                'id': child.id,
            }
            if childinfo['title'] == '':
                childinfo['title'] = child.display_name_with_default
            contents.append(childinfo)

        params = {'items': contents,
                  'element_id': self.location.html_id(),
                  'item_id': self.id,
                  'position': self.position,
                  'tag': self.location.category,
                  'ajax_url': self.system.ajax_url,
                  }

        fragment.add_content(self.system.render_template('seq_module.html', params))

        return fragment
Beispiel #5
0
    def render(self):
        # If we're rendering this sequence, but no position is set yet,
        # default the position to the first element
        if self.position is None:
            self.position = 1

        if self.rendered:
            return
        ## Returns a set of all types of all sub-children
        contents = []
        for child in self.get_display_items():
            progress = child.get_progress()
            childinfo = {
                'content':
                self.runtime.render_child(child, None, 'student_view').content,
                'title':
                "\n".join(grand_child.display_name
                          for grand_child in child.get_children()
                          if grand_child.display_name is not None),
                'progress_status':
                Progress.to_js_status_str(progress),
                'progress_detail':
                Progress.to_js_detail_str(progress),
                'type':
                child.get_icon_class(),
                'id':
                child.id,
            }
            if childinfo['title'] == '':
                childinfo['title'] = child.display_name_with_default
            contents.append(childinfo)

        params = {
            'items': contents,
            'element_id': self.location.html_id(),
            'item_id': self.id,
            'position': self.position,
            'tag': self.location.category
        }

        self.content = self.system.render_template('seq_module.html', params)
        self.rendered = True
    def student_view(self, context):
        fragment = Fragment()
        contents = []
        all_contents = []

        for child in self.get_display_items():
            rendered_child = child.render('student_view', context)
            fragment.add_frag_resources(rendered_child)

            show_now = 'true'

            try:
                problem_now = child.problem_now
                if not problem_now:
                    show_now = 'false'
            except AttributeError:
                pass

            all_contents.append({
                'id': child.id,
                'content': rendered_child.content,
                'father': self.id,                
                'direct_term': self.direct_term,
                'progress_detail': Progress.to_js_detail_str(self.get_progress()),
                'type': child.get_icon_class(),
                'show_now': show_now,
                'problem_time': child.problem_time if child.get_icon_class() == 'problem' else
                [{"id": child2.id if child2.get_icon_class() == 'problem' else "video",
                  "time": child2.problem_time if child2.get_icon_class() == 'problem' and child2.problem_time is not None else "video",
                  } for child2 in self.get_display_items()]
            })
            if self.random_problem_count == -1:
                contents = all_contents
            else:
                contents = random.sample(all_contents, self.random_problem_count)

        fragment.add_content(self.system.render_template('vert_module.html', {
            'items': contents
        }))
        return fragment
    def render(self):
        # If we're rendering this sequence, but no position is set yet,
        # default the position to the first element
        if self.position is None:
            self.position = 1

        if self.rendered:
            return
        ## Returns a set of all types of all sub-children
        contents = []
        for child in self.get_display_items():
            progress = child.get_progress()
            childinfo = {
                'content': child.get_html(),
                'title': "\n".join(
                    grand_child.display_name
                    for grand_child in child.get_children()
                    if grand_child.display_name is not None
                ),
                'progress_status': Progress.to_js_status_str(progress),
                'progress_detail': Progress.to_js_detail_str(progress),
                'type': child.get_icon_class(),
                'id': child.id,
                'direct_term': child.direct_term_with_default
            }
            if childinfo['title'] == '':
                childinfo['title'] = child.display_name_with_default
            contents.append(childinfo)

        params = {'items': contents,
                  'element_id': self.location.html_id(),
                  'item_id': self.id,
                  'position': self.position,
                  'tag': self.location.category
                  }

        self.content = self.system.render_template('seq_module.html', params)
        self.rendered = True
Beispiel #8
0
    def render(self):
        # If we're rendering this sequence, but no position is set yet,
        # default the position to the first element
        if self.position is None:
            self.position = 1

        if self.rendered:
            return
        ## Returns a set of all types of all sub-children
        contents = []
        for child in self.get_display_items():
            progress = child.get_progress()
            childinfo = {
                "content": child.get_html(),
                "title": "\n".join(
                    grand_child.display_name
                    for grand_child in child.get_children()
                    if grand_child.display_name is not None
                ),
                "progress_status": Progress.to_js_status_str(progress),
                "progress_detail": Progress.to_js_detail_str(progress),
                "type": child.get_icon_class(),
                "id": child.id,
            }
            if childinfo["title"] == "":
                childinfo["title"] = child.display_name_with_default
            contents.append(childinfo)

        params = {
            "items": contents,
            "element_id": self.location.html_id(),
            "item_id": self.id,
            "position": self.position,
            "tag": self.location.category,
        }

        self.content = self.system.render_template("seq_module.html", params)
        self.rendered = True