X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/f03d1fdbe472dbfb103d00b0e4ee9fa593c7b2c0..432b6175940bcddf371c80c46e429f37ada6559f:/librarian/pyhtml.py?ds=sidebyside
diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py
index a46659c..6df3647 100644
--- a/librarian/pyhtml.py
+++ b/librarian/pyhtml.py
@@ -6,25 +6,27 @@
from lxml import etree
from librarian import OutputFile, RDFNS, DCNS
from xmlutils import Xmill, tag, tagged, ifoption
+from librarian import functions
import re
import random
+
class EduModule(Xmill):
def __init__(self, *args):
super(EduModule, self).__init__(*args)
self.activity_counter = 0
+ self.register_text_filter(lambda t: functions.substitute_entities(None, t))
def handle_powiesc(self, element):
return u"""
-
+
""", u"
"
-
handle_autor_utworu = tag("span", "author")
handle_nazwa_utworu = tag("h1", "title")
handle_dzielo_nadrzedne = tag("span", "collection")
@@ -183,18 +185,21 @@ class Excercise(EduModule):
add_class += ' handles handles-%s' % handles
self.options = {'handles': handles}
-
return '' %\
(add_class, self.question_counter, solution_s), \
- "
"
+ ""
class Wybor(Excercise):
- def handle_pytanie(self, element):
- pre, post = super(Wybor, self).handle_pytanie(element)
- solutions = re.split(r"[, ]+", element.attrib['rozw'])
- if len(solutions) == 1:
- self.options = { 'single': True }
+ def handle_cwiczenie(self, element):
+ pre, post = super(Wybor, self).handle_cwiczenie(element)
+ is_single_choice = True
+ for p in element.xpath(".//pytanie"):
+ solutions = re.split(r"[, ]+", p.attrib['rozw'])
+ if len(solutions) != 1:
+ is_single_choice = False
+ break
+ self.options = {'single': is_single_choice}
return pre, post
def handle_punkt(self, element):
@@ -221,7 +226,6 @@ class Wybor(Excercise):
return super(Wybor, self).handle_punkt(element)
-
class Uporzadkuj(Excercise):
def handle_pytanie(self, element):
"""