WeBWorK Problems

Error messages shown on "Preview", not just "Submit"

Re: Error messages shown on "Preview", not just "Submit"

by Peter Selinger -
Number of replies: 0

Hi Michael,

amazing! That is exactly the information I needed, to solve this problem and hopefully some future ones. Thanks!

In my opinion, the direct use of Value->Error in answer checkers should be deprecated and replaced by two more specific functions: one to report type errors (which should be shown during previewing), and the other to give feedback on incorrect answers (which should not be shown during previewing). I have now implemented these in a private library and will use them in my problems:

# Report an ill-formed answer. This is used in answer checkers for messages that should 
# be shown when previewing, checking, or submitting the answer.
sub IllFormed ($) {
  my ($msg) = @_;
  Value->Error($msg);
}

# Provide feedback about an incorrect answer. This is used in answer checkers for messages 
# that should be shown when checking or submitting the answer, but not when previewing it.
sub Feedback ($) {
  my ($msg) = @_;
  unless (defined $inputs_ref->{previewAnswers}) {
    Value->Error($msg);
  }
}

Maybe something like this could be eventually added to the standard PG library. Thanks again for the valuable pointers!

-- Peter