X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/384ddeb499d208593c4d44092d8f0c91e4aea503..935dcf2282ee3c08f776e221bc71f9a0744cb85e:/librarian/pypdf.py diff --git a/librarian/pypdf.py b/librarian/pypdf.py index 7267b8a..904b9b3 100644 --- a/librarian/pypdf.py +++ b/librarian/pypdf.py @@ -121,27 +121,31 @@ class EduModule(Xmill): @escape(True) def get_curriculum(self, element): - identifiers = self.get_dc(element, 'subject.curriculum') - if not identifiers: - return '' - try: - from curriculum.templatetags.curriculum_tags import curriculum - curr_elements = curriculum(identifiers) - except ImportError: - curr_elements = {'identifiers': identifiers} - items = ['Podstawa programowa:'] - newline = '\n' - if 'currset' in curr_elements: - for (course, level), types in curr_elements['currset'].iteritems(): - lines = [u'%s, %s poziom edukacyjny' % (course, level)] - for type, currs in types.iteritems(): - lines.append(type) - lines += [curr.title for curr in currs] - items.append(newline.join(lines)) - else: - items += identifiers - return '\n.6em\n'.join( - '%s' % item for item in items) + ret = [] + for dc_tag, new in [('subject.curriculum', False), ('subject.curriculum.new', True)]: + identifiers = self.get_dc(element, dc_tag) + if not identifiers: + continue + try: + from curriculum.templatetags.curriculum_tags import curriculum + curr_elements = curriculum(identifiers) + except ImportError: + curr_elements = {'identifiers': identifiers} + items = ['Podstawa programowa 2017:' if new else 'Podstawa programowa:'] + newline = '\n' + if 'currset' in curr_elements: + for (course, level), types in curr_elements['currset'].iteritems(): + label = u'klasa' if new else u'poziom edukacyjny' + lines = [u'%s, %s %s' % (course, level, label)] + for type, currs in types.iteritems(): + lines.append(type) + lines += [curr.title for curr in currs] + items.append(newline.join(lines)) + else: + items += identifiers + ret.append('\n.6em\n'.join( + '%s' % item for item in items)) + return '\n1em\n'.join(ret) def handle_utwor(self, element): lines = [ @@ -535,7 +539,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 +550,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: