def __str__(self): stem = self.makeupStem(True) tmp = ['(', self.nCategory, ')', stem, '\n'] if self.explanation is None: tmp.extend([nls.getNLSText('msgExplanation'), '\n']) else: tmp.extend( [nls.getNLSText('msgExplanation'), self.explanation, '\n']) return ''.join(tmp)
def toword(self, file, config=Config()): doc = Document() # prepare styles QuizPaper.preparestyles(doc) # Generate top title doc.add_paragraph(self.title, 'title') # Generate questions i = 0 qdict = self.__questions for (category, qset) in qdict.items(): # Generate question category txt = self.getbulletlead(i) \ + nls.getNLSText('N-' + category) # doc.add_heading(txt, 1) doc.add_paragraph(txt, 'h1') # Generate quests j = 0 for j in range(len(qset)): question = qset[j] question.toword(doc, self.getstemlead(j), 2, config) i = i + 1 doc.save(file)
def __str__(self): tmp = ['(', self.nCategory, ')', self.getStem(), u'('] if self.answer is not None: tmp.extend(self.answer) else: tmp.append('') tmp.append(')') tmp.append('\n') if self.explanation is None: tmp.extend([nls.getNLSText('msgExplanation'), '\n']) else: tmp.extend( [nls.getNLSText('msgExplanation'), self.explanation, '\n']) return ''.join(tmp)
def answerToWord2(self, doc): tmp = [] for i in range(len(self.answer)): tmp.extend([self.getPosIdx(i), ' ', self.answer[i], '\t']) p = doc.add_paragraph() p.add_run(nls.getNLSText('msgAnswer'), 'ptitle') p.add_run(''.join(tmp), 'pcontent') # Keep a blank paragraph doc.add_paragraph('', 'pstyle')
def __str__(self): tmp = [self.title, '\n\n'] cnt = 0 i = 0 qdict = self.__questions for (category, qset) in qdict.items(): tmp.extend( [self.getbulletlead(i), nls.getNLSText('N-' + category), '\n']) for j in range(len(qset)): cnt = cnt + 1 question = qset[j] tmp.extend([self.getstemlead(j), str(question), '\n']) tmp.append('\n') i = i + 1 tmp.extend([nls.getNLSText('msgQuizNum') + str(cnt)]) return ''.join(tmp)
def __str__(self): tmp = ['(', self.nCategory, ')', self.getStem(), u'('] if len(self.answer) > 0: if self.category == Category.SChoice: tmp.append(self.answer[0]) else: tmp.append(''.join(self.answer)) else: tmp.append('') tmp.append(u')') tmp.append('\n') for i in range(len(self.options)): tmp.extend([chr(65 + i), ' ', self.options[i], '\n']) tmp.append('\n') if self.explanation is None: tmp.extend([nls.getNLSText('msgExplanation'), '\n']) else: tmp.extend( [nls.getNLSText('msgExplanation'), self.explanation, '\n']) return ''.join(tmp)
def explanationToWord(self, doc): p = doc.add_paragraph() p.add_run(nls.getNLSText('msgExplanation'), 'ptitle') if self.explanation is not None: p.add_run(self.explanation, 'pcontent')
def answerToWord(self, doc): p = doc.add_paragraph() p.add_run(nls.getNLSText('msgAnswer'), 'ptitle') if self.answer is not None: p.add_run(self.answer, 'pcontent')
def getCategoryName(self): return nls.getNLSText('N-' + self.category)