#! /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 class questionnaire: execute = 0 liste_questions = [] max_point = 0 fonction_affiche = True def int_try(point): try: return int(point) except ValueError : return 0 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,quest): r="" id = QR[0][0] r+=f.rawHTML("""
%(id)i : %(Q)s
""" % { "id" : quest.execute , "Q" : QR[0][1]})
QR=QR[1:]
max = 0
for (point,rep) in QR:
point = int_try(point)
if (max
\n"""% { "point" : point , "id" : quest.execute, "rep" : rep})
quest.max_point += max
r += f.rawHTML("\n
%(id)i : %(Q)s
\n" % { "id" : quest.execute , "Q" : QR[0][1]})
QR=QR[1:]
for (point,rep) in QR:
point = int_try(point)
quest.max_point += point
r+=f.rawHTML(""" %(rep)s
\n"""% { "point" : point , "id" : quest.execute, "rep" : rep})
r +=f.rawHTML("\n