-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaffold section with PopUp breaks subsequent MathObjects #881
Comments
In short, the problem is a combination of the answer processing that is done when a section ends by In more detail what is happening is that initially the problem is in the default One way to see that this is the case is to add So another workaround for this bug is to add |
Glenn is correct, evaluating a MathObject answer checker leaves the context as the one used for the MathObject, not the context that was current when the checking was started. That is not a good side-effect, and probably should be fixed. That could be done in PGML when it does the evaluation (save the original context and put it back when done), but it is probably better to fix it in the general MathObject The difficulty is that post filters (like One solution would be to use a pre-filter to save the current context and set up a post-filter to put it back. Because pre-filters won't run until the first time the answer checker is evaluated, the post-filters will have been added by then, so adding another post-filter will add it to the end of the post-filter list, which will mean the context is replaced after the other post-filters run. The only complication is that you don't want to add the post-filter twice if the answer checker is evaluated twice (as it is in scaffolds and in some other circumstances). It's not terrible to have the post-filter added more than once, since it would just be redundant, but its not very clean either. So a possible solution would be to add $ans->install_pre_filter(sub {
my ($hash, $ans) = @_;
$ans->install_post_filter(sub {main::Context($_[1]), $_[0]}, main::Context())
if (!$ans->{has_cmp_postfilter});
$ans->{has_cmp_postfilter} = 1;
return $hash;
}, $ans); just after the line Line 110 in e258ae2
in Line 923 in e258ae2
as well, which means it might be worth making the subroutine into a method like $ans->install_pre_filter(\&Value::cmp_restoreContext, $ans); and put after Lines 377 to 386 in e258ae2
for example. That should make all the standard MathObject answer checkers restore the context, and should resolve the issue with scaffolds. |
This was first reported in #880.
As far as I can tell if a PopUp is used in a scaffold section, then any MathObjects that are defined after the end of that section don't get created properly.
Consider the following example:
The answers up to 3 are evaluated correctly, but 4 and 5 are marked wrong even though those values are shown as the correct answers.
It seems to be that some interaction of the PopUp display followed by
Section::End()
is causing this.An available workaround is to define all variables before the start of the scaffold.
The text was updated successfully, but these errors were encountered: