From: Marcin Koziej Date: Wed, 16 Jan 2013 15:54:05 +0000 (+0100) Subject: dragging overhault X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/3a04fe720cdaef17c5dfa12c011a540a6f77dfc5 dragging overhault --- diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index d3314cc..2cbc678 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -6,7 +6,7 @@ from lxml import etree from librarian import OutputFile, RDFNS, DCNS from xmlutils import Xmill, tag, tagged, ifoption - +import random class EduModule(Xmill): def __init__(self, *args): @@ -218,8 +218,29 @@ Overrides the returned content default handle_pytanie class Luki(Excercise): + def handle_pytanie(self, element): + qpre, qpost = super(Luki, self).handle_pytanie(element) + + luki = list(enumerate(element.xpath("//luka"))) + luki_html = "" + i = 0 + random.shuffle(luki) + for (i, luka) in luki: + i += 1 + luka_html = luka.text + \ + ''.join([etree.tostring(n, encoding=unicode) for n in luka]) + luki_html += u'%s' % (i, luka_html) + self.words_html = '
%s
' % luki_html + + return qpre, qpost + + def handle_opis(self, element): + pre, post = super(Luki, self).handle_opis(element) + return pre, self.words_html + post + def handle_luka(self, element): - return '' % element.text + self.piece_counter += 1 + return '' % self.piece_counter class Zastap(Excercise): @@ -248,13 +269,17 @@ class Przyporzadkuj(Excercise): return pre, post + '
' def handle_punkt(self, element): + self.piece_counter += 1 print "in punkt %s %s" % (element.attrib, self.options) if self.options['subject']: - return '
  • ' % element.attrib, '
  • ' + return '
  • ' % (element.attrib['rozw'], self.piece_counter), '
  • ' + elif self.options['predicate']: print etree.tostring(element, encoding=unicode) - return '
  • ' % element.attrib, '
  • ' + placeholders = u'
  • ' + return '
  • ' % element.attrib, '
  • ' + else: return super(Przyporzadkuj, self).handle_punkt(element)