+ def find_pieces(self, question):
+ return question.xpath("//luka")
+
+ def solution_html(self, piece):
+ return piece.text + ''.join(
+ [etree.tostring(n, encoding=unicode)
+ for n in piece])
+
+ def handle_pytanie(self, element):
+ qpre, qpost = super(Luki, self).handle_pytanie(element)
+
+ luki = list(enumerate(self.find_pieces(element)))
+ luki_html = ""
+ i = 0
+ random.shuffle(luki)
+ for (i, luka) in luki:
+ i += 1
+ luka_html = self.solution_html(luka)
+ luki_html += u'<span class="draggable question-piece" data-no="%d">%s</span>' % (i, luka_html)
+ self.words_html = '<div class="words">%s</div>' % luki_html
+
+ return qpre, qpost
+
+ def handle_opis(self, element):
+ pre, post = super(Luki, self).handle_opis(element)
+ return pre, self.words_html + post
+