示例#1
0
 def __init__(self, stem=None, choices=None, feedback=None, comment=None):
     super(multiplechoice, self).__init__()
     self.children.append(Join.as_element(stem or []))
     self.children.append(_choices_cls(choices or []))
     self.children.append(feedback or Join([]))
     self.children.append(comment or Join([]))
     self.id = id(self)
示例#2
0
    def invoke_body(cls, job, tokens, new):
        data = super(multiplechoice, cls).invoke_body(job, tokens, new)
        data = Join(data)

        # Get comments and feedback
        new.feedback = Join.as_element([ x.unlinked() for x in data if isinstance(x, feedback) ])
        new.comment = Join.as_element([ x.unlinked() for x in data if isinstance(x, comment) ])

        # Discard all data after choices
        try:
            choices_ = data.get(choices)
            [ x.unlink() for x in choices_.get_siblings_next() ]
        except ValueError:
            choices_ = choices()

        # Reorganize elements
        new.choices = choices_.unlinked()
        new.stem = Join.as_element(strip(data.clear()))
        new.id = id(new)

        return []