[system] / trunk / pg / macros / PGbasicmacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGbasicmacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3553 Revision 3704
183generated implicitly. 183generated implicitly.
184 184
185 ans_rule( width ) 185 ans_rule( width )
186 tex_ans_rule( width ) 186 tex_ans_rule( width )
187 ans_radio_buttons(value1=>label1, value2,label2 => value3,label3=>...) 187 ans_radio_buttons(value1=>label1, value2,label2 => value3,label3=>...)
188 pop_up_list(@list) # list consists of (value => label, PR => "Product rule",...) 188 pop_up_list(@list) # list consists of (value => label, PR => "Product rule",...)
189 pop_up_list([@list]) # list consists of values
190
191In the last case, one can use C<pop_up_list(['?', 'yes', 'no'])> to produce a
192pop-up list containing the three strings listed, and then use str_cmp to check
193the answer.
189 194
190To indicate the checked position of radio buttons put a '%' in front of the value: C<ans_radio_buttons(1, 'Yes','%2','No')> 195To indicate the checked position of radio buttons put a '%' in front of the value: C<ans_radio_buttons(1, 'Yes','%2','No')>
191will have 'No' checked. C<tex_ans_rule> works inside math equations in C<HTML_tth> mode. It does not work in C<Latex2HTML> mode 196will have 'No' checked. C<tex_ans_rule> works inside math equations in C<HTML_tth> mode. It does not work in C<Latex2HTML> mode
192since this mode produces gif pictures. 197since this mode produces gif pictures.
193 198
210 NAMED_ANS_RADIO(name, value,label,) 215 NAMED_ANS_RADIO(name, value,label,)
211 NAMED_ANS_RADIO_EXTENSION(name, value,label) 216 NAMED_ANS_RADIO_EXTENSION(name, value,label)
212 NAMED_ANS_RADIO_BUTTONS(name,value1,label1,value2,label2,...) 217 NAMED_ANS_RADIO_BUTTONS(name,value1,label1,value2,label2,...)
213 check_box('-name' =>answer5,'-value' =>'statement3','-label' =>'I loved this course!' ) 218 check_box('-name' =>answer5,'-value' =>'statement3','-label' =>'I loved this course!' )
214 NAMED_POP_UP_LIST($name, @list) # list consists of (value => tag, PR => "Product rule",...) 219 NAMED_POP_UP_LIST($name, @list) # list consists of (value => tag, PR => "Product rule",...)
220 NAMED_POP_UP_LIST($name, [@list]) # list consists of a list of values (and each tag will be set to the corresponding value)
215 221
216(Name is the name of the variable, value is the value given to the variable when this option is selected, 222(Name is the name of the variable, value is the value given to the variable when this option is selected,
217and label is the text printed next to the button or check box. Check box variables can have multiple values.) 223and label is the text printed next to the button or check box. Check box variables can have multiple values.)
218 224
219NAMED_ANS_RADIO_BUTTONS creates a sequence of NAMED_ANS_RADIO and NAMED_ANS_RADIO_EXTENSION items which 225NAMED_ANS_RADIO_BUTTONS creates a sequence of NAMED_ANS_RADIO and NAMED_ANS_RADIO_EXTENSION items which
731 737
732 738
733sub NAMED_POP_UP_LIST { 739sub NAMED_POP_UP_LIST {
734 my $name = shift; 740 my $name = shift;
735 my @list = @_; 741 my @list = @_;
742 if(ref($list[0]) eq 'ARRAY') {
743 my @list1 = @{$list[0]};
744 @list = map { $_ => $_ } @list1;
745 }
736 $name = RECORD_ANS_NAME($name); # record answer name 746 $name = RECORD_ANS_NAME($name); # record answer name
737 my $answer_value = ''; 747 my $answer_value = '';
738 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name}); 748 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
739 my $out = ""; 749 my $out = "";
740 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or 750 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or

Legend:
Removed from v.3553  
changed lines
  Added in v.3704

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9