X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mop%2Fscore%2Fmo-score-mop.sh;h=44944a589873c790ffa62b2e0979800a1c418100;hb=28c3aa2bd73958557fc5e5441bcb7a2a2ca1c375;hp=c20770652821d647c0b5eb7adfdda7c5c6d891c1;hpb=fc833e30d9b1315ffdeb780d5257e8e1bdafad43;p=moe.git diff --git a/mop/score/mo-score-mop.sh b/mop/score/mo-score-mop.sh index c207706..44944a5 100755 --- a/mop/score/mo-score-mop.sh +++ b/mop/score/mo-score-mop.sh @@ -1,5 +1,7 @@ #!/usr/bin/perl +use List::Util qw(min); + $tex = 0; $usage = "Usage: mo-score-mop [--tex] theoretical_tasks_nr praxis_tasks_nr task1 task2 ..."; while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) { @@ -26,7 +28,7 @@ close CT; print STDERR 0+keys %users, "\n"; print STDERR "Scanning teoretical results... "; -if (open (EX, "mop/teorie.txt")) { +if (open (EX, "teorie.txt")) { while () { chomp; (/^$/ || /^#/) && next; @@ -41,7 +43,7 @@ if (open (EX, "mop/teorie.txt")) { } close EX; print STDERR "OK\n"; -} else {die "none, cannot find file mop/teorie.txt!\n";} +} else {die "none, cannot find file teorie.txt!\n";} print STDERR "Scanning task results... "; $need_tasks = join("|", @ARGV); @@ -59,12 +61,23 @@ foreach $u (keys %users) { -f $tt || next; print STDERR "$u/$t "; open (X, $tt) || die "Unable to open $tt"; + my %groups = (); while () { chomp; - /^\S+ (-?\d+)/ || die "Parse error: $_"; - $tasks{$u}{$t_num} += $1; + my ($test, $pts) = /^(\S+) (-?\d+)/ or die "Parse error: $_"; + my $group = $test; + $group =~ s{\D}{}g; + if (defined $groups{$group}) { + $groups{$group} = min($groups{$group}, $pts); + } else { + $groups{$group} = $pts; + } } close X; + + for my $g (keys %groups) { + $tasks{$u}{$t_num} += $groups{$g}; + } } closedir D; } @@ -124,13 +137,13 @@ while ($i < @table) { print STDERR "OK\n"; if ($tex) { - open HDR,"mop/listina.hdr" or die "Cannot open file mop/listina.hdr with TeX template!"; + open HDR,"listina.hdr" or die "Cannot open file listina.hdr with TeX template!"; while () {print; } close HDR; foreach $r (@table) { print join('&',@$r), "\\cr\n";} - open FTR,"mop/listina.ftr" or die "Cannot open file mop/listina.ftr with TeX template!"; + open FTR,"listina.ftr" or die "Cannot open file listina.ftr with TeX template!"; while () {print; } close FTR; } else {