Commit b278756
committed
Fix problem_data with problem randomization and show me another.
When problem randomization is enabled and a new problem version is
opened, don't use the problem data from the previous version.
When show me another is enabled don't use the problem data from the
assigned problem.
To fix these issues force an empty problem data hash by passing `'{}'`
as the `problemData` translation option.
The following example can be used to test this:
```perl
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'scaffold.pl');
$a = random(1, 10);
$b = random(11, 20);
Scaffold::Begin(
is_open => 'correct_or_first_incorrect',
preview_can_change_state => 0
);
Section::Begin('Part 1');
BEGIN_PGML
Enter [`[$a]`]: [_]{$a}{5}
END_PGML
Section::End();
Section::Begin('Part 2');
BEGIN_PGML
Enter [`[$b]`] [_]{$b}{5}
END_PGML
Section::End();
Scaffold::End();
ENDDOCUMENT();
```
Add that problem to a set and enable both problem randomization and show
me another. Then test the following with the develop branch.
Now login as a student user, open the problem in the set, and submit the
correct answer for the first part in the problem. Then submit answers
enough times to need to request a new version, and then request a new
version. Now in the new version, enter an answer and click "Preview My
Answers", and the second part will open. Since the scaffold has the
`preview_can_change_state => 0` option set, even if the "correct" answer
is entered the second part should not open when "Preview My Answers" is
clicked, but it does (and does so even an incorrect answer is entered).
Now try the "Show Me Another" button after submitting the correct answer
to the first part in the assigned problem in the set. In the show me
another problem, enter an answer to the first part, and click "Preview
My Answers". Again, the second part opens regardless of if the first
part is correct or not, and again it shouldn't open even if the first
part is correct.
Now test with this pull request, and of course the correct behaviour
happens. That is the second part only opens when the first part is
submitted (either with "Submit Answers" in the actual set or with "Check
Answers" in the show me another problem) and the first part is correct.1 parent 1fedbc8 commit b278756
2 files changed
+9
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
592 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
593 | 596 | | |
594 | 597 | | |
595 | 598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
209 | | - | |
| 211 | + | |
| 212 | + | |
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
| |||
0 commit comments