From 6c528bcbd5a184387bbb30500b67caef8a21889d Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 28 Jul 2017 10:30:35 +0200 Subject: [PATCH] fix cwiczenie wybor --- librarian/pyhtml.py | 22 +++++++++++++++++----- librarian/pypdf.py | 4 ++-- librarian/res/styles/edumed/pdf/edumed.sty | 10 ++++++---- 3 files changed, 25 insertions(+), 11 deletions(-) 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): diff --git a/librarian/pypdf.py b/librarian/pypdf.py index 7267b8a..de0f859 100644 --- a/librarian/pypdf.py +++ b/librarian/pypdf.py @@ -535,7 +535,7 @@ class Wybor(Exercise): 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 @@ -546,7 +546,7 @@ class Wybor(Exercise): def handle_punkt(self, element): if self.options['exercise'] and element.attrib.get('rozw', None): cmd = 'radio' if self.options['single'] else 'checkbox' - if element.attrib['rozw'] == 'prawda': + if self.options['teacher'] and element.attrib['rozw'] == 'prawda': cmd += 'checked' return u'' % cmd, '' else: diff --git a/librarian/res/styles/edumed/pdf/edumed.sty b/librarian/res/styles/edumed/pdf/edumed.sty index b0d7831..0f45f35 100644 --- a/librarian/res/styles/edumed/pdf/edumed.sty +++ b/librarian/res/styles/edumed/pdf/edumed.sty @@ -1,4 +1,5 @@ \usepackage[MeX]{polski} +\usepackage{amssymb} \newcommand{\activitycounter}[1]{\vspace{1em}\par{\huge{#1}}} @@ -7,12 +8,13 @@ \newcommand{\activityform}[1]{Forma: #1 \\} \newcommand{\activitytools}[1]{#1 \\} -\newcommand{\checked}{\rlap{$\square$}{\raisebox{2pt}{\large\hspace{1pt}\cmark}} +\newcommand{\cmarkboxed}{\rlap{\Square}{\raisebox{2pt}{\large\hspace{1pt}\checkmark}}% +\hspace{-2.5pt}} -\newcommand*\checkbox{\item[\square]} -\newcommand*\checkbox{\item[\checked]} +\newcommand*\checkbox{\item[\Square]} +\newcommand*\checkboxchecked{\item[\cmarkboxed]} \newcommand*\radio{\item[\Circle]} -\newcommand*\radiochecked{\item[\odot]} +\newcommand*\radiochecked{\item[$\odot$]} \renewcommand{\naglowekrozdzial}[1]{% -- 2.20.1