BEGIN{ FS = "[|\n\t]" ; # séparateurs de champs ##### dans les tableaux Question et Reponses: FF = 0; # indice de l'intitulé (formulaire) RR = 1; # indice de l'intitulé (fichier de résultats) NBR = 2; # indice du nombre de réponses ##### dans le tableau Questions TYP = 3; # indice du type de question ##### dans le tableau Sections: I = 0; # indice de l'intitulé NG = 1; # indice du nombre de groupes C = 2; # indice du nombre de colonnes Q = 3; # indice du nombre de questions T = 4 ; # indice du titre de la plage de texte libre nbq = 0; nbs = 0; etat = 1; # 1: chargement des questions; # 2: chargement du titre de l'enquête; # 3: chargement des sections } /\# Fin Questions/ { etat=2; } !/\%/ && !/\#/ { if(NF ==1 && etat==1) { code=$1; CodesQuestions[nbq++]=code; getline; if($1 == "simple") Questions[code,TYP]=0; else Questions[code,TYP]=1; getline; if(NF > 1) { Questions[code,FF]=$1; Questions[code,RR]=$2; } else Questions[code,RR]=Questions[code,FF]=$0; getline; i=0; while(NF > 0) { if(NF > 1) { Reponses[code,i,FF]=$1; Reponses[code,i,RR]=$2; } else Reponses[code,i,RR]=Reponses[code,i,FF]=$0; getline; i++; } Questions[code,NBR]=i; } else if(NF >=1 && etat==2) { etat=3; Intitule=$0; } else if(NF >=1 && etat==3) { Sections[nbs,I] = $0; getline; Sections[nbs,NG] = NF > 0 ? NF-1:0; if(NF > 0) { Groupes[nbs,0]=$1; for(i=2;i<=NF;i++) Groupes[nbs,i-1] = $i; } getline; Sections[nbs,C] = NF > 0 ? NF:1; for(i=1;i<=NF;i++) Colonnes[nbs,i] = $i; getline; Sections[nbs,Q] = NF > 0 ? NF:1; for(i=1;i<=NF;i++) SectQuestions[nbs,i] = $i; getline; Sections[nbs,T] = $0 ; nbs++; } } END { #################################### # Fabrication du formulaire HTML #################################### printf("%s - Evaluation des enseignements\n", Intitule) > FHTML; printf("

%s - Evaluation des enseignements

\n", Intitule) >> FHTML; printf("


> FHTML; printf("

Toutes les réponses sont facultatives, à l'exception de votre adresse électronique dans le domaine %s:

\n

En cas d'erreur, pour réinitialiser le formulaire, cliquer sur .\n",DOMADRESSES,DOMADRESSES) >> FHTML; printf("",ENQUETE) >> FHTML; for(i=0;i


%s

\n

\n",Sections[i,I]) >> FHTML; if(Sections[i,C]>1) { print "" >> FHTML; for(j=1;j<=Sections[i,C];j++) printf("",Colonnes[i,j]) >> FHTML; print "\n" >> FHTML; } if(Sections[i,NG]>0) { printf("",Groupes[i,0]) >> FHTML; for(j=0;j" >> FHTML; for(g=1;g<=Sections[i,NG];g++) printf(" %s
", i,j,g,Groupes[i,g]) >> FHTML; print "" >> FHTML; } print "
\n" >> FHTML; } for(q=1;q<=Sections[i,Q];q++) { code=SectQuestions[i,q]; if(Questions[code,TYP]==0) printf("\n",Questions[code,FF]) >> FHTML; else printf("\n",Questions[code,FF]) >> FHTML; for(j=0;j\n" >> FHTML; if(Questions[code,TYP]==0) typebouton="RADIO" ; else typebouton="CHECKBOX"; for(k=0;k %s
\n",typebouton,i,j,code,k,Reponses[code,k,FF]) >> FHTML; print "\n" >> FHTML; } print "
" >> FHTML; } print "
 
%s
%s
%s
%s (plusieurs réponses possibles)
\n

\n" >> FHTML; if (Sections[i,T] != "") { printf("


%s - %s :

\n", Sections[i,I],Sections[i,T]) >> FHTML; printf("\n

",i) >> FHTML; } } print "

\n
" >> FHTML; ############################################ # Fabrication du fichier de script analyse ############################################ print "BEGIN{" > FANALYSE ; print "TOTALREPONSES=0;" >> FANALYSE; for(i=0;i0) for(j=0;j> FANALYSE; for(q=1;q<=Sections[i,Q];q++) { code=SectQuestions[i,q]; for(j=0;j0) for(g=1;g<=Sections[i,NG];g++) printf("S%dC%dG%d%s=0;\n",i,j,g,code) >> FANALYSE; else printf("S%dC%d%s=0;\n",i,j,code) >> FANALYSE; if(Sections[i,NG]>0) for(g=1;g<=Sections[i,NG];g++) for(k=0;k> FANALYSE; else for(k=0;k> FANALYSE; } } printf("RS%dT=\"\";\n",i) >> FANALYSE; } printf "}\n\n" >> FANALYSE; print "/@/ {TOTALREPONSES++;}" >> FANALYSE; for(i=0;i0) for(k=0;k> FANALYSE; printf("/S%dC%d%s=%d/ {rS%dC%d%s=%d;}\n",i,j,code,k,i,j,code,k) >> FANALYSE; } else for(k=0;k> FANALYSE; } else { if(Sections[i,NG]>0) for(k=0;k> FANALYSE; printf("/S%dC%d%s=%d/ {rS%dC%d%s%d=1;}\n",i,j,code,k,i,j,code,k) >> FANALYSE; } else for(k=0;k> FANALYSE; } } } if(Sections[i,NG]>0) { print "\n" >> FANALYSE; for(j=0;j> FANALYSE; for(g=1;g<=Sections[i,NG];g++) printf("/GS%dC%d=%d/ {S%dC%dG%d++ ;gS%dC%d=%d;}\n",i,j,g,i,j,g,i,j,g) >> FANALYSE; } print "\n{ if (length==0) { \n" >> FANALYSE; for(j=0;j1) printf "else " >> FANALYSE; printf("if (gS%dC%d==%d) {\n",i,j,g) >> FANALYSE; for(q=1;q<=Sections[i,Q];q++) { code=SectQuestions[i,q]; if(Questions[code,TYP]==0) for(k=0;k 0) printf "else " >> FANALYSE; printf("if (rS%dC%d%s==%d) {S%dC%dG%d%s++;RS%dC%dG%d%s%d++}\n",i,j,code,k,i,j,g,code,i,j,g,code,k) >> FANALYSE; } else { for(k=0;k> FANALYSE; } } print "}\n" >> FANALYSE; } print "}\n}\n" >> FANALYSE; } } print "\n" >> FANALYSE; print "END{\n" >> FANALYSE ; print "printf (\"#!/bin/bash\\n\")\n\n" >> FANALYSE; print "printf \"TOTALREPONSES=%1d\\n\",TOTALREPONSES\n" >> FANALYSE ; for(i=0;i0) for(j=0;j> FANALYSE; for(q=1;q<=Sections[i,Q];q++) { code=SectQuestions[i,q]; for(j=0;j0) for(g=1;g<=Sections[i,NG];g++) printf("printf \"S%dC%dG%d%s=%%1d\\n\",S%dC%dG%d%s\n",i,j,g,code,i,j,g,code) >> FANALYSE; else printf("printf \"S%dC%d%s=%%1d\\n\",S%dC%d%s\n",i,j,code,i,j,code) >> FANALYSE; if(Sections[i,NG]>0) for(g=1;g<=Sections[i,NG];g++) if(Questions[code,TYP]==0) for(k=0;k> FANALYSE ; else for(k=0;k> FANALYSE ; else for(k=0;k> FANALYSE; } } } print "}" >> FANALYSE; ############################################## # Fabrication du fichier de script affichage ############################################## print "function plureponse\n { if [ $1 -gt 1 ]\n then\n echo \"$1 réponses\"\n elif [ $1 -eq 1 ]\n then\n echo \"1 réponse\"\n else\n echo \"
 
\"\n fi\n }\n\ncat << _fin0\n" >> FAFFICHAGE; printf ("%s - Evaluation des enseignements\n\n

%s - Evaluation des enseignements

\n_fin0\n\n", Intitule,Intitule) >> FAFFICHAGE; printf("eval \"vTOTALREPONSES=${TOTALREPONSES}\"\n") >> FAFFICHAGE; printf ("echo \"
Nombre de réponses : ${vTOTALREPONSES}

\"\n") >> FAFFICHAGE; print "cat << _fin00\n
Pour les questions auxquelles plusieurs réponses sont possibles, les pourcentages indiqués sont par rapport au nombre total de réponses à la question posée.


\n_fin00\n\n" >> FAFFICHAGE; for(i=0;i

%s

\n

\n",i,Sections[i,I] >> FAFFICHAGE; if(Sections[i,C]>1) { print "" >> FAFFICHAGE; for(j=1;j<=Sections[i,C];j++) printf("",Colonnes[i,j]) >> FAFFICHAGE; print "\n" >> FAFFICHAGE; } printf "_entetesection%d\n\n",i >> FAFFICHAGE; if(Sections[i,NG]>0) for(j=0;j> FAFFICHAGE; for(q=1;q<=Sections[i,Q];q++) { code=SectQuestions[i,q]; if(Questions[code,TYP]==0) printf("echo \"\"\n",Questions[code,RR]) >> FAFFICHAGE; else printf("echo \"\"\n",Questions[code,RR]) >> FAFFICHAGE; for(j=0;j0) for(g=1;g<=Sections[i,NG];g++) printf("eval \"vS%dC%dG%d%s=${S%dC%dG%d%s}\"\n",i,j,g,code,i,j,g,code) >> FAFFICHAGE; else printf("eval \"vS%dC%d%s=${S%dC%d%s}\"\n",i,j,code,i,j,code) >> FAFFICHAGE; for(k=0;k0) for(g=1;g<=Sections[i,NG];g++) printf("eval \"vRS%dC%dG%d%s%d=${RS%dC%dG%d%s%d}\"\n",i,j,g,code, k,i,j,g,code,k) >> FAFFICHAGE; else printf("eval \"vRS%dC%d%s%d=${RS%dC%d%s%d}\"\n",i,j,code,k,i,j,code,k) >> FAFFICHAGE; } if(Sections[i,NG]>0) { printf "echo \"\"\n" >> FAFFICHAGE; } else { printf("plureponse $vS%dC%d%s\n",i,j,code) >> FAFFICHAGE; for(k=0;k %s: ${vRS%dC%d%s%d}%%\";fi\n ",i,j,code,k,Reponses[code,k,RR],i,j,code,k) >> FAFFICHAGE; print "echo \"\"\n" >> FAFFICHAGE; } } print "echo \"\"\n" >> FAFFICHAGE; } print "echo \"
 
%s
%s
%s (plusieurs réponses possibles)\"\necho \"" >> FAFFICHAGE; for(g=1;g<=Sections[i,NG];g++) printf "\"\necho \"",Groupes[i,g] >> FAFFICHAGE; printf "\"\n" >> FAFFICHAGE; for(g=1;g<=Sections[i,NG];g++) { if(Questions[code,TYP]==0) printf("plureponse $vS%dC%dG%d%s\n",i,j,g,code) >> FAFFICHAGE; else printf("plureponse $vS%dC%dG%d\n",i,j,g) >> FAFFICHAGE; for(k=0;k %s: ${vRS%dC%dG%d%s%d}%% \";fi\n",i,j,g,code,k,Reponses[code,k,RR],i,j,g,code,k) >> FAFFICHAGE; print "echo \"\"\n" >> FAFFICHAGE; } print "echo \"
%s
\"\n" >> FAFFICHAGE; } print "echo \"\"\n" >> FAFFICHAGE; print Intitule ; }