Skip to content

Commit

Permalink
Merge pull request #397 from drgrice1/multianswer-fix
Browse files Browse the repository at this point in the history
Fix the MultiAnswer macro when the namedRules option is used.
  • Loading branch information
mgage authored Feb 24, 2019
2 parents 5e6c0a4 + e99db4f commit dfef4c6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions macros/parserMultiAnswer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -411,22 +411,20 @@ sub setMessage {
######################################################################

#
# Produce the name for a named answer blank
# (Use the standard name for the first one, and
# create the prefixed names for the rest.)
# Produce the name for a named answer blank.
# (When the singleResult option is true, use the standard name for the first
# one, and create the prefixed names for the rest.)
#
sub ANS_NAME {
my $self = shift; my $i = shift; my $name;
my $self = shift; my $i = shift;
return $self->{answerNames}{$i} if defined($self->{answerNames}{$i});
if ($self->{singleResult}) {
if (!$self->{id}) {
$name = $self->{answerName} = main::NEW_ANS_NAME();
$self->{id} = $answerPrefix.$name;
}
$name = $self->{id}."_".$i unless $i == 0;
$self->{answerNames}{0} = main::NEW_ANS_NAME() unless defined($self->{answerNames}{0});
$self->{answerNames}{$i} = $answerPrefix.$self->{answerNames}{0}."_".$i unless $i == 0;
} else {
$name = main::NEW_ANS_NAME();
$self->{answerNames}{$i} = main::NEW_ANS_NAME();
}
return $name;
return $self->{answerNames}{$i};
}

#
Expand All @@ -453,7 +451,7 @@ sub ans_rule {
if ($self->{singleResult} && $self->{part} > 1) {
my $extension_ans_rule =
$data->named_ans_rule_extension(
$name,$size, answer_group_name => $self->{answerName},
$name,$size, answer_group_name => $self->{answerNames}{0},
@_);
# warn "extension rule created: $extension_ans_rule for ", ref($data);
return $extension_ans_rule;
Expand All @@ -474,12 +472,12 @@ sub ans_array {
if ($self->{singleResult} && $self->{part} == 1) {
my $label = main::generate_aria_label($answerPrefix.$name."_0");
return $data->named_ans_array($name,$size,
answer_group_name => $self->{answerName},
answer_group_name => $self->{answerNames}{0},
@_,aria_label=>$label);
}
if ($self->{singleResult} && $self->{part} > 1) {
$HTML = $data->named_ans_array_extension($self->NEW_NAME($name),$size,
answer_group_name => $self->{answerName}, @_);
answer_group_name => $self->{answerNames}{0}, @_);
# warn "array extension rule created: $HTML for ", ref($data);
} else {
$HTML = $data->named_ans_array($name,$size,@_);
Expand Down

0 comments on commit dfef4c6

Please sign in to comment.