+class Przyporzadkuj(Exercise):
+ def handle_pytanie(self, element):
+ pre, post = super(Przyporzadkuj, self).handle_pytanie(element)
+ minimum = element.attrib.get("min", None)
+ if minimum:
+ self.options = {"min": int(minimum)}
+ return pre, post
+
+ def handle_lista(self, lista):
+ if 'nazwa' in lista.attrib:
+ attrs = {
+ 'data-name': lista.attrib['nazwa'],
+ 'class': 'predicate'
+ }
+ self.options = {'predicate': True}
+ elif 'cel' in lista.attrib:
+ attrs = {
+ 'data-target': lista.attrib['cel'],
+ 'class': 'subject'
+ }
+ self.options = {'subject': True, 'handles': 'uchwyty' in lista.attrib}
+ else:
+ attrs = {}
+ pre, post = super(Przyporzadkuj, self).handle_lista(lista, attrs)
+ return pre, post + '<br class="clr"/>'
+
+ def handle_punkt(self, element):
+ if self.options['subject']:
+ self.piece_counter += 1
+ if self.options['handles']:
+ return '<li><span data-solution="%s" data-no="%s" class="question-piece draggable handle">%s</span>' % (element.attrib['rozw'], self.piece_counter, self.piece_counter), '</li>'
+ else:
+ return '<li data-solution="%s" data-no="%s" class="question-piece draggable">' % (element.attrib['rozw'], self.piece_counter), '</li>'
+
+ elif self.options['predicate']:
+ if self.options['min']:
+ placeholders = u'<li class="placeholder"/>' * self.options['min']
+ else:
+ placeholders = u'<li class="placeholder multiple"/>'
+ return '<li data-predicate="%(nazwa)s">' % element.attrib, '<ul class="subjects">' + placeholders + '</ul></li>'
+
+ else:
+ return super(Przyporzadkuj, self).handle_punkt(element)