From: dpvc v. a. <we...@ma...> - 2009-06-09 12:11:44
|
Log Message: ----------- Put off adding % to label key until just before needed Modified Files: -------------- pg/macros: parserRadioButtons.pl Revision Data ------------- Index: parserRadioButtons.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserRadioButtons.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -Lmacros/parserRadioButtons.pl -Lmacros/parserRadioButtons.pl -u -r1.11 -r1.12 --- macros/parserRadioButtons.pl +++ macros/parserRadioButtons.pl @@ -158,7 +158,7 @@ Value::Error("A RadioButton's second argument should be the correct button choice") unless defined($value) && $value ne ""; my $context = Parser::Context->getCopy("String"); - my %choiceHash = $self->choiceHash(1); + my %choiceHash = $self->choiceHash; $context->strings->add(map {$_=>{}} (keys %choiceHash)); $value = $self->correctChoice($value); $self = bless $context->Package("String")->new($context,$value)->with(choices => $choices, %options), $class; @@ -178,6 +178,7 @@ $label = $self->makeLabel($choice) unless defined $label; return $label if $label eq $value || $index == $i || $choice eq $value; } + return undef; } # @@ -197,15 +198,10 @@ # ans_radio_buttons() routine # sub choiceHash { - my $self = shift; my $noChecked = shift; - my @radio = (); - my $index = $self->Index($self->{checked}); - my $checked = $self->{checked}; $checked = "" unless defined $checked; - if ($noChecked) {$checked = ""; $index = -1} + my $self = shift; my @radio = (); foreach my $i (0..scalar(@{$self->{choices}})-1) { my $label = $self->{labels}[$i]; my $choice = $self->{choices}[$i]; $label = $self->makeLabel($choice) unless defined $label; - $label = "%$label" if $label eq $checked || $index == $i || $choice eq $checked; push(@radio, $label,$choice); } return @radio; @@ -283,9 +279,9 @@ my %choiceHash = $self->choiceHash; my @labels = keys %choiceHash; - my @order = @{$self->{order}}; - my @first = @{$self->{first}}; - my @last = @{$self->{last}}; + my @order = @{$self->{order} || []}; + my @first = @{$self->{first} || []}; + my @last = @{$self->{last} || []}; my @orderLabels; @@ -335,7 +331,8 @@ @orderLabels = @labels; } - return map { $_ => $choiceHash{$_} } @orderLabels; + my $label = $self->findChoice($self->{checked}); + return map { ($_ eq $label ? "%$_" : $_) => $choiceHash{$_} } @orderLabels; } # |