After lots of naive tries at an answer checker to handle student responses of different types, I realized that this task might be better handled before sending a student response to a single ANS command.
Problem setup: 3 points given
Task: enter a normal to plane they determine or NONE if they are collinear
student response to process: vector or string
current solution: (with $normal equal to cross product of suitable vectors and $abNorm being its norm)
if ($abNorm == 0) {
ANS( List('NONE') -> cmp() ;
$msg = 'comment about collinear points' ;
} else {
ANS( $normal -> cmp( parallel => 1 ) ) ;
$msg = 'scalar multiples are also correct' ;
}
Note: both of those ANS modes seem relatively quiet about chiding a student for entering the wrong type of info.
Late insight: this provides a method for having a relevant $msg within my SOLUTION.
failed attempts at a custom checker (with $ab being cross product of PQ and PR vectors)
[the first presumes a "lazy evaluation" of compound clauses]
ANS( $ab -> cmp( checker => sub {
my ( $correct , $student , $ansHash ) = @_ ;
return ( ( (norm($correct) == 0) && ($student == "NONE") )
|| ( $correct -> isParallel( $student ) ) ) ;
} ,
showCoordinateHints => 0 )
) ;
ANS( $ab -> cmp( parallel => 1 , checker => sub {
my ( $correct , $student , $ansHash ) = @_ ;
return $student == "none" if (norm($correct) == 0) ;
return ($correct == $student) ;
} ,
showCoordinateHints => 0 )
) ;