#!/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]+)$/) {
print STDERR 0+keys %users, "\n";
print STDERR "Scanning teoretical results... ";
-if (open (EX, "../mop/score/teorie.txt")) {
+if (open (EX, "teorie.txt")) {
while (<EX>) {
chomp;
(/^$/ || /^#/) && next;
-f $tt || next;
print STDERR "$u/$t ";
open (X, $tt) || die "Unable to open $tt";
+ my %groups = ();
while (<X>) {
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;
}
print STDERR "OK\n";
if ($tex) {
- open HDR,"../mop/score/listina.hdr" or die "Cannot open file ../mop/score/listina.hdr with TeX template!";
+ open HDR,"listina.hdr" or die "Cannot open file listina.hdr with TeX template!";
while (<HDR>) {print; }
close HDR;
foreach $r (@table) { print join('&',@$r), "\\cr\n";}
- open FTR,"../mop/score/listina.ftr" or die "Cannot open file ../mop/score/listina.ftr with TeX template!";
+ open FTR,"listina.ftr" or die "Cannot open file listina.ftr with TeX template!";
while (<FTR>) {print; }
close FTR;
} else {