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