WeBWorK Problems

#showHint variable behaviour

#showHint variable behaviour

by Cindy Loten -
Number of replies: 3

I have the following snippet of code in a problem, expecting that the hint will be shown after 2 attempts by the student

$showHint = 2; #webwork seems to add 1!

BEGIN_PGML
If you don't get this in [$showHint] tries, you can get a hint.
END_PGML

BEGIN_PGML_HINT
Do you need to produce one example or do you need to prove something for all possible values?  Read the definitions carefully!
END_PGML_HINT

However, the result is

The hint is shown after 3 attempts, not 2.  I found reference to this behaviour in https://webwork.maa.org/moodle/mod/forum/discuss.php?d=3983 

I can `fix' this by doing the following, but that's not really dealing with the issue, and might cause problems later.  Any tips appreciated!

$showHint = 1; #webwork seems to add 1!

BEGIN_PGML
If you don't get this in [$showHint +1] tries, you can get a hint.
END_PGML

In reply to Cindy Loten

Re: #showHint variable behaviour

by Alex Jordan -

It looks like your WW server might be version 2.17. Starting with version 2.18, $showHint is gone. Instead of using a variable like that which could be set in the PG problem, you will set this value for each problem as it is assigned in an exercise set. Or rely on course-wide or site-wide defaults. This is similar to the weight that can be assigned to each problem. So the idea is this is something that is not a property of the problem itself, but a property of the problem in the context of the assignment it is being used in.

For 2.17 and earlier, you will just have to be aware of this and adjust in the way you have described. If the student is seeing the problem for their 3rd attempt, then so far they have used 2 attempts, and so they have not yet exceeded the value of $showHint. It's not intuitive, but that is how it works.