From b76a02d2979785536883d1bba96b6f4bc1714376 Mon Sep 17 00:00:00 2001 From: bobot Date: Mon, 22 Jan 2007 02:34:20 +0100 Subject: [PATCH] Import initial. En bonne voie. darcs-hash:20070122013420-9e428-84217f310a5ffa3c2d1601379847c0b260a7c92d.gz --- wiki/macro/Questionnaire.py | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 wiki/macro/Questionnaire.py diff --git a/wiki/macro/Questionnaire.py b/wiki/macro/Questionnaire.py new file mode 100755 index 00000000..7745b7b1 --- /dev/null +++ b/wiki/macro/Questionnaire.py @@ -0,0 +1,44 @@ +#! /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(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) + return question(f,QR)