Skip to content

Can't use messages of the form "Your ... is incorrect" in custom list checkers #1455

Description

@dlglin

Consider the following MWE:

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');

BEGIN_PGML
[_]{List(1,2)->cmp(list_checker => sub {return(0,"Your answer is incorrect");})}
END_PGML

ENDDOCUMENT();

This should display the feedback message "Your answer is incorrect" to the student when they submit, but it doesn't.

The culprit is:

pg/lib/Value/AnswerChecker.pm

Lines 1689 to 1693 in 1603ef5

if ($score == 0) {
my $i = 0;
while ($i <= $#errors) {
if ($errors[ $i++ ] =~ m/^Your .* is incorrect$/) { splice(@errors, --$i, 1) }
}

The problem is that this can match a custom error message set by a problem author, which is then silently deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions