Example #1
0
 def toHTML(self, doc=None, feedbacks=False):
     """ produces an HTML fragment,
     feedbacks controls the output of feedbacks"""
     if not self.valid:
         return ''
     if doc is None:
         doc = yattag.Doc()
     doc.asis('\n')
     doc.asis('<!-- New question -->')
     with doc.tag('form', klass='question'):
         with doc.tag('h3', klass='questiontitle'):
             doc.text(self.title)
         if (not feedbacks):
             if self.tail != '':
                 with doc.tag('span', klass='questionTextInline'):
                     doc.asis(utils.markupRendering(self.text, self.markup))
                 with doc.tag('span', klass='questionAnswersInline'):
                     self.answers.toHTML(doc)
                 doc.text(' ')
                 doc.asis(utils.markupRendering(self.tail, self.markup))
             else:
                 with doc.tag('div', klass='questiontext'):
                     doc.asis(utils.markupRendering(self.text, self.markup))
                 self.answers.toHTML(doc)
         if feedbacks:
             with doc.tag('div', klass='questiontext'):
                 doc.asis(utils.markupRendering(self.text, self.markup))
             self.answers.toHTMLFB(doc)
             if self.generalFeedback != '':
                 with doc.tag('div', klass='global_feedback'):
                     doc.asis('<b><em>Feedback:</em></b><br/>')
                     doc.asis(
                         utils.markupRendering(self.generalFeedback,
                                               self.markup))
     return doc
Example #2
0
 def toHTMLFB(self, doc):
     with doc.tag('div', klass='answerFeedback'):
         doc.text(self.answer)
     if self.feedbackCorrect:
         with doc.tag('div', klass='correct_answer'):
             doc.asis(markupRendering(self.feedbackCorrect,
                                      self.question.markup))
     if self.feedbackWrong:
         with doc.tag('div', klass='wrong_answer'):
             doc.asis(markupRendering(self.feedbackWrong,
                                      self.question.markup))
Example #3
0
 def toHTMLFB(self, doc):
     with doc.tag('div', klass='groupedAnswerFeedback'):
         with doc.tag('ul', klass='multianswer'):
             for a in self.answers:
                 if a.fraction > 0:
                     aklass = "right_answer"
                 else:
                     aklass = "wrong_answer"
                 with doc.tag('li', klass=aklass):
                     doc.asis(markupRendering(a.answer,
                                              self.question.markup))
                     if a.feedback:
                         doc.asis(" &#8669; "
                                  + markupRendering(a.feedback,
                                                    self.question.markup))
Example #4
0
 def toHTML(self, doc):
     with doc.tag('div', klass='groupedAnswer'):
         with doc.tag("ul", klass='multichoice'):
             for a in self.answers:
                 with doc.tag("li"):
                     doc.input(name="name", type='radio')
                     doc.asis(markupRendering(a.answer,
                                              self.question.markup))
Example #5
0
 def toHTML(self, doc):
     with doc.tag('div', klass='groupedAnswer'):
         with doc.tag('ul', klass='multianswer'):
             for a in self.answers:
                 with doc.tag('li'):
                     doc.input(name=self.question.getId(),
                               type='checkbox')
                     doc.asis(markupRendering(a.answer,
                                              self.question.markup))
Example #6
0
 def toHTMLFB(self, doc):
     with doc.tag('div', klass='groupedAnswerFeedback'):
         with doc.tag('ul'):
             for a in self.answers:
                 with doc.tag('li', klass="right_answer"):
                     doc.text(a.answer)
                     if a.feedback:
                         doc.asis(" &#8669; "
                                  + markupRendering(a.feedback,
                                                    self.question.markup))