Diff for /loncom/interface/lonhelper.pm between versions 1.135 and 1.136

version 1.135, 2006/03/19 23:09:20 version 1.136, 2006/04/06 22:30:52
Line 1069  will be the state transistioned to if th Line 1069  will be the state transistioned to if th
 the choice is not multichoice. This will override the nextstate  the choice is not multichoice. This will override the nextstate
 passed to the parent C<choices> tag.  passed to the parent C<choices> tag.
   
   <choice> may optionally contain a 'relatedvalue' attribute, which
   if present will cause a text entry to appear to the right of the
   selection.  The value of the relatedvalue attribute is a variable
   into which the text entry will be stored e.g.:
   <choice computer='numberprovided" relatedvalue="num">Type the number in:</choice>
   
   <choice> may contain a relatededefault atribute which, if the
   relatedvalue attribute is present will be the initial value of the input
   box.
   
 =back  =back
   
 To create the choices programmatically, either wrap the choices in   To create the choices programmatically, either wrap the choices in 
Line 1159  sub start_choice { Line 1169  sub start_choice {
     my $computer = $token->[2]{'computer'};      my $computer = $token->[2]{'computer'};
     my $human = &mt(&Apache::lonxml::get_all_text('/choice',      my $human = &mt(&Apache::lonxml::get_all_text('/choice',
                                               $parser));                                                $parser));
     my $nextstate = $token->[2]{'nextstate'};      my $nextstate  = $token->[2]{'nextstate'};
     my $evalFlag = $token->[2]{'eval'};      my $evalFlag   = $token->[2]{'eval'};
       my $relatedVar = $token->[2]{'relatedvalue'}; 
       my $relatedDefault = $token->[2]{'relateddefault'};
     push @{$paramHash->{CHOICES}}, [&mtn($human), $computer, $nextstate,       push @{$paramHash->{CHOICES}}, [&mtn($human), $computer, $nextstate, 
                                     $evalFlag];                                      $evalFlag, $relatedVar, $relatedDefault];
     return '';      return '';
 }  }
   
Line 1272  BUTTONS Line 1284  BUTTONS
         }          }
         $result .= qq{id="id$id"};          $result .= qq{id="id$id"};
         my $choiceLabel = $choice->[0];          my $choiceLabel = $choice->[0];
         if ($choice->[4]) {  # if we need to evaluate this choice          if ($choice->[3]) {  # if we need to evaluate this choice
             $choiceLabel = "sub { my $helper = shift; my $state = shift;" .              $choiceLabel = "sub { my $helper = shift; my $state = shift;" .
                 $choiceLabel . "}";                  $choiceLabel . "}";
             $choiceLabel = eval($choiceLabel);              $choiceLabel = eval($choiceLabel);
             $choiceLabel = &$choiceLabel($helper, $self);              $choiceLabel = &$choiceLabel($helper, $self);
         }          }
         $result .= "/></td><td> ".qq{<label for="id$id">}.          $result .= "/></td><td> ".qq{<label for="id$id">}.
             $choiceLabel. "</label></td></tr>\n";              $choiceLabel. "</label></td>";
    if ($choice->[4]) {
       $result .='<td><input type="text" size="5" name="'
    .$choice->[4].'.forminput" value="'
                   .$choice->[5].'" /></td>';
    }
    $result .= "</tr>\n";
     }      }
     $result .= "</table>\n\n\n";      $result .= "</table>\n\n\n";
     $result .= $buttons;      $result .= $buttons;
Line 1313  sub postprocess { Line 1331  sub postprocess {
                 $helper->changeState($choice->[2]);                  $helper->changeState($choice->[2]);
             }              }
         }          }
    if ($choice->[4]) {
       my $varname = $choice->[4];
       $helper->{'VARS'}->{$varname} = $env{'form.'."$varname.forminput"};
    }
     }      }
     return 1;      return 1;
 }  }

Removed from v.1.135  
changed lines
  Added in v.1.136


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>