X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e797b32fa517a05d15fbd3c15a30d8c615500fd6..935dcf2282ee3c08f776e221bc71f9a0744cb85e:/librarian/pypdf.py
diff --git a/librarian/pypdf.py b/librarian/pypdf.py
index 5ba5131..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,24 +539,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 self.options['teacher'] and element.attrib['rozw'] == 'prawda':
+ cmd += 'checked'
return u'' % cmd, ''
else:
return super(Wybor, self).handle_punkt(element)