Archived
1
0
Fork 0

Fix grading condition resolving

This commit is contained in:
Mercier Pierre-Olivier 2013-09-24 19:36:58 +02:00
commit 237cafc34e

View file

@ -312,21 +312,16 @@ sub toString ($$$)
$parent->appendChild($point);
}
sub getValue ($$;$)
sub getValue ($$)
{
my $self = shift;
my $ids = shift;
my $justMatch = shift;
if ($self->{ref} && !$justMatch && !$ids->{ $self->{ref} } // 0) {
return 0;
}
elsif ($self->{value} eq "") {
return $ids->{ $self->{ref} } // 0;
}
else {
return $self->{value};
}
# Return the point node value if exists
return $self->{value} if ($self->{value} ne "");
# Else return pointed ref value
return $ids->{ $self->{ref} };
}
sub compute ($$$;$$)
@ -336,23 +331,23 @@ sub compute ($$$;$$)
my $ids = shift;
my $ret = undef;
if ((not $self->{ref}) || grep { $self->{ref} eq $_ } keys %$ids) {
$ret = $self->getValue( $ids );
}
my $result = (
# No condition on refs nor qversion?
not $self->{ref}
# Condition on refs
|| grep { $self->{ref} eq $_ } keys %$ids
);
if ($self->{not})
{
if ($ret) {
$ret = undef;
} else {
$ret = $self->getValue( $ids );
}
}
# Handel not
$result = !$result if ($self->{not});
# ret is valued only if all conditions passed
$ret = $self->getValue( $ids ) if ($result);
if ($main::debug)
{
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($self->{ref}//"").",\tvalue=".$self->getValue( $ids, 1 ).", got=".($ret // 0);
if ($ret) {
my $str = "not=".($self->{not}//0).", qversion".($self->{qversion}//"*").", ref=".($self->{ref}//"").",\tvalue=".($ids->{ $self->{ref}//"" } // "undef").", got=".($ret // 0);
if ($result) {
say GREEN, ">>>", RESET, " Matching point: ", $str;
} else {
say RED, " * ", RESET, " Skipped point: ", $str;
@ -362,5 +357,4 @@ sub compute ($$$;$$)
return $ret;
}
1;