## WeBWorK Problems

### Hints in different sections of a scaffold problem

by Larry Riddle -
Number of replies: 5

I am writing a problem using scaffolding. I would like to have a unique hint in the two sections. When I test the problem by logging in as a student, the first section works fine with the hint only appearing after the first attempt. But then when I correctly answer section 1 and open the second section, the hint for that section is already visible while I would again like it to remain unavailable until the student has tried answering section two at least once.

I am using $showHint = 0$ (this shows the hint after the *first* attempt, not immediately). I put it inside section 1 of the scaffolding hoping that that the command would apply only to that section, but that does not seem to be the case and it seems to carry over into section 2.

Is it possible to have hints in different sections whose behavior on when to be shown to students is independent of each other?

In reply to Larry Riddle

### Re: Hints in different sections of a scaffold problem

by Larry Riddle -
Here is a short example of what I'm trying to achieve. You need to view this as a student since an instructor can always see the hints.

If you enter an incorrect answer for Part 1, the first hint will appear. Now enter the correct answer so Part 2 will become active. Open Part 2 and the hint will already be showing.

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"scaffold.pl",
"PGML.pl",
);

TEXT(beginproblem());
BEGIN_PGML
Click on Part 1 to start.
END_PGML

# The scaffold
Scaffold::Begin(open_first_section => 0);
Section::Begin("Part 1",
is_open => correct_or_first_incorrect);
$showHint = 0; BEGIN_PGML 1 + 1 = [____]{2} END_PGML BEGIN_PGML_HINT This is the first hint. END_PGML_HINT Section::End(); Section::Begin("Part 2", can_open => when_previous_correct, is_open => correct_or_first_incorrect); BEGIN_PGML 2 + 2 = [_____]{4} END_PGML BEGIN_PGML_HINT This is the second hint which should not be visible immediately. END_PGML_HINT Section::End(); Scaffold::End(); ENDDOCUMENT(); In reply to Larry Riddle ### Re: Hints in different sections of a scaffold problem by Glenn Rice - First note that "$showHints = 0" is not a command.  $showHints is a Perl variable, and this sets its value to 0. You can set the value of that variable multiple times in the problem. If you set it before the first hint to 0, then the first hint will show up after 1 attempt. If you set it again, but this time to 2, before the second hint, then the second hint won't show up until after 3 tries. This takes into account that 1 try is needed to open the first scaffold as well as 1 try before the first hint shows up. This will somewhat mimic what you are getting at. It might be possible to modify scaffold.pl to do a little better, but it may take deeper webwork2 code modification to really obtain what you are trying to do. In reply to Glenn Rice ### Re: Hints in different sections of a scaffold problem by Larry Riddle - Thanks for the clarification. Setting$showHint = 2 before section 2 does indeed make the hint appear in that section after a failed attempt and then a successful attempt in section 1 (so two attempts going into section 2), followed by a failed attempt in section 2. But if there is more than one failed attempted in section 1, the total attempts going into section 2 is now greater than 2 and so the hint in section 2 will appear immediately.

So what I tried instead was to set $showHint =$numOfAttemps thinking this would reflect the number of failed attempts in section 1 upon opening section 2. It did not work, however, because after each time the problem is graded, $numOfAttempts increases by 1 and$showHint is then also increased by one. Thus the second hint never appears no matter how many attempts are made in section 2.

What I would like to be able to do is assign the value of $numOfAttempts to$showHint after the first section is completed in such a way that the value of $showHint does not change when additional attempts are made to answer section 2. I do not know enough about Perl or WeBWorK, however, to know if this is possible. In reply to Larry Riddle ### Re: Hints in different sections of a scaffold problem by Glenn Rice - Yes, the value of$showHint is used relative to the $numOfAttempts value. So setting$showHint equal to $numOfAttempts will not work. To really make this work you would have to modify scaffold.pl. Although, even with that, I am not entirely certain this is possible. It may take further modifications to webwork to make this work. In reply to Glenn Rice ### Re: Hints in different sections of a scaffold problem by Todd Ruskell - I'm new to WeBWorK, so don't know all the variables we can access. I'm guessing (hoping) there must be a variable we can access that tells whether or not the first section is complete. Might anyone know if this is true, and if so, what that variable is? Assuming a boolean variable$section1Correct, you could then try something like this:

$numOfAttemptsSection1 = 999; #some number of tries you hope students never reach$x = 3; #number of attempts on second part before showing hint
if ( ($numOfAttemptsSection1 == 999) &&$section1Correct) {
$numOfAttemptsSection1 =$numOfAttempts;
$showHints=$numOfAttemptsSection1 + \$x;
}