X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/79da3449684beeb938735346e1d66093f51ba36d..ab001bc37c0f8ee0bb92b8762f5151b5b93f6ccc:/librarian/pyhtml.py diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index bd3bbce..bb835ae 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -137,16 +137,19 @@ 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 self.piece_counter = 0 - return u""" + pre = u"""
-""" % element.attrib, \ -u""" +""" % element.attrib + post = u"""
@@ -155,8 +158,16 @@ u"""
""" + # Add a single tag if it's not there + if not element.xpath(".//pytanie"): + qpre, qpost = self.handle_pytanie(element) + pre = pre + qpre + post = qpost + post + return pre, post def handle_pytanie(self, element): + """This will handle element, when there is no + """ self.question_counter += 1 self.piece_counter = 0 solution = element.attrib.get('rozw', None) @@ -165,7 +176,7 @@ u""" return '
' %\ (self.question_counter, solution_s), \ - "
" + "
" class Wybor(Excercise): @@ -186,16 +197,18 @@ class Wybor(Excercise): class Uporzadkuj(Excercise): - def handle_cwiczenie(self, element): - pre, post = super(Uporzadkuj, self).handle_cwiczenie(element) + def handle_pytanie(self, element): + """ +Overrides the returned content default handle_pytanie + """ + # we ignore the result, returning our own + super(Uporzadkuj, self).handle_pytanie(element) order_items = element.xpath(".//punkt/@rozw") - import pdb - if order_items == []: pdb.set_trace() - return pre + u"""
""" % \ - ','.join(order_items), \ - u"""
""" + post - + return u"""
""" % \ + (','.join(order_items), self.question_counter), \ + u"""
""" + def handle_punkt(self, element): return """
  • """ \ % element.attrib,\ @@ -207,7 +220,6 @@ class Luki(Excercise): return '' % element.text - class Zastap(Excercise): def handle_zastap(self, element): return '' % element.attrib, '' @@ -230,22 +242,20 @@ 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, '
  • ' + return '
  • ' % element.attrib, '
  • ' else: return super(Przyporzadkuj, self).handle_punkt(element) - - def transform(wldoc, stylesheet='edumed', options=None, flags=None): """Transforms the WL document to XHTML. @@ -253,7 +263,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())