GithubHelp home page GithubHelp logo

Comments (4)

dpvc avatar dpvc commented on July 19, 2024

It seems to me that here, ans_rule is overruling the ans_rule from PGbasicmacros.pl

No, that's not the case. Since these are inside the package parserPopUp;here

package parser::PopUp;

that makes the methods of the parserPopUp class, not global functions like main::answer_rule() that you refer to.

These are needed particular for things like PGML and MultiAnswer, which use $mo->ans_rule and $mo->named_ans_rule() to obtain answer rules for the MathObject $mo.

All of this is raising my suspicion that these instances were supposed to be the capital letter spelling, or something like that. Or do I misunderstand what is going on here?

I'm afraid it is the later. These are properly named. See

sub ans_rule {
my $self = shift; my $size = shift || 20;
my $data = $self->{data}[$self->{part}];
my $name = $self->ANS_NAME($self->{part}++);
if ($self->{singleResult} && $self->{part} == 1) {
my $label = main::generate_aria_label($answerPrefix.$name."_0");
return $data->named_ans_rule($name,$size,@_,aria_label=>$label);
}
if ($self->{singleResult} && $self->{part} > 1) {
my $extension_ans_rule =
$data->named_ans_rule_extension(
$name,$size, answer_group_name => $self->{answerName},
@_);
# warn "extension rule created: $extension_ans_rule for ", ref($data);
return $extension_ans_rule;
} else {
return $data->named_ans_rule($name,$size,@_);

and

pg/macros/PGML.pl

Lines 1010 to 1015 in 5e6c0a4

my $method = ($item->{hasStar} ? "ans_array" : "ans_rule");
if ($item->{name}) {
unshift(@options,$item->{name});
$method = "named_".$method;
}
$rule = $ans->$method(@options);

All MathObejcts get these methods from

#
# create answer rules of various types
#
sub ans_rule {shift; pgCall('ans_rule',@_)}
sub named_ans_rule {shift; pgCall('NAMED_ANS_RULE',@_)}
sub named_ans_rule_extension {shift; pgCall('NAMED_ANS_RULE_EXTENSION',@_)}
sub ans_array {shift->ans_rule(@_)};
sub named_ans_array {shift->named_ans_rule(@_)};
sub named_ans_array_extension {shift->named_ans_rule_extension(@_)};

though some (like PopUps) need to override the basic method.

The upshot is, these are correct as they stand.

from pg.

Alex-Jordan avatar Alex-Jordan commented on July 19, 2024

OK, I get it. Thank you for the explanation. So these are essentially only there (right now) for the sake of parserMultiAnswer.pl. Sorry for the noise. I was trying to sort this all out while I try to mimic parserPopUp.pl for an attempt at a GoeGebra class.

from pg.

dpvc avatar dpvc commented on July 19, 2024

So these are essentially only there (right now) for the sake of parserMultiAnswer.pl

And also PGML.pl, and for creating answer arrays for matrices and other list-like MathObjects, but yes, it is for that.

from pg.

Alex-Jordan avatar Alex-Jordan commented on July 19, 2024

OK, I missed PGML using named_ans_rule given the way "named_ans_rule" isn't found in a search. I see it now.

from pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.