## WeBWorK Main Forum

### number of attempts in scaffolded problems

by Joel Trussell -
Number of replies: 4
One of the things that students consistently ask for is have the number of attempts tied to each answer. Evidently, WebAssign has this feature, since the students use that as a comparison. I know this is not possible in Webwork for standard problems, but is it possible in scaffolded problems where the student cannot proceed to the next step until s/he completes the previous part?

### Re: number of attempts in scaffolded problems

by Michael Gage -
That's a good idea Joel, and it's probably doable with a little work.

Here is the outline of hack that might work.  The hard part is storing the number of attempts on each question or on each section.  Once that is done it is relatively easy for each answer evaluator, or for each switch controlling the availability of a section, to use the number of attempts to decide whether to allow that section to be open or for that answer evaluator to allow an answer to be evaluated.

The first idea would be to cache the number of attempts made so far in a hidden_answer variable, or perhaps in a cookie on the users machine.  Either one of those could be manipulated if the student wants to make the effort.

Storing an attempt count for each answer or even for each section, in the database would probably not be feasible.

There is a value $numOfAttempts available in each PG problem which tells how many attempts have been made so far. It is currently used to trigger things such as when Hints are shown. One could use that to shut down a section of a scaffolded question after a certain number of attempts and open the next one regardless of whether the questions in the first section were correct. See what you think of one of those ideas. The other observation is that these cutoffs for how many attempts are allowed would have to be hardcoded into the problem itself. Providing an interface which would allow the instructor to define the number of attempts for each question or section from the homework editor would probably not be a good idea anyway, and would be way to complicated to construct a reasonable user interface. That's my 2 cents. Does any of this respond to what you were interested in? Take care, Mike In reply to Michael Gage ### Re: number of attempts in scaffolded problems by Joel Trussell - Thanks - for some reason the email for your reply (and 3 others from the forum) was in my spam folder. I flagged it was not spam. and will be checking the filter more frequently. That is the reason for the delay in getting back. I'll give these a shot. I understand the$numOfAttempts  method.

I tried to look up "hidden_answers" but could not find much - AppletObjects.pl didn't speak in simple enough terms. Can you point me toward a how to use reference?

### Re: number of attempts in scaffolded problems

by Michael Gage -
The code is here:

You will have to assign a fake answer evaluator to the answer
to keep it from complaining. I think there is a no-op answer
evaluator in ASU.pl

since NAMED_ANS_RULE and NAMED_HIDDEN_ANS_RULE
behave the same except that the HIDDEN ans rule doesn't print.
(For debugging purposes use NAMED_ANS_RULE and you'll be able
to see what is happening.)

There is a the start of a better way to store persistent data
in PGcore.pm,  but until now there hasn't been a use for it so I
don't think it has been fully developed.

To retrieve the item use
$inputs_ref->{$name}

you can see what's available using

loadMacros("PGinfo.pl");
listVariables();
or listFormVariables()
will give you what you need.