Is there a known technique to use scaffold.pl such that assessing the student's answer in section 2 depends on what they entered into section 1? If there is something that is known to work, that will sidestep my next question.
I think I see the issue. The method that determines which section an answer name is in is concluding that all the multianswer answer blanks are in the first section where one of the multianswer answer blanks appear. I am looking into it, but I'm not sure how to change this, or if it's possible.
$PG_ANSWERS_HASH->{$name}->ans_eval
to determine if an answer evaluator has yet been assigned to the answer with name $name. This is all part of an indirect way for the code to determine which answer names are from the current scaffold section. The problem is that when there are multianswer blanks in multiple sections, when the evaluator is assigned to the first answer name, it is assigned to the rest as well. So to scaffold.pl, it appears as if all of the multianswer answer blanks come from the first section.
After inspecting $PG_ANSWERS_HASH repeatedly in a sample problem, I think I can replace `$PG_ANSWERS_HASH->{$name}->ans_eval` with:
defined($PG_ANSWERS_HASH->{$name}{response}{responses}{$name})
For example while in the first section, the hash $PG_ANSWERS_HASH->{AnSwEr0001}{response}{responses} is initialized with one key AnSwEr0001, but $PG_ANSWERS_HASH->{AnSwEr0002}{response}{responses} is an empty hash. Only once the second section is run is that hash given the key AnSwEr0002.
I tested this change with a few different configurations of multianswer questions (like two parts in one section, a third part in the next section) as well as with "normal" scaffold problems that don't use multianswer. And it works.
Does this proposed change raise any red flags? My problem with it is that I do not fully understand it. I do not know what mechanism is initializing theses hash keys, and that makes me nervous that there is some situation where the proposed change would break something.
Alex, here is another approach. I haven't used multianswers across sections, but instead store the students answer in a variable that I can then use in other answer checkers (or even output to the problem).
This approach basically takes advantage of variables are global in the safe compartment, but there might be a better approach to better scope the variables.
Though looks like allowing multianswers across scaffold sections would be useful, so that should probably be fixed, but here is an example that will work as is.
Thanks, this is a nice technique. I didn't think to assign variables from the main body while inside the checker. And this allows you to use thee previous section answers in subsequent section statements, hints, and solutions.
With the multianswer technique, I can easily put a message for the second part that says "This cannot be assessed until the first part is correct" or something like that. How would you do that with this method? We would need to access the score from the first answer hash, after that score is found. Would that be done with a post filter storing it to some global variable/array?
Attached is a rework of Jaimos' problem that does this the way I have done this sort of thing in problems. It uses the answer hash from the first part, instead of creating another global variable.
Attached is a corrected version. Note that I also removed the custom checker on the first part to emphasize the versatility of this approach.