-
-
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
Changes to parserMultiAnswer breaks problems #450
Comments
#######################
### ggbApplet MultiAns
#######################
#
# Make a subclass of MultiAnswer
#
package myMultiAnswer;
our @ISA = ('MultiAnswer');
sub new {
my $self = shift;
my $ma = $self->SUPER::new(@_);
$ma->{part} = 1;
$ma->{answerName} = 'answerBox';
$ma->{answerNames}{0} = $ma->{answerName};
$ma->{id} = $MultiAnswer::answerPrefix.$ma->{answerName};
$ma->{singleResult} = 1;
$ma->{namedRules} = 1;
return $ma;
}
sub ANS_NAME {
my $self = shift;
my $i = shift;
$self->{answerNames}{$i} = ($i == 0 ? $self->{answerName} : $self->{id}.'_'.$i);
return $self->{answerNames}{$i};
}
package main; Is this the best way to modify the original in order to accommodate the new answerNames cache? If I've understood correctly, the answerNames cache expects the root name to live in the {0}th position and the other MuLtIaNsWeR_ blocks are built off of that first one? |
Although your modification will work, and even simpler approach that will work in the same way is to just delete your ANS_NAME method. The built in ANS_NAME method of the MultiAnswer object will work, and almost literally does the same thing. So use the following: package myMultiAnswer;
our @ISA = ('MultiAnswer');
sub new {
my $self = shift;
my $ma = $self->SUPER::new(@_);
$ma->{part} = 1;
$ma->{answerName} = 'answerBox';
$ma->{answerNames}{0} = $ma->{answerName};
$ma->{id} = $MultiAnswer::answerPrefix.$ma->{answerName};
$ma->{singleResult} = 1;
$ma->{namedRules} = 1;
return $ma;
}
package main; |
Previously, @dpvc helped me write this modification to parserMultiAnswer.pl in order to pull a GeoGebra
answerBox
into a multiAnswer object. The update to the multi-answer library has broken all my problems written with this code.The following code used to initiate a multi answer object with the first answerName matching that of the GeoGebra applet (answerBox); and after that, it would create answerNames according to the usual approach.
Can the old functionality be replicated under the modified version of parserMultiAnswer.pl?
For one, it seems that answerName is no longer an appropriate hash key. Instead, answerNames keys to an array now?
Also, it seems that ANS_NAME has changed as well, and this replacement will no longer suffice.
The PG error message I'm seeing is:
---- main (eval 3679) 489 ------ Error in NAMED_ANSWER_RULE_EXTENSION: every call to this subroutine needs to have $options{answer_group_name} defined. For a single answer blank this is usually the same as the answer blank name. Answer blank name: MuLtIaNsWeR_answerBox_1
For testing purposes, an example problem that uses this method can be found here:
Contrib/CUNY/CityTech/Calculus/setExplore_-_Intermediate_Value_Theorem/geogebra-IVT.pg
The text was updated successfully, but these errors were encountered: