]>
git.immae.eu Git - perso/Immae/Projets/Scripts/Public.git/blob - interrogations
2 # The MIT License (MIT)
4 # Copyright (c) 2011-2015 Ismaël Bouya http://www.normalesup.org/~bouya/
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 my @tablequestion = ();
32 my $interro_courante = 0;
33 my $fichier = "notes.dat";
39 print "Nom de l'interrogation\n";
40 my $interro = <STDIN
>;
42 push(@interros,$interro);
43 push(@tablequestion,[]);
46 foreach my $key (keys %corr_nom) {
47 push(@{ $corr_nom{$key} }, "Absent" );
58 $corr_nom{$prenom."\n".$nom} = ();
59 for my $i (0..$#interros) {
60 push(@{ $corr_nom{$prenom."\n".$nom} }, "Absent" );
67 while($nbexos =~ m/\D/) {
68 print "Nombre d'exercices\n";
72 print "Mauvaise entrée\n";
78 push(@{ $table[$interro] }, $nbexos);
80 push(@{ $tablequestion[$interro] }, "");
82 for(my $i = 1; $i <= $nbexos; $i++) {
84 while($questions =~ m/\D/) {
85 print "Nombre de questions dans l'exercice ",$i,"\n";
88 if($questions =~ /\D/) {
89 print "Mauvaise entrée\n";
92 if($questions eq "") {
96 push(@{ $table[$interro] }, $questions);
97 for(my $j = 1; $j <= $questions; $j++) {
98 my $ssquestions = "a";
99 while($ssquestions =~ m/\D/) {
100 print "Nombre de sous-questions dans la question ",$i,".",$j,"\n";
101 $ssquestions = <STDIN
>;
103 if($ssquestions =~ /\D/) {
104 print "Mauvaise entrée\n";
107 if($ssquestions eq "") {
110 if($ssquestions > 1) {
111 push(@{ $table[$interro] }, $j.".".$ssquestions);
112 for(my $k = 1; $k<= $ssquestions; $k++) {
113 push(@{ $tablequestion[$interro] }, $i.".".$j.".".$k);
117 push(@{ $tablequestion[$interro] }, $i.".".$j);
122 push(@{ $tablequestion[$interro] }, $i);
135 @boucle = sort sort_alpha
keys %corr_nom;
137 foreach my $key (@boucle) {
140 print $keyt." (mettre A pour indiquer une absence)\n";
142 if(ref($corr_nom{$key}[$interro]) eq 'ARRAY') {
143 @int = @{$corr_nom{$key}[$interro]};
145 $corr_nom{$key}[$interro] = ();
146 Interro
: for my $i (0..$#{$tablequestion[$interro]}) {
147 my $pourcentage = "a";
149 if(!@int && $i == 0) {
152 if(scalar(@int) > 0) {
155 while($pourcentage =~ m/\D/ || $pourcentage > 100) {
156 if($tablequestion[$interro][$i] =~ m/\D/ ) {
157 print "Pourcentage pour la question ".$tablequestion[$interro][$i]." [".$def."]\n";
160 print "Pourcentage pour l'exercice ".$tablequestion[$interro][$i]." [".$def."]\n";
162 $pourcentage = <STDIN
>;
164 if($pourcentage eq "") {
167 if($pourcentage =~ m/^a$/i) {
168 $corr_nom{$key}[$interro] = "Absent";
171 if($pourcentage =~ /\D/ || $pourcentage > 100) {
172 print "Il faut un pourcentage entre 0 et 100\n";
175 push(@{ $corr_nom{$key}[$interro] },$pourcentage);
182 foreach my $nomquestion ( @{ $tablequestion[$interro] } ) {
184 while($point =~ /[^\d\.]/) {
185 if($nomquestion =~ m/\D/ ) {
186 print "Points pour la question ".$nomquestion."\n";
189 print "Points pour l'exercice ".$nomquestion."\n";
193 if($point =~ /[^\d\.]/) {
194 print "Il faut donner un nombre de points\n";
200 push(@{ $points[$interro] },$point);
205 open FILE
, ">".$fichier;
206 foreach my $i (0..$#table) {
207 print FILE
$interros[$i]."\n";
208 print FILE
"@{ $table[$i] }\n";
209 print FILE
"@{ $tablequestion[$i] }\n";
210 print FILE
"@{ $points[$i] }\n";
213 foreach my $ligne (keys(%corr_nom)) {
214 print FILE
$ligne."\n";
215 foreach my $lig (@{ $corr_nom{$ligne} }) {
216 if($lig eq "Absent") {
220 print FILE
"* @$lig\n";
230 while(my $int = <FILE
>) {
231 if($int eq "\n") { last };
233 push(@interros,$int);
236 push(@table, [ split(/ /, $int) ] );
239 push(@tablequestion, [ split(/ /, $int) ] );
242 push(@points, [ split(/ /, $int) ] );
247 if($int eq "\n") { last };
250 my $key = $int.$intn;
251 $corr_nom{$key} = ();
252 while($intn = <FILE
>) {
253 if($intn =~ m/^\*/) {
255 push(@{ $corr_nom{$key} }, [ split(/ /, substr($intn,2)) ] );
257 elsif($intn =~ m/^!/) {
258 push(@{ $corr_nom{$key} }, "Absent" );
270 my @p_na = split(/\n/,$a);
271 my @p_nb = split(/\n/,$b);
272 return $p_na[1] cmp $p_nb[1] || $p_na[0] cmp $p_nb[0];
277 my $f_export = <STDIN
>;
279 if($f_export eq "") { return 0 };
280 open FILE
, ">".$f_export;
281 print FILE
"\\documentclass[landscape]{article}\n";
282 print FILE
"\\usepackage[T1]{fontenc}\n";
283 print FILE
"\\usepackage[utf8]{inputenc}\n";
284 print FILE
"\\usepackage{geometry}\n";
285 print FILE
"\\geometry{margin=1cm}\n";
286 print FILE
"\\begin{document}\n";
287 for my $interro (0..$#table) {
288 print FILE
"\\begin{tabular}{|l|";
289 my @exosansq = grep(/^[1-9]\d*$/,@{ $tablequestion[$interro] });
290 print FILE
"c|"x
(scalar(@{ $tablequestion[$interro] })+$table[$interro][0] - scalar(@exosansq));
297 print FILE
"\\multicolumn{",(scalar(@{ $tablequestion[$interro] })+$table[$interro][0] - scalar(@exosansq) + 2),"}{c}{\\Large ".$interros[$interro]."}\\\\\n";
298 if($table[$interro][0] > 0) {
299 print FILE
"\\hline\n\t ";
300 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
301 my @b = grep(/^$i/,@{ $tablequestion[$interro] });
302 if(scalar(@b) == 1) {
303 print FILE
"& Exercice $i ";
306 print FILE
"& \\multicolumn{",scalar(@b)+1,"}{c|}{Exercice ",$i,"} ";
309 print FILE
"& Total ";
311 print FILE
"\\hline\n\t";
313 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
314 my @b = grep(/^$i(\D|$)/,@{ $tablequestion[$interro] });
315 for(my $j = 1; $j <= scalar(@b); $j++) {
316 my @c = grep(/^$i\.$j(\D|$)/,@{ $tablequestion[$interro] });
318 if(scalar(@c) == 1) {
321 elsif(scalar(@c) > 0) {
322 print FILE
"& \\multicolumn{",scalar(@c),"}{c|}{",$j,")} ";
326 push(@ign,$rank+$i-1);
330 print FILE
"& Total ";
333 print FILE
"& \\\\\n";
335 print FILE
"\\hline\n\t";
336 print FILE
"points ";
340 for my $i (0.. $#{ $points[$interro] }) {
341 print FILE
"& $points[$interro][$i] ";
342 push(@min,$points[$interro][$i]);
345 $totalexo += $points[$interro][$i];
346 $total += $points[$interro][$i];
348 if((grep {$_ == $i} @pts) > 0) {
350 print FILE
"& $totalexo ";
352 push(@min,$totalexo);
359 print FILE
"& $total ";
364 print FILE
"\\hline\n\t";
365 print FILE
"\\hline\n\t";
367 my @sortednotes = sort sort_alpha
(keys %corr_nom);
368 #print "@sortednotes";
370 my $nombre_eleves = 0;
371 for my $i (0.. $#sortednotes) {
372 my $np = $sortednotes[$i];
375 my @ligne = @{ $corr_nom{$sortednotes[$i]} };
376 if($ligne[$interro] eq "Absent") {
377 print FILE
"& \\multicolumn{",scalar(@{ $tablequestion[$interro] })+$table[$interro][0]+1,"}{c|}{Absent}";
380 my @ligneo = @{ $ligne[$interro] };
386 foreach my $l (0.. $#ligneo ) {
387 my $val = sprintf("%.0f",4.*$ligneo[$l]*$points[$interro][$l]/100)/4;
388 print FILE
"& ",$val;
389 if($min[$k] > $val) {
392 if($max[$k] < $val) {
400 if((grep {$_ == $l} @pts) > 0) {
401 if($min[$k] > $totalexo) {
402 $min[$k] = $totalexo;
404 if($max[$k] < $totalexo) {
405 $max[$k] = $totalexo;
407 $somme[$k] += $totalexo;
409 print FILE
"& $totalexo ";
416 print FILE
"& $total ";
417 if($min[$k] > $total) {
420 if($max[$k] < $total) {
423 $somme[$k] += $total;
427 print FILE
"\\hline\n\t";
429 print FILE
"\\hline\n\t";
430 print FILE
"Moyenne";
431 for my $l (0.. $#somme) {
432 next if((grep {$_ == $l} @ign) > 0);
433 print FILE
"& ".sprintf("%.0f",4.*$somme[$l]/$nombre_eleves)/4;
436 print FILE
"\\hline\n\t";
438 for my $l (0.. $#min) {
439 next if((grep {$_ == $l} @ign) > 0);
440 print FILE
"& $min[$l]";
443 print FILE
"\\hline\n\t";
445 for my $l (0.. $#max) {
446 next if((grep {$_ == $l} @ign) > 0);
447 print FILE
"& $max[$l]";
449 #print FILE "Moyenne & \\multicolumn{",scalar(@{ $tablequestion[$interro] })+$table[$interro][0],"}{c||}{ }";
450 #my $moyenne = sprintf("%.0f",4.*$somme/$nombre_eleves)/4;
451 #print FILE " & $moyenne\\\\\n";
453 print FILE
"\\hline\n\t";
454 print FILE
"\\end{tabular}\n";
455 print FILE
"\\vfill\n";
456 print FILE
"\\newpage\n";
458 print FILE
"\\end{document}\n";
465 my $f_export = <STDIN
>;
467 if($f_export eq "") { return 0 };
468 open FILE
, ">".$f_export;
469 for my $interro (0..$#table) {
470 print FILE
"; ".$interros[$interro]."\n";
476 if($table[$interro][0] > 0) {
477 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
478 my @b = grep(/^$i/,@{ $tablequestion[$interro] });
479 if(scalar(@b) == 1) {
480 print FILE
"; Exercice $i ";
483 print FILE
"; Exercice $i","; "x
scalar(@b);
486 print FILE
"; Total \n";
488 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
489 my @b = grep(/^$i(\D|$)/,@{ $tablequestion[$interro] });
490 for(my $j = 1; $j <= scalar(@b); $j++) {
491 my @c = grep(/^$i\.$j(\D|$)/,@{ $tablequestion[$interro] });
493 if(scalar(@c) == 1) {
496 elsif(scalar(@c) > 0) {
498 for my $num (0..$#c) {
499 print FILE
"; $j) ".$char.") ";
502 #print FILE "; $j) ","; "x (scalar(@c)-1);
506 push(@ign,$rank+$i-1);
510 print FILE
"; Total ";
515 print FILE
"points ";
519 for my $i (0.. $#{ $points[$interro] }) {
520 print FILE
"; $points[$interro][$i] ";
521 push(@min,$points[$interro][$i]);
524 $totalexo += $points[$interro][$i];
525 $total += $points[$interro][$i];
527 if((grep {$_ == $i} @pts) > 0) {
529 print FILE
"; $totalexo ";
531 push(@min,$totalexo);
538 print FILE
"; $total ";
544 my @sortednotes = sort sort_alpha
(keys %corr_nom);
545 #print "@sortednotes";
547 my $nombre_eleves = 0;
548 for my $i (0.. $#sortednotes) {
549 my $np = $sortednotes[$i];
552 my @ligne = @{ $corr_nom{$sortednotes[$i]} };
553 if($ligne[$interro] eq "Absent") {
554 print FILE
"; Absent","; "x
(scalar(@{ $tablequestion[$interro] })+$table[$interro][0]);
557 my @ligneo = @{ $ligne[$interro] };
563 foreach my $l (0.. $#ligneo ) {
564 my $val = sprintf("%.0f",4.*$ligneo[$l]*$points[$interro][$l]/100)/4;
565 print FILE
"; ",$val;
566 if($min[$k] > $val) {
569 if($max[$k] < $val) {
577 if((grep {$_ == $l} @pts) > 0) {
579 print FILE
"; $totalexo ";
581 if($min[$k] > $totalexo) {
582 $min[$k] = $totalexo;
584 if($max[$k] < $totalexo) {
585 $max[$k] = $totalexo;
587 $somme[$k] += $totalexo;
593 print FILE
"; $total ";
594 if($min[$k] > $total) {
597 if($max[$k] < $total) {
600 $somme[$k] += $total;
605 print FILE
"Moyenne";
606 for my $l (0.. $#somme) {
607 next if((grep {$_ == $l} @ign) > 0);
608 print FILE
"; ".sprintf("%.0f",4.*$somme[$l]/$nombre_eleves)/4;
612 for my $l (0.. $#min) {
613 next if((grep {$_ == $l} @ign) > 0);
614 print FILE
"; $min[$l]";
618 for my $l (0.. $#max) {
619 next if((grep {$_ == $l} @ign) > 0);
620 print FILE
"; $max[$l]";
622 #print FILE "Moyenne & \\multicolumn{",scalar(@{ $tablequestion[$interro] })+$table[$interro][0],"}{c||}{ }";
623 #my $moyenne = sprintf("%.0f",4.*$somme/$nombre_eleves)/4;
624 #print FILE " & $moyenne\\\\\n";
635 sub choisir_interro
() {
640 foreach $var ( @interros ) {
641 $message .= $i++.') '.$var."\n";
646 if(/\D/ || $var < 1 || $var > $i) {
647 print "Mauvaise entrée\n";
650 $interro_courante = $var-1;
658 open COL
, "| column";
660 my @eleves = sort sort_alpha
keys(%corr_nom);
661 foreach my $eleve_l (@eleves) {
662 my $eleve_lm = $eleve_l;
663 $eleve_lm =~ s/\n/ /;
664 print COL
$i++.") ".$eleve_lm."\n";
666 print COL
$i.") Annuler\n";
670 if(/\D/ || $var < 1 || $var > $i) {
671 print "Mauvaise entrée\n";
674 elsif( $var == $i ) {
677 $eleve = $eleves[$var-1];
680 my $notes_c = ${$corr_nom{$eleve}}[$interro_courante];
681 if($notes_c == "Absent") {
682 print "Absent à ".$interros[$interro_courante]."\n";
684 &entrer_notes
($interro_courante,$eleve);
691 my @actions = ("Ajouter une interro", "Ajouter un élève");
692 my @actions_f = (\
&ajout_interro
,
705 if(scalar(@interros)>0) {
706 $actions[2] = "Choisir une interro";
707 $actions[3] = "Éditer les notes d'un élève";
708 $actions[4] = "Définir les exercices de l'interro";
709 $actions[5] = "Définir le barême de l'interro";
710 $actions[6] = "Entrer les notes de l'interro";
711 $actions[7] = "Sauvegarder";
712 $actions[8] = "Exporter en LaTeX";
713 $actions[9] = "Exporter en CSV";
721 my @vart = ( @actions, 'Quitter' );
722 my $message = 'Interro sélectionnée : '.$interros[$interro_courante]."\n";
723 foreach $var ( @vart ) {
724 $message .= $i++.') '.$var."\n";
729 if(/\D/ || $var < 1 || $var > $i) {
730 print "Mauvaise entrée\n";
733 $action = $actions_f[$var-1];
736 &{$action}($interro_courante);