prawda/falsz questions
[librarian.git] / librarian / pyhtml.py
index bb835ae..d3314cc 100644 (file)
@@ -94,7 +94,8 @@ class EduModule(Xmill):
             'uporzadkuj': Uporzadkuj,
             'luki': Luki,
             'zastap': Zastap,
-            'przyporzadkuj': Przyporzadkuj
+            'przyporzadkuj': Przyporzadkuj,
+            'prawdafalsz': PrawdaFalsz
             }
         
         typ = element.attrib['typ']
@@ -186,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"""
-<li class="question-piece" data-qc="%(qc)d" data-no="%(no)d">
+<li class="question-piece" data-qc="%(qc)d" data-no="%(no)d" data-name="%(aname)s">
 <input type="checkbox" name="" id="%(eid)s" />
 <label for="%(eid)s">
 """ % locals(), u"</label></li>"
@@ -251,11 +253,24 @@ class Przyporzadkuj(Excercise):
         if self.options['subject']:
             return '<li data-solution="%(rozw)s" class="question-piece draggable">' % element.attrib, '</li>'
         elif self.options['predicate']:
+            print etree.tostring(element, encoding=unicode)
             return '<li data-predicate="%(nazwa)s">' % element.attrib, '<ul class="subjects droppable"></ul></li>'
         else:
             return super(Przyporzadkuj, self).handle_punkt(element)
 
 
+class PrawdaFalsz(Excercise):
+    def handle_punkt(self, element):
+        if 'rozw' in element.attrib:
+            return u'''<li data-solution="%s" class="question-piece">
+            <span class="buttons">
+            <a href="#" data-value="true" class="true">Prawda</a>
+            <a href="#" data-value="false" class="false">Fałsz</a>
+        </span>''' % {'prawda': 'true', 'falsz': 'false'}[element.attrib['rozw']], '</li>'
+        else:
+            return super(PrawdaFalsz, self).handle_punkt(element)
+
+
 def transform(wldoc, stylesheet='edumed', options=None, flags=None):
     """Transforms the WL document to XHTML.