Add average in cvs
This commit is contained in:
parent
e2ba0a5e38
commit
bedb084ffe
@ -31,6 +31,7 @@ sub process
|
|||||||
|
|
||||||
my %grades;
|
my %grades;
|
||||||
my @headers;
|
my @headers;
|
||||||
|
my @averages;
|
||||||
|
|
||||||
opendir(my $dh, "$basedir/$year/$project_id/grades/") or croak "can't opendir $basedir/$year/$project_id/grades/: $!";
|
opendir(my $dh, "$basedir/$year/$project_id/grades/") or croak "can't opendir $basedir/$year/$project_id/grades/: $!";
|
||||||
for my $gfile (grep { ( ! /^\./ ) && -f "$basedir/$year/$project_id/grades/$_" } readdir($dh))
|
for my $gfile (grep { ( ! /^\./ ) && -f "$basedir/$year/$project_id/grades/$_" } readdir($dh))
|
||||||
@ -52,6 +53,7 @@ sub process
|
|||||||
if ($ugrades[$i] eq $grade->getAttribute("name"))
|
if ($ugrades[$i] eq $grade->getAttribute("name"))
|
||||||
{
|
{
|
||||||
$ugrades[$i] = $grade->getAttribute("value");
|
$ugrades[$i] = $grade->getAttribute("value");
|
||||||
|
$averages[$i] += $grade->getAttribute("value");
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,6 +62,7 @@ sub process
|
|||||||
{
|
{
|
||||||
push @headers, $grade->getAttribute("name");
|
push @headers, $grade->getAttribute("name");
|
||||||
push @ugrades, $grade->getAttribute("value");
|
push @ugrades, $grade->getAttribute("value");
|
||||||
|
push @averages, $grade->getAttribute("value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,13 +73,15 @@ sub process
|
|||||||
# Print CSV
|
# Print CSV
|
||||||
my $out = "login";
|
my $out = "login";
|
||||||
|
|
||||||
for my $header (@headers) {
|
foreach my $header (@headers) {
|
||||||
$out .= ",$header";
|
$out .= ",$header";
|
||||||
}
|
}
|
||||||
$out .= "\n";
|
$out .= "\n";
|
||||||
|
|
||||||
for my $login (keys %grades)
|
my $nb = 0;
|
||||||
|
foreach my $login (keys %grades)
|
||||||
{
|
{
|
||||||
|
$nb += 1;
|
||||||
$out .= "$login";
|
$out .= "$login";
|
||||||
my @ugrades = @{ $grades{$login} };
|
my @ugrades = @{ $grades{$login} };
|
||||||
for my $header (@headers)
|
for my $header (@headers)
|
||||||
@ -92,6 +97,13 @@ sub process
|
|||||||
$out .= "\n";
|
$out .= "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$out .= "Average";
|
||||||
|
foreach my $average (@averages)
|
||||||
|
{
|
||||||
|
$out .= ",".($average / $nb);
|
||||||
|
}
|
||||||
|
$out .= "\n";
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user