]>
Commit | Line | Data |
---|---|---|
5172ecf8 IB |
1 | #!/usr/local/bin/perl |
2 | # The MIT License (MIT) | |
3 | # | |
4 | # Copyright (c) 2011-2015 Ismaël Bouya http://www.normalesup.org/~bouya/ | |
5 | # | |
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: | |
12 | # | |
13 | # The above copyright notice and this permission notice shall be included in | |
14 | # all copies or substantial portions of the Software. | |
15 | # | |
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 | |
22 | # THE SOFTWARE. | |
23 | ||
2d8938f6 IB |
24 | |
25 | # Feel like tipping/donating? https://www.immae.eu/licenses_and_tipping | |
26 | ||
5172ecf8 IB |
27 | use Switch; |
28 | use strict; | |
29 | ||
30 | my @table = (); | |
31 | my @interros = (); | |
32 | my @tablequestion = (); | |
33 | my @points = (); | |
34 | my %corr_nom ; | |
35 | my $interro_courante = 0; | |
36 | my $fichier = "notes.dat"; | |
37 | if($#ARGV == 0) { | |
38 | $fichier = $ARGV[0]; | |
39 | } | |
40 | ||
41 | sub ajout_interro { | |
42 | print "Nom de l'interrogation\n"; | |
43 | my $interro = <STDIN>; | |
44 | chomp($interro); | |
45 | push(@interros,$interro); | |
46 | push(@tablequestion,[]); | |
47 | push(@table,[]); | |
48 | push(@points,[]); | |
49 | foreach my $key (keys %corr_nom) { | |
50 | push(@{ $corr_nom{$key} }, "Absent" ); | |
51 | } | |
52 | } | |
53 | ||
54 | sub ajout_eleve { | |
55 | print "Nom\n"; | |
56 | my $nom = <STDIN>; | |
57 | chomp($nom); | |
58 | print "Prénom\n"; | |
59 | my $prenom = <STDIN>; | |
60 | chomp($prenom); | |
61 | $corr_nom{$prenom."\n".$nom} = (); | |
62 | for my $i (0..$#interros) { | |
63 | push(@{ $corr_nom{$prenom."\n".$nom} }, "Absent" ); | |
64 | } | |
65 | } | |
66 | ||
67 | sub definir_exos { | |
68 | my $interro = shift; | |
69 | my $nbexos = "a"; | |
70 | while($nbexos =~ m/\D/) { | |
71 | print "Nombre d'exercices\n"; | |
72 | $nbexos = <STDIN>; | |
73 | chomp($nbexos); | |
74 | if($nbexos =~ /\D/) { | |
75 | print "Mauvaise entrée\n"; | |
76 | } | |
77 | } | |
78 | if($nbexos == "") { | |
79 | $nbexos = 0; | |
80 | } | |
81 | push(@{ $table[$interro] }, $nbexos); | |
82 | if($nbexos == 0) { | |
83 | push(@{ $tablequestion[$interro] }, ""); | |
84 | } | |
85 | for(my $i = 1; $i <= $nbexos; $i++) { | |
86 | my $questions = "a"; | |
87 | while($questions =~ m/\D/) { | |
88 | print "Nombre de questions dans l'exercice ",$i,"\n"; | |
89 | $questions = <STDIN>; | |
90 | chomp($questions); | |
91 | if($questions =~ /\D/) { | |
92 | print "Mauvaise entrée\n"; | |
93 | } | |
94 | } | |
95 | if($questions eq "") { | |
96 | $questions = 0; | |
97 | } | |
98 | if($questions > 1) { | |
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>; | |
105 | chomp($ssquestions); | |
106 | if($ssquestions =~ /\D/) { | |
107 | print "Mauvaise entrée\n"; | |
108 | } | |
109 | } | |
110 | if($ssquestions eq "") { | |
111 | $ssquestions = 0; | |
112 | } | |
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); | |
117 | } | |
118 | } | |
119 | else { | |
120 | push(@{ $tablequestion[$interro] }, $i.".".$j); | |
121 | } | |
122 | } | |
123 | } | |
124 | else { | |
125 | push(@{ $tablequestion[$interro] }, $i); | |
126 | } | |
127 | } | |
128 | } | |
129 | ||
130 | sub entrer_notes { | |
131 | my $interro = shift; | |
132 | my $eleve = shift; | |
133 | my @boucle; | |
134 | if($eleve) { | |
135 | @boucle = ($eleve); | |
136 | } | |
137 | else { | |
138 | @boucle = sort sort_alpha keys %corr_nom; | |
139 | } | |
140 | foreach my $key (@boucle) { | |
141 | my $keyt = $key; | |
142 | $keyt =~ s/\n/ /; | |
143 | print $keyt." (mettre A pour indiquer une absence)\n"; | |
144 | my @int; | |
145 | if(ref($corr_nom{$key}[$interro]) eq 'ARRAY') { | |
146 | @int = @{$corr_nom{$key}[$interro]}; | |
147 | } | |
148 | $corr_nom{$key}[$interro] = (); | |
149 | Interro: for my $i (0..$#{$tablequestion[$interro]}) { | |
150 | my $pourcentage = "a"; | |
151 | my $def = 0; | |
152 | if(!@int && $i == 0) { | |
153 | $def = "A"; | |
154 | } | |
155 | if(scalar(@int) > 0) { | |
156 | $def = $int[$i]; | |
157 | } | |
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"; | |
161 | } | |
162 | else { | |
163 | print "Pourcentage pour l'exercice ".$tablequestion[$interro][$i]." [".$def."]\n"; | |
164 | } | |
165 | $pourcentage = <STDIN>; | |
166 | chomp($pourcentage); | |
167 | if($pourcentage eq "") { | |
168 | $pourcentage = $def; | |
169 | } | |
170 | if($pourcentage =~ m/^a$/i) { | |
171 | $corr_nom{$key}[$interro] = "Absent"; | |
172 | last Interro; | |
173 | } | |
174 | if($pourcentage =~ /\D/ || $pourcentage > 100) { | |
175 | print "Il faut un pourcentage entre 0 et 100\n"; | |
176 | } | |
177 | } | |
178 | push(@{ $corr_nom{$key}[$interro] },$pourcentage); | |
179 | } | |
180 | } | |
181 | } | |
182 | ||
183 | sub entrer_bareme { | |
184 | my $interro = shift; | |
185 | foreach my $nomquestion ( @{ $tablequestion[$interro] } ) { | |
186 | my $point = "a"; | |
187 | while($point =~ /[^\d\.]/) { | |
188 | if($nomquestion =~ m/\D/ ) { | |
189 | print "Points pour la question ".$nomquestion."\n"; | |
190 | } | |
191 | else { | |
192 | print "Points pour l'exercice ".$nomquestion."\n"; | |
193 | } | |
194 | $point = <STDIN>; | |
195 | chomp($point); | |
196 | if($point =~ /[^\d\.]/) { | |
197 | print "Il faut donner un nombre de points\n"; | |
198 | } | |
199 | } | |
200 | if($point eq "") { | |
201 | $point = 0; | |
202 | } | |
203 | push(@{ $points[$interro] },$point); | |
204 | } | |
205 | } | |
206 | ||
207 | sub sauver { | |
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"; | |
214 | } | |
215 | print FILE "\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") { | |
220 | print FILE "! \n"; | |
221 | } | |
222 | else { | |
223 | print FILE "* @$lig\n"; | |
224 | } | |
225 | } | |
226 | } | |
227 | print FILE "\n"; | |
228 | close FILE; | |
229 | } | |
230 | ||
231 | sub charger { | |
232 | open FILE, $fichier; | |
233 | while(my $int = <FILE>) { | |
234 | if($int eq "\n") { last }; | |
235 | chomp($int); | |
236 | push(@interros,$int); | |
237 | $int = <FILE>; | |
238 | chomp($int); | |
239 | push(@table, [ split(/ /, $int) ] ); | |
240 | $int = <FILE>; | |
241 | chomp($int); | |
242 | push(@tablequestion, [ split(/ /, $int) ] ); | |
243 | $int = <FILE>; | |
244 | chomp($int); | |
245 | push(@points, [ split(/ /, $int) ] ); | |
246 | ||
247 | } | |
248 | my $int = <FILE>; | |
249 | while(1) { | |
250 | if($int eq "\n") { last }; | |
251 | my $intn = <FILE>; | |
252 | chomp($intn); | |
253 | my $key = $int.$intn; | |
254 | $corr_nom{$key} = (); | |
255 | while($intn = <FILE>) { | |
256 | if($intn =~ m/^\*/) { | |
257 | chomp($intn); | |
258 | push(@{ $corr_nom{$key} }, [ split(/ /, substr($intn,2)) ] ); | |
259 | } | |
260 | elsif($intn =~ m/^!/) { | |
261 | push(@{ $corr_nom{$key} }, "Absent" ); | |
262 | } | |
263 | else { | |
264 | $int = $intn; | |
265 | last; | |
266 | } | |
267 | } | |
268 | } | |
269 | close FILE; | |
270 | } | |
271 | ||
272 | sub sort_alpha { | |
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]; | |
276 | } | |
277 | ||
278 | sub export_latex { | |
279 | print "Fichier ?\n"; | |
280 | my $f_export = <STDIN>; | |
281 | chomp($f_export); | |
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)); | |
294 | print FILE "|c|}\n"; | |
295 | my @ign = (); | |
296 | my @pts = (); | |
297 | my @max = (); | |
298 | my @min = (); | |
299 | my @somme = (); | |
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 "; | |
307 | } | |
308 | else { | |
309 | print FILE "& \\multicolumn{",scalar(@b)+1,"}{c|}{Exercice ",$i,"} "; | |
310 | } | |
311 | } | |
312 | print FILE "& Total "; | |
313 | print FILE "\\\\\n"; | |
314 | print FILE "\\hline\n\t"; | |
315 | my $rank = -1; | |
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] }); | |
320 | $rank += scalar(@c); | |
321 | if(scalar(@c) == 1) { | |
322 | print FILE "& $j) "; | |
323 | } | |
324 | elsif(scalar(@c) > 0) { | |
325 | print FILE "& \\multicolumn{",scalar(@c),"}{c|}{",$j,")} "; | |
326 | } | |
327 | elsif($j == 1) { | |
328 | $rank +=1; | |
329 | push(@ign,$rank+$i-1); | |
330 | #print FILE "& "; | |
331 | } | |
332 | } | |
333 | print FILE "& Total "; | |
334 | push(@pts,$rank); | |
335 | } | |
336 | print FILE "& \\\\\n"; | |
337 | } | |
338 | print FILE "\\hline\n\t"; | |
339 | print FILE "points "; | |
340 | my $totalexo = 0; | |
341 | my $total = 0; | |
342 | my $nq = 0; | |
343 | for my $i (0.. $#{ $points[$interro] }) { | |
344 | print FILE "& $points[$interro][$i] "; | |
345 | push(@min,$points[$interro][$i]); | |
346 | push(@max,0); | |
347 | push(@somme,0); | |
348 | $totalexo += $points[$interro][$i]; | |
349 | $total += $points[$interro][$i]; | |
350 | $nq++; | |
351 | if((grep {$_ == $i} @pts) > 0) { | |
352 | if($nq > 1) { | |
353 | print FILE "& $totalexo "; | |
354 | } | |
355 | push(@min,$totalexo); | |
356 | push(@max,0); | |
357 | push(@somme,0); | |
358 | $totalexo = 0; | |
359 | $nq = 0; | |
360 | } | |
361 | } | |
362 | print FILE "& $total "; | |
363 | push(@min,$total); | |
364 | push(@max,0); | |
365 | push(@somme,0); | |
366 | print FILE "\\\\\n"; | |
367 | print FILE "\\hline\n\t"; | |
368 | print FILE "\\hline\n\t"; | |
369 | ||
370 | my @sortednotes = sort sort_alpha (keys %corr_nom); | |
371 | #print "@sortednotes"; | |
372 | #my $somme = 0; | |
373 | my $nombre_eleves = 0; | |
374 | for my $i (0.. $#sortednotes) { | |
375 | my $np = $sortednotes[$i]; | |
376 | $np =~ s/\n/ /; | |
377 | print FILE $np; | |
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}"; | |
381 | } | |
382 | else { | |
383 | my @ligneo = @{ $ligne[$interro] }; | |
384 | my $totalexo = 0; | |
385 | my $total = 0; | |
386 | $nombre_eleves++; | |
387 | my $k = 0; | |
388 | my $nq = 0; | |
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) { | |
393 | $min[$k] = $val; | |
394 | } | |
395 | if($max[$k] < $val) { | |
396 | $max[$k] = $val; | |
397 | } | |
398 | $somme[$k] += $val; | |
399 | $k++; | |
400 | $nq++; | |
401 | $totalexo += $val; | |
402 | $total += $val; | |
403 | if((grep {$_ == $l} @pts) > 0) { | |
404 | if($min[$k] > $totalexo) { | |
405 | $min[$k] = $totalexo; | |
406 | } | |
407 | if($max[$k] < $totalexo) { | |
408 | $max[$k] = $totalexo; | |
409 | } | |
410 | $somme[$k] += $totalexo; | |
411 | if($nq > 1) { | |
412 | print FILE "& $totalexo "; | |
413 | } | |
414 | $k++; | |
415 | $totalexo = 0; | |
416 | $nq = 0; | |
417 | } | |
418 | } | |
419 | print FILE "& $total "; | |
420 | if($min[$k] > $total) { | |
421 | $min[$k] = $total; | |
422 | } | |
423 | if($max[$k] < $total) { | |
424 | $max[$k] = $total; | |
425 | } | |
426 | $somme[$k] += $total; | |
427 | $k++; | |
428 | } | |
429 | print FILE "\\\\\n"; | |
430 | print FILE "\\hline\n\t"; | |
431 | } | |
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; | |
437 | } | |
438 | print FILE "\\\\\n"; | |
439 | print FILE "\\hline\n\t"; | |
440 | print FILE "Min"; | |
441 | for my $l (0.. $#min) { | |
442 | next if((grep {$_ == $l} @ign) > 0); | |
443 | print FILE "& $min[$l]"; | |
444 | } | |
445 | print FILE "\\\\\n"; | |
446 | print FILE "\\hline\n\t"; | |
447 | print FILE "Max"; | |
448 | for my $l (0.. $#max) { | |
449 | next if((grep {$_ == $l} @ign) > 0); | |
450 | print FILE "& $max[$l]"; | |
451 | } | |
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"; | |
455 | print FILE "\\\\\n"; | |
456 | print FILE "\\hline\n\t"; | |
457 | print FILE "\\end{tabular}\n"; | |
458 | print FILE "\\vfill\n"; | |
459 | print FILE "\\newpage\n"; | |
460 | } | |
461 | print FILE "\\end{document}\n"; | |
462 | close FILE; | |
463 | } | |
464 | ||
465 | sub export_csv { | |
466 | my $interro = shift; | |
467 | print "Fichier ?\n"; | |
468 | my $f_export = <STDIN>; | |
469 | chomp($f_export); | |
470 | if($f_export eq "") { return 0 }; | |
471 | open FILE, ">".$f_export; | |
472 | for my $interro (0..$#table) { | |
473 | print FILE "; ".$interros[$interro]."\n"; | |
474 | my @pts = (); | |
475 | my @ign = (); | |
476 | my @max = (); | |
477 | my @min = (); | |
478 | my @somme = (); | |
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 "; | |
484 | } | |
485 | else { | |
486 | print FILE "; Exercice $i","; "x scalar(@b); | |
487 | } | |
488 | } | |
489 | print FILE "; Total \n"; | |
490 | my $rank = -1; | |
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] }); | |
495 | $rank += scalar(@c); | |
496 | if(scalar(@c) == 1) { | |
497 | print FILE "; $j) "; | |
498 | } | |
499 | elsif(scalar(@c) > 0) { | |
500 | my $char = "a"; | |
501 | for my $num (0..$#c) { | |
502 | print FILE "; $j) ".$char.") "; | |
503 | $char++; | |
504 | } | |
505 | #print FILE "; $j) ","; "x (scalar(@c)-1); | |
506 | } | |
507 | elsif($j == 1) { | |
508 | $rank += 1; | |
509 | push(@ign,$rank+$i-1); | |
510 | #print FILE "; "; | |
511 | } | |
512 | } | |
513 | print FILE "; Total "; | |
514 | push(@pts,$rank); | |
515 | } | |
516 | print FILE "; \n"; | |
517 | } | |
518 | print FILE "points "; | |
519 | my $totalexo = 0; | |
520 | my $total = 0; | |
521 | my $nq = 0; | |
522 | for my $i (0.. $#{ $points[$interro] }) { | |
523 | print FILE "; $points[$interro][$i] "; | |
524 | push(@min,$points[$interro][$i]); | |
525 | push(@max,0); | |
526 | push(@somme,0); | |
527 | $totalexo += $points[$interro][$i]; | |
528 | $total += $points[$interro][$i]; | |
529 | $nq++; | |
530 | if((grep {$_ == $i} @pts) > 0) { | |
531 | if($nq > 1) { | |
532 | print FILE "; $totalexo "; | |
533 | } | |
534 | push(@min,$totalexo); | |
535 | push(@max,0); | |
536 | push(@somme,0); | |
537 | $totalexo = 0; | |
538 | $nq = 0; | |
539 | } | |
540 | } | |
541 | print FILE "; $total "; | |
542 | push(@min,$total); | |
543 | push(@max,0); | |
544 | push(@somme,0); | |
545 | print FILE "\n"; | |
546 | ||
547 | my @sortednotes = sort sort_alpha (keys %corr_nom); | |
548 | #print "@sortednotes"; | |
549 | #my $somme = 0; | |
550 | my $nombre_eleves = 0; | |
551 | for my $i (0.. $#sortednotes) { | |
552 | my $np = $sortednotes[$i]; | |
553 | $np =~ s/\n/ /; | |
554 | print FILE $np; | |
555 | my @ligne = @{ $corr_nom{$sortednotes[$i]} }; | |
556 | if($ligne[$interro] eq "Absent") { | |
557 | print FILE "; Absent","; "x (scalar(@{ $tablequestion[$interro] })+$table[$interro][0]); | |
558 | } | |
559 | else { | |
560 | my @ligneo = @{ $ligne[$interro] }; | |
561 | my $totalexo = 0; | |
562 | my $total = 0; | |
563 | $nombre_eleves++; | |
564 | my $k = 0; | |
565 | my $nq = 0; | |
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) { | |
570 | $min[$k] = $val; | |
571 | } | |
572 | if($max[$k] < $val) { | |
573 | $max[$k] = $val; | |
574 | } | |
575 | $somme[$k] += $val; | |
576 | $k++; | |
577 | $totalexo += $val; | |
578 | $total += $val; | |
579 | $nq++; | |
580 | if((grep {$_ == $l} @pts) > 0) { | |
581 | if($nq > 1) { | |
582 | print FILE "; $totalexo "; | |
583 | } | |
584 | if($min[$k] > $totalexo) { | |
585 | $min[$k] = $totalexo; | |
586 | } | |
587 | if($max[$k] < $totalexo) { | |
588 | $max[$k] = $totalexo; | |
589 | } | |
590 | $somme[$k] += $totalexo; | |
591 | $k++; | |
592 | $totalexo = 0; | |
593 | $nq = 0; | |
594 | } | |
595 | } | |
596 | print FILE "; $total "; | |
597 | if($min[$k] > $total) { | |
598 | $min[$k] = $total; | |
599 | } | |
600 | if($max[$k] < $total) { | |
601 | $max[$k] = $total; | |
602 | } | |
603 | $somme[$k] += $total; | |
604 | $k++; | |
605 | } | |
606 | print FILE "\n"; | |
607 | } | |
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; | |
612 | } | |
613 | print FILE "\n"; | |
614 | print FILE "Min"; | |
615 | for my $l (0.. $#min) { | |
616 | next if((grep {$_ == $l} @ign) > 0); | |
617 | print FILE "; $min[$l]"; | |
618 | } | |
619 | print FILE "\n"; | |
620 | print FILE "Max"; | |
621 | for my $l (0.. $#max) { | |
622 | next if((grep {$_ == $l} @ign) > 0); | |
623 | print FILE "; $max[$l]"; | |
624 | } | |
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"; | |
628 | print FILE "\n"; | |
629 | print FILE "\n\n\n"; | |
630 | } | |
631 | close FILE; | |
632 | } | |
633 | ||
634 | if(-e $fichier) { | |
635 | &charger(); | |
636 | } | |
637 | ||
638 | sub choisir_interro() { | |
639 | while(1) { | |
640 | my $i = 1; | |
641 | my $var; | |
642 | my $message = ''; | |
643 | foreach $var ( @interros ) { | |
644 | $message .= $i++.') '.$var."\n"; | |
645 | } | |
646 | print $message; | |
647 | $var = <STDIN>; | |
648 | chop($var); | |
649 | if(/\D/ || $var < 1 || $var > $i) { | |
650 | print "Mauvaise entrée\n"; | |
651 | next; | |
652 | } | |
653 | $interro_courante = $var-1; | |
654 | last; | |
655 | } | |
656 | } | |
657 | ||
658 | sub editer_eleve() { | |
659 | my $eleve; | |
660 | while(1) { | |
661 | open COL, "| column"; | |
662 | my $i = 1; | |
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"; | |
668 | } | |
669 | print COL $i.") Annuler\n"; | |
670 | close COL; | |
671 | my $var = <STDIN>; | |
672 | chop($var); | |
673 | if(/\D/ || $var < 1 || $var > $i) { | |
674 | print "Mauvaise entrée\n"; | |
675 | next; | |
676 | } | |
677 | elsif( $var == $i ) { | |
678 | return; | |
679 | } | |
680 | $eleve = $eleves[$var-1]; | |
681 | last; | |
682 | } | |
683 | my $notes_c = ${$corr_nom{$eleve}}[$interro_courante]; | |
684 | if($notes_c == "Absent") { | |
685 | print "Absent à ".$interros[$interro_courante]."\n"; | |
686 | } | |
687 | &entrer_notes($interro_courante,$eleve); | |
688 | } | |
689 | ||
690 | sub quitter() { | |
691 | exit 0; | |
692 | } | |
693 | ||
694 | my @actions = ("Ajouter une interro", "Ajouter un élève"); | |
695 | my @actions_f = (\&ajout_interro, | |
696 | \&ajout_eleve, | |
697 | \&choisir_interro, | |
698 | \&editer_eleve, | |
699 | \&definir_exos, | |
700 | \&entrer_bareme, | |
701 | \&entrer_notes, | |
702 | \&sauver, | |
703 | \&export_latex, | |
704 | \&export_csv, | |
705 | \&quitter, | |
706 | ); | |
707 | while(1) { | |
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"; | |
717 | } | |
718 | ||
719 | ||
720 | my $action; | |
721 | while(1) { | |
722 | my $i = 1; | |
723 | my $var; | |
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"; | |
728 | } | |
729 | print $message; | |
730 | $var = <STDIN>; | |
731 | chop($var); | |
732 | if(/\D/ || $var < 1 || $var > $i) { | |
733 | print "Mauvaise entrée\n"; | |
734 | next; | |
735 | } | |
736 | $action = $actions_f[$var-1]; | |
737 | last; | |
738 | } | |
739 | &{$action}($interro_courante); | |
740 | } | |
741 | ||
742 | #&export_latex(); |