Archived
1
0

gen_grades: better resolution of names

This commit is contained in:
Mercier Pierre-Olivier 2013-11-18 22:28:10 +01:00
parent 555c922786
commit f02f484cb8

View File

@ -100,16 +100,14 @@ sub grades_generate
for my $login (@logins) for my $login (@logins)
{ {
my @files;
log DEBUG, "Generating grades for $login"; log DEBUG, "Generating grades for $login";
for my $dir (@trace_dirs) for my $dir (@trace_dirs)
{ {
log DEBUG, "Fetching identifiers from $dir"; log DEBUG, "Fetching identifiers from $dir";
my $tr_file = "$year/$project_id/traces/$dir/$login.xml"; # Looking for a group traces first
# Looking for a group traces?
if (! -f "$basedir/$tr_file")
{
for my $grp (@{ $groups->{groups} }) for my $grp (@{ $groups->{groups} })
{ {
my $this = 0; my $this = 0;
@ -125,26 +123,30 @@ sub grades_generate
} }
if ($this && $chief) if ($this && $chief)
{ {
$tr_file = "$year/$project_id/traces/$dir/".$chief->{login}.".xml"; if (-f "$basedir/$year/$project_id/traces/$dir/".$chief->{login}.".xml") {
log DEBUG, "Using group trace: chief is ".$chief->{login}; push @files, "$basedir/$year/$project_id/traces/$dir/".$chief->{login}.".xml";
}
last; last;
} }
} }
if (-f "$basedir/$year/$project_id/traces/$dir/$login.xml") {
push @files, "$basedir/$year/$project_id/traces/$dir/$login.xml";
}
} }
if (-f "$basedir/$tr_file") for my $path (@files)
{ {
open my $xmltrace, "<", "$basedir/$tr_file" or die "$tr_file: $!"; open my $xmltrace, "<", "$path" or die "$path: $!";
binmode $xmltrace; binmode $xmltrace;
my $trace = Trace->new(join '', <$xmltrace>); my $trace = Trace->new(join '', <$xmltrace>);
close $xmltrace; close $xmltrace;
log DEBUG, "Fill from file: $tr_file"; log DEBUG, "Fill from file: $path";
log TRACE, $trace->getIds($login); log TRACE, $trace->getIds($login);
$grading->fill($trace->getIds($login)); $grading->fill($trace->getIds($login));
} }
}
log DEBUG, "Computed grades: ".$grading->compute($login); log DEBUG, "Computed grades: ".$grading->compute($login);