X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/384ddeb499d208593c4d44092d8f0c91e4aea503..935dcf2282ee3c08f776e221bc71f9a0744cb85e:/librarian/pyhtml.py?ds=inline diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 67793f6..3bda4c8 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -351,13 +351,18 @@ class Exercise(EduModule): def handle_rozw_kom(self, element): return u"""""" + def extra_attributes(self): + return {} + def handle_cwiczenie(self, element): self.options = {'exercise': element.attrib['typ']} self.question_counter = 0 self.piece_counter = 0 + extra_attrs = self.extra_attributes() + pre = u""" -
+

Zadanie %(exercies_counter)d

@@ -368,7 +373,12 @@ class Exercise(EduModule):
-""" % {'exercies_counter': self.options['exercise_counter'], 'typ': element.attrib['typ']} +""" % { + 'exercies_counter': self.options['exercise_counter'], + 'typ': element.attrib['typ'], + 'extra_attrs': ' ' + ' '.join( + 'data-%s="%s"' % item for item in extra_attrs.iteritems()) if extra_attrs else '', + } post = u"""
@@ -420,20 +430,22 @@ class Exercise(EduModule): class Wybor(Exercise): + def extra_attributes(self): + return {'subtype': 'single' if self.options['single'] else 'multiple'} + def handle_cwiczenie(self, element): - pre, post = super(Wybor, self).handle_cwiczenie(element) is_single_choice = True pytania = element.xpath(".//pytanie") if not pytania: pytania = [element] for p in pytania: - solutions = p.xpath(".//punkt[rozw='prawda']") + solutions = p.xpath(".//punkt[@rozw='prawda']") if len(solutions) != 1: is_single_choice = False break self.options = {'single': is_single_choice} - return pre, post + return super(Wybor, self).handle_cwiczenie(element) def handle_punkt(self, element): if self.options['exercise'] and element.attrib.get('rozw', None):