+class Uporzadkuj(Exercise):
+ def handle_pytanie(self, element):
+ order_items = element.xpath(".//punkt/@rozw")
+ return super(Uporzadkuj, self).handle_pytanie(element)
+
+
+class Przyporzadkuj(Exercise):
+ def handle_lista(self, lista):
+ header = etree.Element("parm")
+ header_cmd = etree.Element("cmd", name="par")
+ header_cmd.append(header)
+ if 'nazwa' in lista.attrib:
+ header.text = u"Kategorie:"
+ elif 'cel' in lista.attrib:
+ header.text = u"Elementy do przyporządkowania:"
+ else:
+ header.text = u"Lista:"
+ pre, post = super(Przyporzadkuj, self).handle_lista(lista)
+ pre = etree.tostring(header_cmd, encoding=unicode) + pre
+ return pre, post
+
+
+class Luki(Exercise):
+ def find_pieces(self, question):
+ return question.xpath(".//luka")
+
+ def solution(self, piece):
+ piece = deepcopy(piece)
+ piece.tail = None
+ sub = EduModule()
+ return sub.generate(piece)
+
+ def handle_pytanie(self, element):
+ qpre, qpost = super(Luki, self).handle_pytanie(element)
+
+ luki = self.find_pieces(element)
+ random.shuffle(luki)
+ self.words = u"<env name='itemize'>%s</env>" % (
+ "".join("<cmd name='item'/>%s" % self.solution(luka) for luka in luki)
+ )
+ return qpre, qpost
+
+ def handle_opis(self, element):
+ return '', self.words
+
+ def handle_luka(self, element):
+ luka = "_" * 10
+ if self.options['teacher']:
+ piece = deepcopy(element)
+ piece.tail = None
+ sub = EduModule()
+ text = sub.generate(piece)
+ luka += u" [rozwiązanie: %s]" % text
+ return luka
+
+
+class Zastap(Luki):
+ def find_pieces(self, question):
+ return question.xpath(".//zastap")
+
+ def solution(self, piece):
+ return piece.attrib['rozw']
+
+ def list_header(self):
+ return u"Elementy do wstawienia"
+
+ def handle_zastap(self, element):
+ piece = deepcopy(element)
+ piece.tail = None
+ sub = EduModule()
+ text = sub.generate(piece)
+ if self.options['teacher'] and element.attrib.get('rozw'):
+ text += u" [rozwiązanie: %s]" % element.attrib.get('rozw')
+ return text
+
+
+class PrawdaFalsz(Exercise):
+ def handle_punkt(self, element):
+ pre, post = super(PrawdaFalsz, self).handle_punkt(element)
+ if 'rozw' in element.attrib:
+ post += u" [Prawda/Fałsz]"
+ return pre, post
+