X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e0e7693096469f5952eef1c5847dabc9cf797f70..36ded31bc121ec258d35bd209d9da93224f773aa:/librarian/pyhtml.py diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index fcfb3a6..621340e 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -13,29 +13,6 @@ class EduModule(Xmill): super(EduModule, self).__init__(*args) self.activity_counter = 0 - - -# def handle_utwor(self, element): -# v = {} -# # from pdb import *; set_trace() -# v['title'] = element.xpath('//dc:title/text()', namespaces={'dc':DCNS.uri})[0] -# return u""" -# -# -# -# -# %(title)s -# -# -# -# -# -# """ % v, u""" -# -# -# """ - - def handle_powiesc(self, element): return u"""
@@ -117,6 +94,7 @@ class EduModule(Xmill): 'uporzadkuj': Uporzadkuj, 'luki': Luki, 'zastap': Zastap, + 'przyporzadkuj': Przyporzadkuj } typ = element.attrib['typ'] @@ -164,11 +142,11 @@ class Excercise(EduModule): self.question_counter = 0 self.piece_counter = 0 - return u""" + pre = u"""
-""" % element.attrib, \ -u""" +""" % element.attrib + post = u"""
@@ -177,8 +155,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) @@ -208,15 +194,17 @@ 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 """
  • """ \ @@ -236,20 +224,34 @@ class Zastap(Excercise): class Przyporzadkuj(Excercise): - def handle_lista(self, element): + def handle_lista(self, lista): + print "in lista %s %s" % (lista.attrib, self.options) if 'nazwa' in lista.attrib: attrs = { 'data-name': lista.attrib['nazwa'], - 'class': 'category' + 'class': 'predicate' } + self.options = {'predicate': True} elif 'cel' in lista.attrib: attrs = { 'data-target': lista.attrib['cel'], - 'class': 'object' + 'class': 'subject' } + self.options = {'subject': True} else: attrs = {} - return super(Przyporzadkuj, self).handle_lista(element, attrs) + return super(Przyporzadkuj, self).handle_lista(lista, attrs) + + + def handle_punkt(self, element): + print "in punkt %s %s" % (element.attrib, self.options) + + if self.options['subject']: + return '
  • ' % element.attrib, '
  • ' + elif self.options['predicate']: + return '
  • ' % element.attrib, '
    • Placeholder
  • ' + else: + return super(Przyporzadkuj, self).handle_punkt(element)