X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/b0224a1763fd71c1c9ed19e7663d94106a513dc8..45aed036278c98bda04414dfd6f216bc5d2f7586:/librarian/pyhtml.py diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 88e1194..e5ca40e 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -42,9 +42,9 @@ class EduModule(Xmill): self.activity_counter += 1 self.options = { 'activity': True, - 'activity_counter': self.activity_counter + 'activity_counter': self.activity_counter, } - submill = EduModule(self.options) + submill = EduModule(dict(self.options.items() + {'sub_gen': True}.items())) opis = submill.generate(element.xpath('opis')[0]) @@ -78,10 +78,10 @@ class EduModule(Xmill): """ % locals() - handle_opis = ifoption(activity=False)(tag('div', 'description')) - handle_wskazowki = ifoption(activity=False)(tag('div', ('hints', 'teacher'))) + handle_opis = ifoption(sub_gen=True)(tag('div', 'description')) + handle_wskazowki = ifoption(sub_gen=True)(tag('div', ('hints', 'teacher'))) - @ifoption(activity=False) + @ifoption(sub_gen=True) @tagged('div', 'materials') def handle_pomoce(self, _): return "Pomoce: ", "" @@ -113,7 +113,7 @@ class EduModule(Xmill): surl = element.attrib.get('href', None) sxml = None if surl: - sxml = etree.fromstring(self.provider.by_uri(surl).get_string()) + sxml = etree.fromstring(self.options['provider'].by_uri(surl).get_string()) self.options = {'slowniczek': True, 'slowniczek_xml': sxml } return '
', '
' @@ -143,9 +143,10 @@ class EduModule(Xmill): # let's pull definiens from another document if self.options['slowniczek_xml'] and (not nxt or nxt.tag != 'definiens'): sxml = self.options['slowniczek_xml'] - defloc = sxml.xpath("//definiendum[content()='%s']" % element.text) + assert element.text != '' + defloc = sxml.xpath("//definiendum[text()='%s']" % element.text) if defloc: - definiens = defloc.getnext() + definiens = defloc[0].getnext() if definiens.tag == 'definiens': subgen = EduModule(self.options) definiens_s = subgen.generate(definiens) @@ -301,7 +302,8 @@ Overrides the returned content default handle_pytanie class Luki(Exercise): def find_pieces(self, question): - return question.xpath("//luka") + print question.xpath(".//luka") + return question.xpath(".//luka") def solution_html(self, piece): return piece.text + ''.join( @@ -324,8 +326,7 @@ class Luki(Exercise): return qpre, qpost def handle_opis(self, element): - pre, post = super(Luki, self).handle_opis(element) - return pre, self.words_html + post + return '', self.words_html def handle_luka(self, element): self.piece_counter += 1 @@ -334,7 +335,7 @@ class Luki(Exercise): class Zastap(Luki): def find_pieces(self, question): - return question.xpath("//zastap") + return question.xpath(".//zastap") def solution_html(self, piece): return piece.attrib['rozw']