diff --git a/wiki-lenny/local/macro/Questionnaire.py b/wiki-lenny/local/macro/Questionnaire.py new file mode 100755 index 00000000..70e25666 --- /dev/null +++ b/wiki-lenny/local/macro/Questionnaire.py @@ -0,0 +1,142 @@ +#! /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 = [] + min_point = 0 + 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
+ min = 0
+ for (point,rep) in QR:
+ point = int_try(point)
+ if (max < point):
+ max = point
+ if (min > point):
+ min = point
+ r+=f.rawHTML(""" %(rep)s
\n"""% { "point" : point , "id" : quest.execute, "rep" : rep})
+ quest.max_point += max
+ quest.min_point += min
+ 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)
+ if point > 0:
+ quest.max_point += point
+ else:
+ quest.min_point += point
+ r+=f.rawHTML(""" %(rep)s
\n"""% { "point" : point , "id" : quest.execute, "rep" : rep})
+ r +=f.rawHTML("\n