X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/36ded31bc121ec258d35bd209d9da93224f773aa..aeed223c57f453d068216f86941b7de963190536:/librarian/pyhtml.py diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 621340e..d3314cc 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -94,7 +94,8 @@ class EduModule(Xmill): 'uporzadkuj': Uporzadkuj, 'luki': Luki, 'zastap': Zastap, - 'przyporzadkuj': Przyporzadkuj + 'przyporzadkuj': Przyporzadkuj, + 'prawdafalsz': PrawdaFalsz } typ = element.attrib['typ'] @@ -137,6 +138,9 @@ class Excercise(EduModule): self.question_counter = 0 super(Excercise, self).__init__(*args, **kw) + def handle_rozw_kom(self, element): + return None + def handle_cwiczenie(self, element): self.options = {'excercise': element.attrib['typ']} self.question_counter = 0 @@ -173,7 +177,7 @@ class Excercise(EduModule): return '
' %\ (self.question_counter, solution_s), \ - "
" + "" class Wybor(Excercise): @@ -183,8 +187,9 @@ class Wybor(Excercise): self.piece_counter += 1 no = self.piece_counter eid = "q%(qc)d_%(no)d" % locals() + aname = element.attrib.get('nazwa', None) return u""" -
  • +
  • " @@ -205,7 +210,7 @@ Overrides the returned content default handle_pytanie return u"""
    """ % \ (','.join(order_items), self.question_counter), \ u"""
    """ - + def handle_punkt(self, element): return """
  • """ \ % element.attrib,\ @@ -217,7 +222,6 @@ class Luki(Excercise): return '' % element.text - class Zastap(Excercise): def handle_zastap(self, element): return '' % element.attrib, '' @@ -240,20 +244,31 @@ class Przyporzadkuj(Excercise): self.options = {'subject': True} else: attrs = {} - return super(Przyporzadkuj, self).handle_lista(lista, attrs) - + pre, post = super(Przyporzadkuj, self).handle_lista(lista, attrs) + return pre, post + '
    ' def handle_punkt(self, element): print "in punkt %s %s" % (element.attrib, self.options) if self.options['subject']: - return '
  • ' % element.attrib, '
  • ' + return '
  • ' % element.attrib, '
  • ' elif self.options['predicate']: - return '
  • ' % element.attrib, '
  • ' + print etree.tostring(element, encoding=unicode) + return '
  • ' % element.attrib, '
  • ' else: return super(Przyporzadkuj, self).handle_punkt(element) +class PrawdaFalsz(Excercise): + def handle_punkt(self, element): + if 'rozw' in element.attrib: + return u'''
  • + + Prawda + Fałsz + ''' % {'prawda': 'true', 'falsz': 'false'}[element.attrib['rozw']], '
  • ' + else: + return super(PrawdaFalsz, self).handle_punkt(element) def transform(wldoc, stylesheet='edumed', options=None, flags=None): @@ -263,7 +278,6 @@ def transform(wldoc, stylesheet='edumed', options=None, flags=None): otherwise returns True if file has been written,False if it hasn't. File won't be written if it has no content. """ - edumod = EduModule(options) # from pdb import set_trace; set_trace() html = edumod.generate(wldoc.edoc.getroot())