Ajout de la possibilitéede choix multiples en mettant une * au débutde
l'argument darcs-hash:20070123094006-9e428-7fcc357779bacd860bc707b1509ae03c4ea31bb7.gz
This commit is contained in:
parent
555bd2bb20
commit
52e9091bae
1 changed files with 28 additions and 2 deletions
|
@ -12,7 +12,7 @@ def parse(text):
|
|||
question+=[(l[0],l[1])]
|
||||
return question
|
||||
|
||||
def question(f,QR):
|
||||
def question_choix_unique(f,QR):
|
||||
r=""
|
||||
id = QR[0][0]
|
||||
r+=f.rawHTML("""<script type="text/javascript">
|
||||
|
@ -32,6 +32,29 @@ def question(f,QR):
|
|||
r+=f.rawHTML("""<input type="radio" name="radio%(id)s" onclick="ajoute_Q%(id)s(%(point)s)" > %(rep)s<br>\n"""% { "point" : point , "id" : id, "rep" : rep})
|
||||
return r
|
||||
|
||||
|
||||
def question_choix_multiple(f,QR):
|
||||
r=""
|
||||
id = QR[0][0]
|
||||
r+=f.rawHTML("""<script type="text/javascript">
|
||||
var point_globale = 0
|
||||
function ajoute_multiple(point,on)
|
||||
{
|
||||
if(on)
|
||||
{point_globale = point_globale + point}
|
||||
else
|
||||
{point_globale = point_globale - point}
|
||||
document.getElementById('result').innerHTML = point_globale
|
||||
}
|
||||
</script>
|
||||
<p> %(Q)s </p>
|
||||
""" % { "id" : id , "Q" : QR[0][1]})
|
||||
QR=QR[1:]
|
||||
for (point,rep) in QR:
|
||||
r+=f.rawHTML("""<input type="checkbox" name="radio%(id)s" onclick="ajoute_multiple(%(point)s,this.checked)" > %(rep)s<br>\n"""% { "point" : point , "id" : id, "rep" : rep})
|
||||
return r
|
||||
|
||||
|
||||
def result(f):
|
||||
return """<p id="result"> 0 </p>"""
|
||||
|
||||
|
@ -41,4 +64,7 @@ def execute(macro,text):
|
|||
return result(f)
|
||||
else:
|
||||
QR = parse(text)
|
||||
return question(f,QR)
|
||||
if QR[0][0][0]=='*':
|
||||
return question_choix_multiple(f,QR)
|
||||
else:
|
||||
return question_choix_unique(f,QR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue