Skip to content

Commit

Permalink
parserMultiAnswer, check if user checker is a CODE ref.
Browse files Browse the repository at this point in the history
Check if any user defined checker is a subroutine, and give an error
message if not, instead of sliently overwriting it with a default checker.
  • Loading branch information
somiaj committed Nov 6, 2024
1 parent 2822f53 commit b3a4b01
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions macros/parsers/parserMultiAnswer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ sub cmp {
}
}

die "Your checker must be a subroutine." if defined($self->{checker}) && ref($self->{checker}) ne 'CODE';
unless (ref($self->{checker}) eq 'CODE') {
$self->{checker} = sub {
my ($correct, $student, $self, $ans) = @_;
Expand Down

0 comments on commit b3a4b01

Please sign in to comment.