]>
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
25 # Feel like tipping/donating? https://www.immae.eu/licenses_and_tipping
32 my @tablequestion = ();
35 my $interro_courante = 0;
36 my $fichier = "notes.dat";
42 print "Nom de l'interrogation\n";
43 my $interro = <STDIN
>;
45 push(@interros,$interro);
46 push(@tablequestion,[]);
49 foreach my $key (keys %corr_nom) {
50 push(@{ $corr_nom{$key} }, "Absent" );
61 $corr_nom{$prenom."\n".$nom} = ();
62 for my $i (0..$#interros) {
63 push(@{ $corr_nom{$prenom."\n".$nom} }, "Absent" );
70 while($nbexos =~ m/\D/) {
71 print "Nombre d'exercices\n";
75 print "Mauvaise entrée\n";
81 push(@{ $table[$interro] }, $nbexos);
83 push(@{ $tablequestion[$interro] }, "");
85 for(my $i = 1; $i <= $nbexos; $i++) {
87 while($questions =~ m/\D/) {
88 print "Nombre de questions dans l'exercice ",$i,"\n";
91 if($questions =~ /\D/) {
92 print "Mauvaise entrée\n";
95 if($questions eq "") {
99 push(@{ $table[$interro] }, $questions);
100 for(my $j = 1; $j <= $questions; $j++) {
101 my $ssquestions = "a";
102 while($ssquestions =~ m/\D/) {
103 print "Nombre de sous-questions dans la question ",$i,".",$j,"\n";
104 $ssquestions = <STDIN
>;
106 if($ssquestions =~ /\D/) {
107 print "Mauvaise entrée\n";
110 if($ssquestions eq "") {
113 if($ssquestions > 1) {
114 push(@{ $table[$interro] }, $j.".".$ssquestions);
115 for(my $k = 1; $k<= $ssquestions; $k++) {
116 push(@{ $tablequestion[$interro] }, $i.".".$j.".".$k);
120 push(@{ $tablequestion[$interro] }, $i.".".$j);
125 push(@{ $tablequestion[$interro] }, $i);
138 @boucle = sort sort_alpha
keys %corr_nom;
140 foreach my $key (@boucle) {
143 print $keyt." (mettre A pour indiquer une absence)\n";
145 if(ref($corr_nom{$key}[$interro]) eq 'ARRAY') {
146 @int = @{$corr_nom{$key}[$interro]};
148 $corr_nom{$key}[$interro] = ();
149 Interro
: for my $i (0..$#{$tablequestion[$interro]}) {
150 my $pourcentage = "a";
152 if(!@int && $i == 0) {
155 if(scalar(@int) > 0) {
158 while($pourcentage =~ m/\D/ || $pourcentage > 100) {
159 if($tablequestion[$interro][$i] =~ m/\D/ ) {
160 print "Pourcentage pour la question ".$tablequestion[$interro][$i]." [".$def."]\n";
163 print "Pourcentage pour l'exercice ".$tablequestion[$interro][$i]." [".$def."]\n";
165 $pourcentage = <STDIN
>;
167 if($pourcentage eq "") {
170 if($pourcentage =~ m/^a$/i) {
171 $corr_nom{$key}[$interro] = "Absent";
174 if($pourcentage =~ /\D/ || $pourcentage > 100) {
175 print "Il faut un pourcentage entre 0 et 100\n";
178 push(@{ $corr_nom{$key}[$interro] },$pourcentage);
185 foreach my $nomquestion ( @{ $tablequestion[$interro] } ) {
187 while($point =~ /[^\d\.]/) {
188 if($nomquestion =~ m/\D/ ) {
189 print "Points pour la question ".$nomquestion."\n";
192 print "Points pour l'exercice ".$nomquestion."\n";
196 if($point =~ /[^\d\.]/) {
197 print "Il faut donner un nombre de points\n";
203 push(@{ $points[$interro] },$point);
208 open FILE
, ">".$fichier;
209 foreach my $i (0..$#table) {
210 print FILE
$interros[$i]."\n";
211 print FILE
"@{ $table[$i] }\n";
212 print FILE
"@{ $tablequestion[$i] }\n";
213 print FILE
"@{ $points[$i] }\n";
216 foreach my $ligne (keys(%corr_nom)) {
217 print FILE
$ligne."\n";
218 foreach my $lig (@{ $corr_nom{$ligne} }) {
219 if($lig eq "Absent") {
223 print FILE
"* @$lig\n";
233 while(my $int = <FILE
>) {
234 if($int eq "\n") { last };
236 push(@interros,$int);
239 push(@table, [ split(/ /, $int) ] );
242 push(@tablequestion, [ split(/ /, $int) ] );
245 push(@points, [ split(/ /, $int) ] );
250 if($int eq "\n") { last };
253 my $key = $int.$intn;
254 $corr_nom{$key} = ();
255 while($intn = <FILE
>) {
256 if($intn =~ m/^\*/) {
258 push(@{ $corr_nom{$key} }, [ split(/ /, substr($intn,2)) ] );
260 elsif($intn =~ m/^!/) {
261 push(@{ $corr_nom{$key} }, "Absent" );
273 my @p_na = split(/\n/,$a);
274 my @p_nb = split(/\n/,$b);
275 return $p_na[1] cmp $p_nb[1] || $p_na[0] cmp $p_nb[0];
280 my $f_export = <STDIN
>;
282 if($f_export eq "") { return 0 };
283 open FILE
, ">".$f_export;
284 print FILE
"\\documentclass[landscape]{article}\n";
285 print FILE
"\\usepackage[T1]{fontenc}\n";
286 print FILE
"\\usepackage[utf8]{inputenc}\n";
287 print FILE
"\\usepackage{geometry}\n";
288 print FILE
"\\geometry{margin=1cm}\n";
289 print FILE
"\\begin{document}\n";
290 for my $interro (0..$#table) {
291 print FILE
"\\begin{tabular}{|l|";
292 my @exosansq = grep(/^[1-9]\d*$/,@{ $tablequestion[$interro] });
293 print FILE
"c|"x
(scalar(@{ $tablequestion[$interro] })+$table[$interro][0] - scalar(@exosansq));
300 print FILE
"\\multicolumn{",(scalar(@{ $tablequestion[$interro] })+$table[$interro][0] - scalar(@exosansq) + 2),"}{c}{\\Large ".$interros[$interro]."}\\\\\n";
301 if($table[$interro][0] > 0) {
302 print FILE
"\\hline\n\t ";
303 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
304 my @b = grep(/^$i/,@{ $tablequestion[$interro] });
305 if(scalar(@b) == 1) {
306 print FILE
"& Exercice $i ";
309 print FILE
"& \\multicolumn{",scalar(@b)+1,"}{c|}{Exercice ",$i,"} ";
312 print FILE
"& Total ";
314 print FILE
"\\hline\n\t";
316 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
317 my @b = grep(/^$i(\D|$)/,@{ $tablequestion[$interro] });
318 for(my $j = 1; $j <= scalar(@b); $j++) {
319 my @c = grep(/^$i\.$j(\D|$)/,@{ $tablequestion[$interro] });
321 if(scalar(@c) == 1) {
324 elsif(scalar(@c) > 0) {
325 print FILE
"& \\multicolumn{",scalar(@c),"}{c|}{",$j,")} ";
329 push(@ign,$rank+$i-1);
333 print FILE
"& Total ";
336 print FILE
"& \\\\\n";
338 print FILE
"\\hline\n\t";
339 print FILE
"points ";
343 for my $i (0.. $#{ $points[$interro] }) {
344 print FILE
"& $points[$interro][$i] ";
345 push(@min,$points[$interro][$i]);
348 $totalexo += $points[$interro][$i];
349 $total += $points[$interro][$i];
351 if((grep {$_ == $i} @pts) > 0) {
353 print FILE
"& $totalexo ";
355 push(@min,$totalexo);
362 print FILE
"& $total ";
367 print FILE
"\\hline\n\t";
368 print FILE
"\\hline\n\t";
370 my @sortednotes = sort sort_alpha
(keys %corr_nom);
371 #print "@sortednotes";
373 my $nombre_eleves = 0;
374 for my $i (0.. $#sortednotes) {
375 my $np = $sortednotes[$i];
378 my @ligne = @{ $corr_nom{$sortednotes[$i]} };
379 if($ligne[$interro] eq "Absent") {
380 print FILE
"& \\multicolumn{",scalar(@{ $tablequestion[$interro] })+$table[$interro][0]+1,"}{c|}{Absent}";
383 my @ligneo = @{ $ligne[$interro] };
389 foreach my $l (0.. $#ligneo ) {
390 my $val = sprintf("%.0f",4.*$ligneo[$l]*$points[$interro][$l]/100)/4;
391 print FILE
"& ",$val;
392 if($min[$k] > $val) {
395 if($max[$k] < $val) {
403 if((grep {$_ == $l} @pts) > 0) {
404 if($min[$k] > $totalexo) {
405 $min[$k] = $totalexo;
407 if($max[$k] < $totalexo) {
408 $max[$k] = $totalexo;
410 $somme[$k] += $totalexo;
412 print FILE
"& $totalexo ";
419 print FILE
"& $total ";
420 if($min[$k] > $total) {
423 if($max[$k] < $total) {
426 $somme[$k] += $total;
430 print FILE
"\\hline\n\t";
432 print FILE
"\\hline\n\t";
433 print FILE
"Moyenne";
434 for my $l (0.. $#somme) {
435 next if((grep {$_ == $l} @ign) > 0);
436 print FILE
"& ".sprintf("%.0f",4.*$somme[$l]/$nombre_eleves)/4;
439 print FILE
"\\hline\n\t";
441 for my $l (0.. $#min) {
442 next if((grep {$_ == $l} @ign) > 0);
443 print FILE
"& $min[$l]";
446 print FILE
"\\hline\n\t";
448 for my $l (0.. $#max) {
449 next if((grep {$_ == $l} @ign) > 0);
450 print FILE
"& $max[$l]";
452 #print FILE "Moyenne & \\multicolumn{",scalar(@{ $tablequestion[$interro] })+$table[$interro][0],"}{c||}{ }";
453 #my $moyenne = sprintf("%.0f",4.*$somme/$nombre_eleves)/4;
454 #print FILE " & $moyenne\\\\\n";
456 print FILE
"\\hline\n\t";
457 print FILE
"\\end{tabular}\n";
458 print FILE
"\\vfill\n";
459 print FILE
"\\newpage\n";
461 print FILE
"\\end{document}\n";
468 my $f_export = <STDIN
>;
470 if($f_export eq "") { return 0 };
471 open FILE
, ">".$f_export;
472 for my $interro (0..$#table) {
473 print FILE
"; ".$interros[$interro]."\n";
479 if($table[$interro][0] > 0) {
480 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
481 my @b = grep(/^$i/,@{ $tablequestion[$interro] });
482 if(scalar(@b) == 1) {
483 print FILE
"; Exercice $i ";
486 print FILE
"; Exercice $i","; "x
scalar(@b);
489 print FILE
"; Total \n";
491 for(my $i = 1; $i <= $table[$interro][0]; $i++) {
492 my @b = grep(/^$i(\D|$)/,@{ $tablequestion[$interro] });
493 for(my $j = 1; $j <= scalar(@b); $j++) {
494 my @c = grep(/^$i\.$j(\D|$)/,@{ $tablequestion[$interro] });
496 if(scalar(@c) == 1) {
499 elsif(scalar(@c) > 0) {
501 for my $num (0..$#c) {
502 print FILE
"; $j) ".$char.") ";
505 #print FILE "; $j) ","; "x (scalar(@c)-1);
509 push(@ign,$rank+$i-1);
513 print FILE
"; Total ";
518 print FILE
"points ";
522 for my $i (0.. $#{ $points[$interro] }) {
523 print FILE
"; $points[$interro][$i] ";
524 push(@min,$points[$interro][$i]);
527 $totalexo += $points[$interro][$i];
528 $total += $points[$interro][$i];
530 if((grep {$_ == $i} @pts) > 0) {
532 print FILE
"; $totalexo ";
534 push(@min,$totalexo);
541 print FILE
"; $total ";
547 my @sortednotes = sort sort_alpha
(keys %corr_nom);
548 #print "@sortednotes";
550 my $nombre_eleves = 0;
551 for my $i (0.. $#sortednotes) {
552 my $np = $sortednotes[$i];
555 my @ligne = @{ $corr_nom{$sortednotes[$i]} };
556 if($ligne[$interro] eq "Absent") {
557 print FILE
"; Absent","; "x
(scalar(@{ $tablequestion[$interro] })+$table[$interro][0]);
560 my @ligneo = @{ $ligne[$interro] };
566 foreach my $l (0.. $#ligneo ) {
567 my $val = sprintf("%.0f",4.*$ligneo[$l]*$points[$interro][$l]/100)/4;
568 print FILE
"; ",$val;
569 if($min[$k] > $val) {
572 if($max[$k] < $val) {
580 if((grep {$_ == $l} @pts) > 0) {
582 print FILE
"; $totalexo ";
584 if($min[$k] > $totalexo) {
585 $min[$k] = $totalexo;
587 if($max[$k] < $totalexo) {
588 $max[$k] = $totalexo;
590 $somme[$k] += $totalexo;
596 print FILE
"; $total ";
597 if($min[$k] > $total) {
600 if($max[$k] < $total) {
603 $somme[$k] += $total;
608 print FILE
"Moyenne";
609 for my $l (0.. $#somme) {
610 next if((grep {$_ == $l} @ign) > 0);
611 print FILE
"; ".sprintf("%.0f",4.*$somme[$l]/$nombre_eleves)/4;
615 for my $l (0.. $#min) {
616 next if((grep {$_ == $l} @ign) > 0);
617 print FILE
"; $min[$l]";
621 for my $l (0.. $#max) {
622 next if((grep {$_ == $l} @ign) > 0);
623 print FILE
"; $max[$l]";
625 #print FILE "Moyenne & \\multicolumn{",scalar(@{ $tablequestion[$interro] })+$table[$interro][0],"}{c||}{ }";
626 #my $moyenne = sprintf("%.0f",4.*$somme/$nombre_eleves)/4;
627 #print FILE " & $moyenne\\\\\n";
638 sub choisir_interro
() {
643 foreach $var ( @interros ) {
644 $message .= $i++.') '.$var."\n";
649 if(/\D/ || $var < 1 || $var > $i) {
650 print "Mauvaise entrée\n";
653 $interro_courante = $var-1;
661 open COL
, "| column";
663 my @eleves = sort sort_alpha
keys(%corr_nom);
664 foreach my $eleve_l (@eleves) {
665 my $eleve_lm = $eleve_l;
666 $eleve_lm =~ s/\n/ /;
667 print COL
$i++.") ".$eleve_lm."\n";
669 print COL
$i.") Annuler\n";
673 if(/\D/ || $var < 1 || $var > $i) {
674 print "Mauvaise entrée\n";
677 elsif( $var == $i ) {
680 $eleve = $eleves[$var-1];
683 my $notes_c = ${$corr_nom{$eleve}}[$interro_courante];
684 if($notes_c == "Absent") {
685 print "Absent à ".$interros[$interro_courante]."\n";
687 &entrer_notes
($interro_courante,$eleve);
694 my @actions = ("Ajouter une interro", "Ajouter un élève");
695 my @actions_f = (\
&ajout_interro
,
708 if(scalar(@interros)>0) {
709 $actions[2] = "Choisir une interro";
710 $actions[3] = "Éditer les notes d'un élève";
711 $actions[4] = "Définir les exercices de l'interro";
712 $actions[5] = "Définir le barême de l'interro";
713 $actions[6] = "Entrer les notes de l'interro";
714 $actions[7] = "Sauvegarder";
715 $actions[8] = "Exporter en LaTeX";
716 $actions[9] = "Exporter en CSV";
724 my @vart = ( @actions, 'Quitter' );
725 my $message = 'Interro sélectionnée : '.$interros[$interro_courante]."\n";
726 foreach $var ( @vart ) {
727 $message .= $i++.') '.$var."\n";
732 if(/\D/ || $var < 1 || $var > $i) {
733 print "Mauvaise entrée\n";
736 $action = $actions_f[$var-1];
739 &{$action}($interro_courante);