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,52 +100,54 @@ 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
for my $grp (@{ $groups->{groups} })
# Looking for a group traces?
if (! -f "$basedir/$tr_file")
{ {
for my $grp (@{ $groups->{groups} }) my $this = 0;
my $chief;
for my $member (@{ $grp->{stds} })
{ {
my $this = 0; if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief")
my $chief;
for my $member (@{ $grp->{stds} })
{ {
if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief") $chief = $member;
{ next;
$chief = $member;
next;
}
$this = 1 if ($member->{login} eq $login);
} }
if ($this && $chief) $this = 1 if ($member->{login} eq $login);
{ }
$tr_file = "$year/$project_id/traces/$dir/".$chief->{login}.".xml"; if ($this && $chief)
log DEBUG, "Using group trace: chief is ".$chief->{login}; {
last; if (-f "$basedir/$year/$project_id/traces/$dir/".$chief->{login}.".xml") {
push @files, "$basedir/$year/$project_id/traces/$dir/".$chief->{login}.".xml";
} }
last;
} }
} }
if (-f "$basedir/$tr_file") if (-f "$basedir/$year/$project_id/traces/$dir/$login.xml") {
{ push @files, "$basedir/$year/$project_id/traces/$dir/$login.xml";
open my $xmltrace, "<", "$basedir/$tr_file" or die "$tr_file: $!";
binmode $xmltrace;
my $trace = Trace->new(join '', <$xmltrace>);
close $xmltrace;
log DEBUG, "Fill from file: $tr_file";
log TRACE, $trace->getIds($login);
$grading->fill($trace->getIds($login));
} }
} }
for my $path (@files)
{
open my $xmltrace, "<", "$path" or die "$path: $!";
binmode $xmltrace;
my $trace = Trace->new(join '', <$xmltrace>);
close $xmltrace;
log DEBUG, "Fill from file: $path";
log TRACE, $trace->getIds($login);
$grading->fill($trace->getIds($login));
}
log DEBUG, "Computed grades: ".$grading->compute($login); log DEBUG, "Computed grades: ".$grading->compute($login);
open my $xmlgrade, ">", "$basedir/$year/$project_id/grades/$login.xml" or croak "grades/$login.xml"; open my $xmlgrade, ">", "$basedir/$year/$project_id/grades/$login.xml" or croak "grades/$login.xml";