We want to use Webwork to create a "competency quiz" for use in our math for elementary teachers course. For example, we want to require that students simplify

sqrt(8) - sqrt(2)

and the only acceptable answer to us is sqrt(2).

################

It's easy enough using contexts to do this, for example:

Context("Numeric");

Parser::Number::NoDecimals($context);

Context()->flags->set(reduceConstants=>0);

Context()->flags->set(reduceConstantFunctions=>0);

Context()->flags->set(formatStudentAnswer=>parsed);

Context()->operators->undefine('+','-');

$a = Formula("sqrt(8)");

$b = Formula("sqrt(2)");

$ans = Compute("sqrt(2)");

Context()->texStrings;

BEGIN_TEXT

Enter a value for \($a - $b\) \{ans_rule(35)\}

END_TEXT

Context()->normalStrings;

ANS($ans->cmp());

################

However, in a gateway quiz, if students hit the "preview" button, they are told that, for example "-" is not allowed in this context.

Is it possible for sqrt(8)-sqrt(2) to fail silently without highlighting the minus sign and warning students? We would like for them to not know at the preview stage that this would be marked incorrectly. The same question could be asked of decimals, etc.

Any advice?

Thanks!

Adam

ANS($ans->cmp->withPostFilter(sub { my $hash = shift; $hash->{ans_message} = "" if $hash->{ans_message} && $hash->{isPreview}; return $hash; }));which will prevent ANY message from being displayed for preview (including syntactic errors). You could look for specific messages to remove if you want to be more discerning, but then run the risk of letting some unwanted messages through.

Note that this requires you to modify the problems in order to have this effect, so you would need to have special versions for your quiz bank. (I would not want to see such problems filter into the NPL, in general.) Making it happen "automatically" for existing problems without modification would be more difficult.

Davide

I added the additional line:

$hash->{student_ans} = $hash->{original_student_ans} if $hash->{ans_message} && $hash->{isPreview};

so that the yellow syntax highlighting was also disabled. In fact, I think that we will just disable the preview display on essentially all of these questions.

I agree that problems with this modification should not be in the NPL. However, for the specific purpose that we are using these questions for we have a pedagogical need for removing these hints.

We actually will create now two sets of problems: practice problems WITH the hints and quiz questions without.

Thanks a bunch for your help!

Adam

You can, of course, put your post-filter in a macro file as

$noMessages = sub { ... };and then use

ANS($ans->cmp->withPostFilter($noMessages));in the problem, to make it easier.

I understand your pedagogical need, and was not suggesting that you not modify the problems, only that they not be distributed as part of the NPL, where people might not realize their special purpose.

Good luck with the quizzes.

Davide