[system] / trunk / webwork / system / courseScripts / PGchoicemacros.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/courseScripts/PGchoicemacros.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (download) (as text) (annotate)
Wed Jun 20 00:29:58 2001 UTC (18 years, 8 months ago) by gage
File size: 20138 byte(s)
Added _PG......_init  subroutines to these two files
.

    1 #!/usr/local/bin/webwork-perl
    2 BEGIN{
    3   be_strict;
    4 }
    5 
    6 package main;
    7 
    8 
    9 =head1 NAME
   10 
   11 PGchoicemacros.pl --- located in the courseScripts directory
   12 
   13 
   14 =head1 SYNPOSIS
   15 
   16 =for html
   17 There are two types of choice macros. The older versions are simply scripts. The newer versions involve the <a href='List'>List</a> class and its sub-classes and the use of objects based on these classes. The list sub-classes are: <a href='Match'>Match</a> which aids in setting up matching question and answer lists, <a href='Select'>Select</a> which aids in selecting and presenting a subset of questions with short answers (e.g. true/false questions) from a larger question set, and <a href='Multiple'>Multiple</a> which aids in setting up a standard style, one question, many answers type multiple choice question.
   18 
   19 
   20 =head1 DESCRIPTION
   21 
   22 Typical use varies depending on the type of list being used.
   23 
   24 =for html
   25 See the documentation for <a href='Multiple'>Multiple.pm</a>, <a href='Match'>Match.pm</a>, and <a href='Select'>Select.pm</a>
   26 
   27 =cut
   28 
   29 
   30 =head2 Matching List macros
   31 
   32 
   33 =head3 new_match_list
   34 
   35 Matching list object creation macro
   36 
   37 Useage:
   38 
   39 =for html
   40   <PRE>
   41   <I>$ml = new_match_list;</I></PRE>
   42 
   43 Which is equivalent to the following direct call to Match
   44 
   45 =for html
   46   <PRE>
   47   <I>$ml = new Match(random(1,2000,1), ~~&std_print_q, ~~&std_print_a);</I></PRE>
   48 
   49 =for html
   50 Either call will create a matching list object in the variable $ml. ( $ml
   51 cannot be a my variable if it is to be used within a
   52 BEGIN_TEXT/END_TEXT block.  The printing methods are passed as references (~~ in PG equals \ in perl) to
   53 subroutines so that no matter what printing subroutines are used, those subroutines can be used by saying
   54 $ml->print_q and $ml->print_a.  This also means that other subroutines can be used instead of the default ones.  An
   55 example of how to do this is demonstrated with <a href="PGchoicemacros#pop_up_list_print_q">pop_up_list_print_q</a> below.
   56 
   57 
   58 =for html
   59   <P>See the documentation for <a href='Match'>Match.pm</a> to see how to use
   60   this object to create a matching question.
   61 
   62 
   63 =head4 std_print_q
   64 
   65 Standard method for printing questions
   66 
   67 =for html
   68 This simple printing routine is used to print the questions for each of the three sub-classes of List.  When a match list, select list, or multiple choice object is created, a reference to std_print_q is passed to that object so that it can be used from within the object later.
   69 
   70 std_print_q checks which mode the user is trying to print the questions from and returns the appropriately formatted string.
   71 
   72 
   73 =head4 std_print_a
   74 
   75 Standard method for printing answers with answer boxes
   76 
   77 This simple printing routine is used to print the answers for matching lists
   78 (and technically select list, even though answers are not printed with a select
   79 list).  When a match list or select list object is created, a reference to
   80 std_print_q is passed to that object so that it can be used from within the
   81 object later.
   82 
   83 std_print_a checks which mode the user is trying to print the answers from and
   84 returns the appropriately formatted string.
   85 
   86 
   87 =head2 Select List macros
   88 
   89 
   90 =head3 new_select_list
   91 
   92 Select list object creation macro
   93 
   94 Useage:
   95 
   96 =for html
   97   <PRE>
   98   <I>$sl = new_select_list;</I></PRE>
   99 
  100 Which is equivalent to this direct call to Select
  101 
  102 =for html
  103   <PRE>
  104   <I>$sl = new Select(random(1,2000,1), ~~&std_print_q, ~~&std_print_a);</I></PRE>
  105 
  106 =for html
  107 Either call will create a select list object in the variable $sl. ( Note that
  108 $sl cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT
  109 block.)  The printing methods are passed as references (~~ in PG equals \ in
  110 perl) to subroutines so that no matter what printing subroutines are used,
  111 those subroutines can be used by saying $sl->print_q and $sl->print_a.  This
  112 also means that other subroutines can be used instead of the default ones.  An
  113 example of how to do this is demonstrated with <a href="PGchoicemacros#pop_up_list_print_q">pop_up_list_print_q</a> below.
  114 
  115 
  116 =for html
  117   <P>See the documentation for <a href='Select'>Select.pm</a> to see how to use this
  118   object to create a true/false question.
  119 
  120 
  121 =head4 std_print_q
  122 
  123 Standard method for printing questions with answer boxes
  124 
  125 See std_print_q under Matching Lists above.
  126 
  127 
  128 =head4 std_print_a
  129 
  130 This is only intended to be used for debugging as there is rarely a reason to
  131 print out the answers to a select list.
  132 
  133 See std_print_a under Matching Lists above.
  134 
  135 
  136 =head3 new_pop_up_select_list
  137 
  138 Select list object creation macro
  139 
  140 Useage:
  141 
  142 =for html
  143   <PRE>
  144   <I>$sl = new_pop_up_select_list;</I></PRE>
  145 
  146 Which is equivalent to this direct call to Select
  147 
  148 =for html
  149   <PRE>
  150   <I>$sl = new Select(random(1,2000,1), ~~&pop_up_list_print_q, ~~&std_print_a);</I></PRE>
  151 
  152 =for html
  153 Either call will create a select list object in the variable $sl. ( Note that
  154 $sl cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT
  155 block.)  The printing methods are passed as references (~~ in PG equals \ in
  156 perl) to subroutines so that no matter what printing subroutines are used,
  157 those subroutines can be used by saying $sl->print_q and $sl->print_a.  This
  158 also means that other subroutines can be used instead of the default ones.
  159 
  160 =for html
  161   <P>See the documentation for <a href='Select'>Select.pm</a> to see how to use this
  162   object to create a true/false question.
  163 
  164 
  165 =head4 std_print_q
  166 
  167 Standard method for printing questions with answer boxes
  168 
  169 See std_print_q under Matching Lists above.
  170 
  171 
  172 =head4 pop_up_list_print_q
  173 
  174 Alternate method for print questions with pop up lists.
  175 
  176 Useage:
  177 
  178 This printing routine is used to print the questions for a true/false or other
  179 select list with a preceding pop up list of possible answers.  A list of values
  180 and labels need to be given to the pop_up_list so that the intended answer is
  181 returned when a student selects an answer form the list.  Notethe use of => to
  182 associate the values on the left with the labels on the right, this means that,
  183 for instance, the student will see the word True in the pop_up_list but the
  184 answer that is returned to the grader is T, so that it corresponds with what
  185 the professor typed in as the answer when using $sl->qa('blah blah', 'T');
  186 
  187 =for html
  188   <PRE>
  189   <I>$sl->ra_pop_up_list([</I>value<I> => </I>label<I>,
  190               T => 'True',
  191               F => 'False']);</I></PRE>
  192 
  193 
  194 =head4 std_print_a
  195 
  196 This is only intended to be used for debugging as there is rarely a reason to
  197 print out the answers to a select list.
  198 
  199 See std_print_a under Matching Lists above.
  200 
  201 
  202 =head2 Multiple Choice macros
  203 
  204 
  205 =head3 new_multiple_choice
  206 
  207 Multiple choice object creation macro
  208 
  209 Useage:
  210 
  211 =for html
  212   <PRE>
  213   <I>$mc = new_multiple_choice;</I></PRE>
  214 
  215 Which is equivalent to this direct call to Multiple
  216 
  217 =for html
  218   <PRE>
  219   <I>$mc = new Multiple(random(1,2000,1), ~~&std_print_q, ~~&std_print_a);</I></PRE>
  220 
  221 Either call will create a multiple choice object in the variable $mc. Note that
  222 $mc cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT
  223 block.
  224 
  225 =for html
  226   <P>See the documentation for <a href='Multiple'>Multiple.pm</a> to see how to use
  227   this object to create a multiple choice question.
  228 
  229 
  230 =head4 std_print_q
  231 
  232 Standard method for printing questions
  233 
  234 See std_print_q under Matching Lists above.
  235 
  236 
  237 =head4 radio_print_a
  238 
  239 Method for printing answers with radio buttons
  240 
  241 This simple printing routine is used to print the answers to multiple choice
  242 questions in a bulleted style with radio buttons preceding each possible answer.
  243 When a multiple choice object is created, a reference to radio_print_a is passed
  244 to that object so that it can be used from within the object later.
  245 
  246 radio_print_a checks which mode the user is trying to print the answers from and
  247 returns the appropriately formatted string.
  248 
  249 
  250 =head3 new_checkbox_multiple_choice
  251 
  252 Checkbox multiple choice object creation macro
  253 
  254 Useage:
  255 
  256 =for html
  257   <PRE>
  258   <I>$cmc = new_checkbox_multiple_choice;</I></PRE>
  259 
  260 Which is equivalent to this direct call to Multiple
  261 
  262 =for html
  263   <PRE>
  264   <I>$cmc = new Multiple(random(1,2000,1), ~~&std_print_q, ~~&checkbox_print_a);</I></PRE>
  265 
  266 Either call will create a checkbox multiple choice object in the variable $cmc. Note that
  267 $cmc cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT
  268 block.
  269 
  270 =for html
  271   <P>See the documentation for <a href='Multiple'>Multiple.pm</a> to see how to use
  272   this object to create a multiple choice question.
  273 
  274 
  275 =head4 std_print_q
  276 
  277 Standard method for printing questions
  278 
  279 See std_print_q under Matching Lists above.
  280 
  281 
  282 =head4 checkbox_print_a
  283 
  284 Method for printing answers with radio buttons
  285 
  286 This simple printing routine is used to print the answers to multiple choice
  287 questions in a bulleted style with checkboxes preceding each possible answer.
  288 When a multiple choice object is created, a reference to checkbox_print_a is passed
  289 to that object so that it can be used from within the object later.
  290 
  291 checkbox_print_a checks which mode the user is trying to print the answers from and
  292 returns the appropriately formatted string.
  293 
  294 
  295 
  296 =cut
  297 BEGIN {
  298   be_strict();
  299 }
  300 sub _PGchoicemacros_init{
  301 }
  302 sub _PGchoicemacros_export {
  303 
  304   my @EXPORT = (
  305     '&new_match_list',
  306     '&new_select_list', '&new_pop_up_select_list',
  307     '&new_multiple_choice', '&new_checkbox_multiple_choice',
  308     '&pop_up_list_print_q', '&std_print_a', '&radio_print_a',
  309     '&checkbox_print_a', '&std_print_q', '&qa', '&invert', '&NchooseK',
  310     '&shuffle', '&match_questions_list', '&match_questions_list_varbox',
  311   );
  312   @EXPORT;
  313 }
  314 
  315 #Useage: $ml = new_match_list
  316 #Note that $ml cannot be a my variable if used within a BEGIN_TEXT/END_TEXT block
  317 sub new_match_list {
  318   new Match(random(1,2000,1), \&std_print_q, \&std_print_a);
  319 }
  320 
  321 #Useage: $sl = new_select_list
  322 #Note that $sl cannot be a my variable if used within a BEGIN_TEXT/END_TEXT block
  323 sub new_select_list {
  324   new Select(random(1,2000,1), \&std_print_q, \&std_print_a);
  325 }
  326 
  327 #Useage: $pusl = new_pop_up_select_list
  328 sub new_pop_up_select_list {
  329   new Select(random(1,2000,1), \&pop_up_list_print_q, \&std_print_a);
  330 }
  331 
  332 
  333 #Useage: $mc = new_multiple_choice
  334 #Note that $mc cannot be a my variable if used within a BEGIN_TEXT/END_TEXT block
  335 sub new_multiple_choice {
  336   new Multiple(random(1,2000,1), \&std_print_q, \&radio_print_a);
  337 }
  338 
  339 #Useage: $mcc = new_checkbox_multiple_choice
  340 sub new_checkbox_multiple_choice {
  341   new Multiple(random(1,2000,1), \&std_print_q, \&checkbox_print_a);
  342 }
  343 
  344 #Useage:  $sl->rf_print_a(~~&pop_up_list_print_q);
  345 #   $sl->ra_pop_up_list([</I>value<I> => </I>label<I>, T => 'True', F => 'False']);
  346 sub pop_up_list_print_q {
  347     my $self = shift;
  348     my (@questions) = @_;
  349     my $length = $self->{ans_rule_len};
  350     my @list = @{$self->{ra_pop_up_list} };
  351     my $out = "";
  352 
  353   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  354     my $i=1; my $quest;
  355     foreach $quest (@questions) {
  356        $out.= "\n<p>" . pop_up_list(@list) . "&nbsp;<B>$i.</B> $quest";
  357        $i++;
  358     }
  359     $out .= "<br>\n";
  360   } elsif ($main::displayMode eq 'Latex2HTML') {
  361     my $i=1; my $quest;
  362     foreach $quest (@questions) {
  363        $out.= " \\begin{rawhtml}<p><B>\\end{rawhtml}" . pop_up_list(@list) . " $i. \\begin{rawhtml}</B>\\end{rawhtml}   $quest";
  364        $i++;
  365     }
  366     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  367   }  elsif ($main::displayMode eq 'TeX') {
  368       $out = "\n\\par\\begin{enumerate}\n";
  369       my $i=1; my $quest;
  370     foreach $quest (@questions) {
  371       $out .= "\\item[" .  pop_up_list(@list) . "$i.] $quest\n";
  372       $i++;
  373     }
  374     $out .= "\\end{enumerate}\n";
  375   } else {
  376     $out = "Error: PGchoicemacros: pop_up_list_print_q: Unknown displayMode: $main::displayMode.\n";
  377   }
  378   $out;
  379 
  380 }
  381 
  382 #Standard method of printing answers in a matching list
  383 sub std_print_a {
  384   my $self = shift;
  385   my(@array) = @_;
  386   my $i = 0;
  387   my  $out=   &main::M3(
  388           "\\begin{enumerate}\n",
  389           " \\begin{rawhtml} <OL TYPE=\"A\" VALUE=\"1\"> \\end{rawhtml} ",
  390           "<OL COMPACT TYPE=\"A\" START=\"1\">\n"
  391   ) ;
  392   my $elem;
  393   foreach $elem (@array) {
  394     $out .= &main::M3(
  395           "\\item[$main::ALPHABET[$i].] $elem\n",
  396           " \\begin{rawhtml} <LI> \\end{rawhtml} $elem  ",
  397           "<LI> $elem\n"
  398     ) ;
  399     $i++;
  400   }
  401   $out .= &main::M3(
  402         "\\end{enumerate}\n",
  403         " \\begin{rawhtml} </OL>\n \\end{rawhtml} ",
  404         "</OL>\n"
  405   ) ;
  406   $out;
  407 
  408 }
  409 
  410 
  411 #Alternate method of printing answers as a list of radio buttons for multiple choice
  412 #radio_print_a2 is used instead now
  413 # sub radio_print_a {
  414 #     my $self = shift;
  415 #     my (@answers) = @_;
  416 #     my $num = ++$main::ans_rule_count;
  417 #     my $out = "";
  418 #   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  419 #     my $ans = shift @answers;
  420 #     $out .= "\n<BR>" . '&nbsp;' x 5 . NAMED_ANS_RADIO(NEW_ANS_NAME($num), $ans, $ans);
  421 #     foreach $ans (@answers) {
  422 #        $out.= "\n<BR>" . '&nbsp;' x 5 . NAMED_ANS_RADIO_OPTION(ANS_NUM_TO_NAME($num), $ans, $ans);
  423 #     }
  424 #     $out .= "<br>\n";
  425 #   } elsif ($main::displayMode eq 'Latex2HTML') {
  426 #     my $ans = shift @answers;
  427 #     $out .= "\\begin{rawhtml}<BR>\\end{rawhtml}" . NAMED_ANS_RADIO(NEW_ANS_NAME($num), $ans, $ans);
  428 #     foreach $ans (@answers) {
  429 #        $out.= "\\begin{rawhtml}<BR>\\end{rawhtml}" . NAMED_ANS_RADIO_OPTION(ANS_NUM_TO_NAME($num), $ans, $ans);
  430 #     }
  431 #     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  432 #   }  elsif ($main::displayMode eq 'TeX') {
  433 #     $out = "\n\\par\\begin{itemize}\n";
  434 #     my $ans;
  435 #     foreach $ans (@answers) {
  436 #       $out .= "\\item[" . $ans . "\n";
  437 #     }
  438 #     $out .= "\\end{itemize}\n";
  439 #   } else {
  440 #     $out = "Error: PGchoicemacros: match_questions_list_varbox: Unknown displayMode: $main::displayMode.\n";
  441 #   }
  442 #   $out;
  443 #
  444 # }
  445 
  446 
  447 #Alternate method of printing answers as a list of radio buttons for multiple choice
  448 sub radio_print_a {
  449     my $self = shift;
  450     my (@answers) = @_;
  451     my $out = "";
  452   my $i =0;
  453     my @in = ();
  454   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  455     foreach my $ans (@answers) {
  456       push (@in, ($main::ALPHABET[$i], "<B> $main::ALPHABET[$i]. </B> $ans"));
  457       $i++;
  458     }
  459     my @radio_buttons = ans_radio_buttons(@in);
  460     $out = "\n<BR>" . join "\n<BR>", @radio_buttons;
  461     $out .= "<BR>\n";
  462   } elsif ($main::displayMode eq 'Latex2HTML') {
  463     foreach my $ans (@answers) {
  464       push (@in, ($main::ALPHABET[$i], "\\begin{rawhtml}<B> $main::ALPHABET[$i]. </B> \\end{rawhtml} $ans"));
  465       $i++;
  466     }
  467     my @radio_buttons = ans_radio_buttons(@in);
  468     $out = "\\begin{rawhtml}<BR>\\end{rawhtml}" . join "\\begin{rawhtml}<BR>\\end{rawhtml}", @radio_buttons;
  469     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  470   }  elsif ($main::displayMode eq 'TeX') {
  471     foreach my $ans (@answers) {
  472       push (@in, ($main::ALPHABET[$i], "$main::ALPHABET[$i]. $ans"));
  473       $i++;
  474     }
  475     my @radio_buttons = ans_radio_buttons(@in);
  476     #$out = "\n\\par\\begin{itemize}\n";
  477     $out .= join '', @radio_buttons;
  478     #$out .= "\\end{itemize}\n";
  479   } else {
  480     $out = "Error: PGchoicemacros: radio_print_a: Unknown displayMode: $main::displayMode.\n";
  481   }
  482   $out;
  483 
  484 }
  485 
  486 #Second alternate method of printing answers as a list of radio buttons for multiple choice
  487 #Method for naming radio buttons is no longer round about and hackish
  488 sub checkbox_print_a {
  489     my $self = shift;
  490     my (@answers) = @_;
  491     my $out = "";
  492   my $i =0;
  493     my @in = ();
  494   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  495     foreach my $ans (@answers) {
  496       push (@in, ($main::ALPHABET[$i], "<B> $main::ALPHABET[$i]. </B> $ans"));
  497       $i++;
  498     }
  499     my @checkboxes = ans_checkbox(@in);
  500     $out = "\n<BR>" . join "\n<BR>", @checkboxes;
  501     $out .= "<BR>\n";
  502   } elsif ($main::displayMode eq 'Latex2HTML') {
  503     foreach my $ans (@answers) {
  504       push (@in, ($main::ALPHABET[$i], "\\begin{rawhtml}<B> $main::ALPHABET[$i]. </B> \\end{rawhtml} $ans"));
  505       $i++;
  506     }
  507     my @checkboxes = ans_checkbox(@in);
  508     $out = "\\begin{rawhtml}<BR>\\end{rawhtml}" . join "\\begin{rawhtml}<BR>\\end{rawhtml}", @checkboxes;
  509     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  510   }  elsif ($main::displayMode eq 'TeX') {
  511     foreach my $ans (@answers) {
  512       push (@in, ($main::ALPHABET[$i], "$main::ALPHABET[$i]. $ans"));
  513       $i++;
  514     }
  515     my @radio_buttons = ans_checkbox(@in);
  516     #$out = "\n\\par\\begin{itemize}\n";
  517     $out .= join '', @radio_buttons ;
  518     #$out .= "\\end{itemize}\n";
  519   } else {
  520     $out = "Error: PGchoicemacros: checkbox_print_a: Unknown displayMode: $main::displayMode.\n";
  521   }
  522   $out;
  523 
  524 }
  525 
  526 
  527 #Standard method of printing questions in a matching or select list
  528 sub std_print_q {
  529     my $self = shift;
  530     my (@questions) = @_;
  531     my $length = $self->{ans_rule_len};
  532     my $out = "";
  533   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  534     my $i=1; my $quest;
  535     foreach $quest (@questions) {
  536        $out.= "\n<BR>" . ans_rule($length) . "<B>$i.</B> $quest";
  537        $i++;
  538     }
  539     $out .= "<br>\n";
  540   } elsif ($main::displayMode eq 'Latex2HTML') {
  541     my $i=1; my $quest;
  542     foreach $quest (@questions) {
  543        $out.= " \\begin{rawhtml}<BR>\\end{rawhtml} " . ans_rule($length) . "\\begin{rawhtml}<B>\\end{rawhtml} $i. \\begin{rawhtml}</B>\\end{rawhtml}   $quest"; #"$i.   $quest";
  544        $i++;
  545     }
  546     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  547   }  elsif ($main::displayMode eq 'TeX') {
  548       $out = "\n\\par\\begin{enumerate}\n";
  549       my $i=1; my $quest;
  550     foreach $quest (@questions) {
  551       $out .= "\\item[" . ans_rule($length) . "$i.] $quest\n";
  552       $i++;
  553     }
  554     $out .= "\\end{enumerate}\n";
  555   } else {
  556     $out = "Error: PGchoicemacros: std_print_q: Unknown displayMode: $main::displayMode.\n";
  557   }
  558   $out;
  559 
  560 }
  561 
  562 
  563 #legacy macros
  564 #these are only needed for backward compatibility and should be taken out when no longer needed
  565 #except for NchooseK which has become common enough that it should probably be moved to a
  566 #different macros file and given some documentation
  567 sub qa {
  568   my($questionsRef,$answersRef,@questANDanswer) = @_;
  569   while (@questANDanswer) {
  570     push(@$questionsRef,shift(@questANDanswer));
  571     push(@$answersRef,shift(@questANDanswer));
  572 
  573   }
  574 }
  575 
  576 sub invert {
  577   my @array = @_;
  578   my @out = ();
  579   my $i;
  580   for ($i=0;$i<=$#array;$i++) {
  581     $out[$array[$i]]=$i;
  582   }
  583   @out;
  584 }
  585 
  586 sub NchooseK {
  587   my($n,$k)=@_;;
  588   my @array = 0..($n-1);
  589   my @out = ();
  590   while (@out<$k) {
  591     push(@out, splice(@array,    random(0,$#array,1) ,         1) );
  592   }
  593   @out;
  594 }
  595 
  596 sub shuffle {
  597   my ($i) = @_;
  598   my @out = &NchooseK($i,$i);
  599   @out;
  600 }
  601 
  602 sub match_questions_list {
  603   my (@questions) = @_;
  604   my $out = "";
  605   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  606     my $i=1; my $quest;
  607     foreach $quest (@questions) {
  608        $out.= "\n<BR>" . ans_rule(4) . "<B>$i.</B> $quest";
  609        $i++;
  610     }
  611     $out .= "<br>\n";
  612   } elsif ($main::displayMode eq 'Latex2HTML') {
  613     my $i=1; my $quest;
  614     foreach $quest (@questions) {
  615        $out.= " \\begin{rawhtml}<BR>\\end{rawhtml} " . ans_rule(4) . "\\begin{rawhtml}<B>\\end{rawhtml} $i. \\begin{rawhtml}</B>\\end{rawhtml}   $quest"; #"$i.   $quest";
  616        $i++;
  617     }
  618     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  619   } elsif ($main::displayMode eq 'TeX') {
  620       $out = "\n\\par\\begin{enumerate}\n";
  621       my $i=1; my $quest;
  622     foreach $quest (@questions) {
  623       $out .= "\\item[" . ans_rule(3) . "$i.] $quest\n";
  624       $i++;
  625       }
  626     $out .= "\\end{enumerate}\n";
  627   } else {
  628     $out = "Error: PGchoicemacros: match_questions_list: Unknown displayMode: $main::displayMode.\n";
  629   }
  630   $out;
  631 }
  632 
  633 
  634 
  635 sub match_questions_list_varbox {
  636   my ($length, @questions) = @_;
  637   my $out = "";
  638   if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') {
  639     my $i=1; my $quest;
  640     foreach $quest (@questions) {
  641       $out.=  "\n<BR>" . ans_rule($length) . "<B>$i.</B> $quest";
  642       $i++;
  643     }
  644     $out .= "<br>\n";
  645   } elsif ($main::displayMode eq 'Latex2HTML') {
  646     my $i=1; my $quest;
  647     foreach $quest (@questions) {
  648       $out.=  " \\begin{rawhtml}<BR>\\end{rawhtml} " . ans_rule($length) . "\\begin{rawhtml}<B>\\end{rawhtml} $i. \\begin{rawhtml}</B>\\end{rawhtml}   $quest"; #"$i.   $quest";
  649       $i++;
  650     }
  651     $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} ";
  652   } elsif ($main::displayMode eq 'TeX') {
  653     $out = "\n\\par\\begin{enumerate}\n";
  654     my $i=1; my $quest;
  655     foreach $quest (@questions) {
  656       $out .= "\\item[" . ans_rule($length) . "$i.] $quest\n";
  657       $i++;
  658     }
  659     $out .= "\\end{enumerate}\n";
  660   } else {
  661     $out = "Error: PGchoicemacros: match_questions_list_varbox: Unknown displayMode: $main::displayMode.\n";
  662   }
  663   $out;
  664 }
  665 
  666 
  667 
  668 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9