diff --git a/wiki/macro/Questionnaire.py b/wiki/macro/Questionnaire.py index c4323949..0a76c819 100755 --- a/wiki/macro/Questionnaire.py +++ b/wiki/macro/Questionnaire.py @@ -3,6 +3,18 @@ #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 = [] @@ -12,59 +24,104 @@ def parse(text): question+=[(l[0],l[1])] return question -def question_choix_unique(f,QR): +def question_choix_unique(f,QR,quest): r="" id = QR[0][0] - r+=f.rawHTML(""" -
%(Q)s
- """ % { "id" : id , "Q" : QR[0][1]}) + r+=f.rawHTML(""" + %(id)i : %(Q)s
+ """ % { "id" : quest.execute , "Q" : QR[0][1]})
QR=QR[1:]
+ max = 0
for (point,rep) in QR:
- r+=f.rawHTML(""" %(rep)s
\n"""% { "point" : point , "id" : id, "rep" : rep})
+ point = int_try(point)
+ if (max
\n"""% { "point" : point , "id" : quest.execute, "rep" : rep})
+ quest.max_point += max
+ r += f.rawHTML("\n
%(Q)s
- """ % { "id" : id , "Q" : QR[0][1]}) - QR=QR[1:] - for (point,rep) in QR: - r+=f.rawHTML(""" %(rep)s