From: Marcin Koziej Date: Fri, 25 Jan 2013 11:25:16 +0000 (+0100) Subject: Show radios X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/f03d1fdbe472dbfb103d00b0e4ee9fa593c7b2c0?ds=sidebyside;hp=b22e1811ddec4e7af6f7e369cf1b868f8cc8140b Show radios --- diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 7114b12..a46659c 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -6,6 +6,7 @@ from lxml import etree from librarian import OutputFile, RDFNS, DCNS from xmlutils import Xmill, tag, tagged, ifoption +import re import random class EduModule(Xmill): @@ -189,6 +190,13 @@ class Excercise(EduModule): class Wybor(Excercise): + def handle_pytanie(self, element): + pre, post = super(Wybor, self).handle_pytanie(element) + solutions = re.split(r"[, ]+", element.attrib['rozw']) + if len(solutions) == 1: + self.options = { 'single': True } + return pre, post + def handle_punkt(self, element): if self.options['excercise'] and element.attrib.get('nazwa', None): qc = self.question_counter @@ -196,9 +204,16 @@ class Wybor(Excercise): no = self.piece_counter eid = "q%(qc)d_%(no)d" % locals() aname = element.attrib.get('nazwa', None) - return u""" + if self.options['single']: + return u"""
  • - + +
  • " + else: + return u""" +
  • +
  • " @@ -206,6 +221,7 @@ class Wybor(Excercise): return super(Wybor, self).handle_punkt(element) + class Uporzadkuj(Excercise): def handle_pytanie(self, element): """ @@ -284,7 +300,7 @@ class Przyporzadkuj(Excercise): 'data-target': lista.attrib['cel'], 'class': 'subject' } - self.options = {'subject': True} + self.options = {'subject': True, 'handles': 'uchwyty' in lista.attrib} else: attrs = {} pre, post = super(Przyporzadkuj, self).handle_lista(lista, attrs)