gen_grades: better resolution of names
This commit is contained in:
parent
555c922786
commit
f02f484cb8
@ -100,52 +100,54 @@ sub grades_generate
|
||||
|
||||
for my $login (@logins)
|
||||
{
|
||||
my @files;
|
||||
|
||||
log DEBUG, "Generating grades for $login";
|
||||
for my $dir (@trace_dirs)
|
||||
{
|
||||
log DEBUG, "Fetching identifiers from $dir";
|
||||
|
||||
my $tr_file = "$year/$project_id/traces/$dir/$login.xml";
|
||||
|
||||
# Looking for a group traces?
|
||||
if (! -f "$basedir/$tr_file")
|
||||
# Looking for a group traces first
|
||||
for my $grp (@{ $groups->{groups} })
|
||||
{
|
||||
for my $grp (@{ $groups->{groups} })
|
||||
my $this = 0;
|
||||
my $chief;
|
||||
for my $member (@{ $grp->{stds} })
|
||||
{
|
||||
my $this = 0;
|
||||
my $chief;
|
||||
for my $member (@{ $grp->{stds} })
|
||||
if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief")
|
||||
{
|
||||
if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief")
|
||||
{
|
||||
$chief = $member;
|
||||
next;
|
||||
}
|
||||
$this = 1 if ($member->{login} eq $login);
|
||||
$chief = $member;
|
||||
next;
|
||||
}
|
||||
if ($this && $chief)
|
||||
{
|
||||
$tr_file = "$year/$project_id/traces/$dir/".$chief->{login}.".xml";
|
||||
log DEBUG, "Using group trace: chief is ".$chief->{login};
|
||||
last;
|
||||
$this = 1 if ($member->{login} eq $login);
|
||||
}
|
||||
if ($this && $chief)
|
||||
{
|
||||
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")
|
||||
{
|
||||
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));
|
||||
if (-f "$basedir/$year/$project_id/traces/$dir/$login.xml") {
|
||||
push @files, "$basedir/$year/$project_id/traces/$dir/$login.xml";
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
open my $xmlgrade, ">", "$basedir/$year/$project_id/grades/$login.xml" or croak "grades/$login.xml";
|
||||
|
Reference in New Issue
Block a user