X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/a501e5663d1586b4dd1bbabf9fb79ccc15261735..384ddeb499d208593c4d44092d8f0c91e4aea503:/librarian/pypdf.py diff --git a/librarian/pypdf.py b/librarian/pypdf.py index 5ba5131..7267b8a 100644 --- a/librarian/pypdf.py +++ b/librarian/pypdf.py @@ -535,24 +535,19 @@ class Wybor(Exercise): if not pytania: pytania = [element] for p in pytania: - solutions = re.split(r"[, ]+", p.attrib.get('rozw', '')) + solutions = p.xpath(".//punkt[rozw='prawda']") if len(solutions) != 1: is_single_choice = False break - choices = p.xpath(".//*[@nazwa]") - uniq = set() - for n in choices: - uniq.add(n.attrib.get('nazwa', '')) - if len(choices) != len(uniq): - is_single_choice = False - break self.options = {'single': is_single_choice} return pre, post def handle_punkt(self, element): - if self.options['exercise'] and element.attrib.get('nazwa', None): + if self.options['exercise'] and element.attrib.get('rozw', None): cmd = 'radio' if self.options['single'] else 'checkbox' + if element.attrib['rozw'] == 'prawda': + cmd += 'checked' return u'' % cmd, '' else: return super(Wybor, self).handle_punkt(element)