Handel $LOGIN in grades
This commit is contained in:
parent
9160fa0fb2
commit
025e938354
2 changed files with 21 additions and 11 deletions
|
@ -143,13 +143,14 @@ sub toString ($)
|
||||||
return $doc->toString();
|
return $doc->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub compute ($)
|
sub compute ($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $login = shift;
|
||||||
my $sum = 0;
|
my $sum = 0;
|
||||||
|
|
||||||
for my $grade (@{ $self->{tree} }) {
|
for my $grade (@{ $self->{tree} }) {
|
||||||
my $tmp = $grade->compute($self->{operators}, $self->{ids});
|
my $tmp = $grade->compute($self->{operators}, $self->{ids}, $login);
|
||||||
$sum += $tmp if $tmp;
|
$sum += $tmp if $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,12 +160,13 @@ sub compute ($)
|
||||||
sub computeXML ($;$)
|
sub computeXML ($;$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $login = shift;
|
||||||
|
|
||||||
my $doc = XML::LibXML::Document->new('1.0');
|
my $doc = XML::LibXML::Document->new('1.0');
|
||||||
my $root = $doc->createElement("grading");
|
my $root = $doc->createElement("grading");
|
||||||
|
|
||||||
for my $grade (@{ $self->{tree} }) {
|
for my $grade (@{ $self->{tree} }) {
|
||||||
$grade->compute($self->{operators}, $self->{ids}, $doc, $root);
|
$grade->compute($self->{operators}, $self->{ids}, $login, $doc, $root);
|
||||||
}
|
}
|
||||||
|
|
||||||
$root->addChild( $doc->createAttribute("max", $self->{max}) );
|
$root->addChild( $doc->createAttribute("max", $self->{max}) );
|
||||||
|
@ -222,11 +224,12 @@ sub append ($@)
|
||||||
push @{ $self->{tree} }, @_;
|
push @{ $self->{tree} }, @_;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub compute ($$$;$$)
|
sub compute ($$$;$$$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $operators = shift;
|
my $operators = shift;
|
||||||
my $ids = shift;
|
my $ids = shift;
|
||||||
|
my $login = shift;
|
||||||
my $doc = shift;
|
my $doc = shift;
|
||||||
my $parent = shift;
|
my $parent = shift;
|
||||||
my @current = ();
|
my @current = ();
|
||||||
|
@ -324,18 +327,25 @@ sub getValue ($$)
|
||||||
return $ids->{ $self->{ref} };
|
return $ids->{ $self->{ref} };
|
||||||
}
|
}
|
||||||
|
|
||||||
sub compute ($$$;$$)
|
sub compute ($$$;$$$)
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $operators = shift;
|
my $operators = shift;
|
||||||
my $ids = shift;
|
my $ids = shift;
|
||||||
|
my $login = shift;
|
||||||
|
|
||||||
|
my $ref = $self->{ref};
|
||||||
|
if ($login && $ref) {
|
||||||
|
$ref =~ s/\$LOGIN/$login/;
|
||||||
|
}
|
||||||
|
|
||||||
my $ret = undef;
|
my $ret = undef;
|
||||||
|
|
||||||
my $result = (
|
my $result = (
|
||||||
# No condition on refs nor qversion?
|
# No condition on refs nor qversion?
|
||||||
! defined $self->{ref}
|
! defined $ref
|
||||||
# Condition on refs
|
# Condition on refs
|
||||||
|| grep { $self->{ref} eq $_ } keys %$ids
|
|| grep { $ref eq $_ } keys %$ids
|
||||||
);
|
);
|
||||||
|
|
||||||
# Handel not
|
# Handel not
|
||||||
|
@ -346,11 +356,11 @@ sub compute ($$$;$$)
|
||||||
|
|
||||||
if ($main::debug)
|
if ($main::debug)
|
||||||
{
|
{
|
||||||
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($self->{ref}//"").",\tvalue=".($ids->{ $self->{ref}//"" } // "undef").", got=".($ret // 0);
|
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($ref//"").",\tvalue=".($ids->{ $ref//"" } // "undef").", ";
|
||||||
if ($result) {
|
if ($result) {
|
||||||
say GREEN, ">>>", RESET, " Matching point: ", $str;
|
say GREEN, ">>>", RESET, " Matching point: ", $str, BOLD, "got=".($ret // 0), RESET;
|
||||||
} else {
|
} else {
|
||||||
say RED, " * ", RESET, " Skipped point: ", $str;
|
say RED, " * ", RESET, " Skipped point: ", $str, BOLD, "got=".($ret // 0), RESET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ sub grades_generate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log DEBUG, "Computed grades: ".$grading->compute();
|
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";
|
||||||
binmode $xmlgrade;
|
binmode $xmlgrade;
|
||||||
|
|
Reference in a new issue