#! /usr/bin/env python # -*- encoding: iso-8859-15 -*- #generation d'une question de questionnaire si il y a des arguments, sinon affiche le résultat def parse(text): ligne = text.split("\\") question = [] for l in ligne: l = l.split(":",1) if len(l)>=2: question+=[(l[0],l[1])] return question def question_choix_unique(f,QR): r="" id = QR[0][0] r+=f.rawHTML("""

%(Q)s

""" % { "id" : id , "Q" : QR[0][1]}) QR=QR[1:] for (point,rep) in QR: r+=f.rawHTML(""" %(rep)s
\n"""% { "point" : point , "id" : id, "rep" : rep}) return r def question_choix_multiple(f,QR): r="" id = QR[0][0] r+=f.rawHTML("""

%(Q)s

""" % { "id" : id , "Q" : QR[0][1]}) QR=QR[1:] for (point,rep) in QR: r+=f.rawHTML(""" %(rep)s
\n"""% { "point" : point , "id" : id, "rep" : rep}) return r def result(f): return """

0

""" def execute(macro,text): f = macro.formatter if text == "": return result(f) else: QR = parse(text) if QR[0][0][0]=='*': return question_choix_multiple(f,QR) else: return question_choix_unique(f,QR)