Parent Directory
|
Revision Log
remove unneccsary shebang lines Arnie
1 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 =pod 17 18 There are two types of choice macros. The older versions are simply scripts. 19 The newer versions involve the "List.pm" class and its sub-classes 20 and the use of objects based on these classes. The list sub-classes are: 21 "Match.pm" which aids in setting up matching question 22 and answer lists, "Select.pm" which aids in selecting 23 and presenting a subset of questions with short answers 24 (e.g. true/false questions) from a larger question set, and 25 "Multiple.pm" which aids in setting up a 26 standard style, one question, many answers type multiple 27 choice question. 28 29 30 =head1 DESCRIPTION 31 32 Sample usage: 33 34 35 $ml = new_match_list(); 36 # enter three questions and their answers 37 $ml->qa( "What color is a rose?", 38 "Red", 39 "What color is the sky?", 40 "Blue", 41 "What color is the sea?", 42 "Green" 43 ); 44 # choose two of these questions, ordered at random, 45 # which will be printed in the problem. 46 $ml->choose(2); 47 BEGIN_TEXT 48 Match the answers below with these questions:$BR 49 \\{$ml->print_q\\} $BR 50 Answers: 51 \\{$ml->print_a\\} 52 END_TEXT 53 54 ANS( $ml->ra_correct_ans() ); 55 56 =cut 57 58 59 =head2 Matching List macros 60 61 62 =head3 new_match_list 63 64 Matching list object creation macro 65 66 Usage: 67 68 69 $ml = new_match_list(); 70 71 Which is short hand for the following direct call to Match 72 73 $ml = new Match(random(1,2000,1), ~~&std_print_q, ~~&std_print_a); 74 75 76 Either call will create a matching list object in the variable $ml. 77 (I< Note: $ml cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT block.>) 78 79 The first argument is the seed for the match list (choosen at random between 1 and 2000 in 80 the example above.). The next two arguments are references to the print subroutines 81 used to print the questions and the answers. 82 Other printing methods can be used instead of the standard ones. An 83 example of how to do this is demonstrated with 84 "pop_up_list_print_q" below. 85 86 =head4 std_print_q 87 88 Standard method for formatting a list of questions with answer blanks. 89 90 This formatting routine is the default method for formatting the 91 way questions are printed 92 for each of the three sub-classes of "List.pm". It lists the questions vertically, numbering 93 them sequentially and providing an answer blank before each question. 94 C<std_print_q> checks which mode the user is trying to print the 95 questions from and returns the appropriately formatted string. 96 97 The length of the answer blank can be set with C<$ml-> 98 99 To replace the standard question formatting method with your own, use: 100 101 $ml->rf_print_q(~~&my_question_format_method) 102 103 Your method should be a subroutine of the form C<my_question_format_method($self, @questions)> 104 and should return a string to be printed. The @questions array contains the 105 questions to be listed, while $self can be used to obtain extra information from 106 the object for formatting purposes. The variable C<$main::displayMode> contains the 107 current display mode. (See "MODES" for more details on display modes and 108 see "writing print methods for lists" for details on constructing formatting subroutines.) 109 110 111 =head4 std_print_a 112 113 Standard method for formatting a list of answers. 114 115 This simple formatting routine is the default method for formatting 116 the answers for matching lists. It lists the answers vertically 117 lettered sequentially. 118 119 To replace the standard answer formatting method with your own subroutine use: 120 121 $ml->rf_print_q(~~&my_answer_format_method) 122 123 The answer formatting method has the same interface as the question formatting 124 method. 125 126 127 =head2 Select List macros 128 129 130 =head3 new_select_list 131 132 Select list object creation macro 133 134 Usage: 135 136 $sl = new_select_list; 137 138 Which is equivalent to this direct call to Select 139 140 $sl = new Select(random(1,2000,1), ~~&std_print_q, ~~&std_print_a); 141 142 143 Either call will create a select list object in the variable $sl. ( Note that 144 $sl cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT 145 block.) The printing methods are the same as those defined for C<new_match_list> 146 above. 147 See the documentation for "Select.pm" to see how to use this 148 object to create a true/false question. 149 150 std_print_a is only intended to be used for debugging with select lists, as there is rarely a reason to 151 print out the answers to a select list. 152 153 154 =head3 new_pop_up_select_list 155 156 157 158 Usage: 159 160 $sl = new_pop_up_select_list;</I></PRE> 161 162 Which is equivalent to this direct call to Select 163 164 $sl = new Select(random(1,2000,1), ~~&pop_up_list_print_q, ~~&std_print_a); 165 166 167 Either call will create a select list object in the variable $sl. ( Note that 168 $sl cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT 169 block.) The printing methods are passed as references (~~ in PG equals \ in 170 perl) to subroutines so that no matter what printing subroutines are used, 171 those subroutines can be used by saying $sl->print_q and $sl->print_a. This 172 also means that other subroutines can be used instead of the default ones. 173 174 See the documentation for <a href='Select'>Select.pm</a> to see how to use this 175 object to create a true/false question. 176 177 178 =head4 std_print_q 179 180 Standard method for printing questions with answer boxes 181 182 See std_print_q under Matching Lists above. 183 184 185 =head4 pop_up_list_print_q 186 187 Alternate method for print questions with pop up lists. 188 189 Usage: 190 191 This printing routine is used to print the questions for a true/false or other 192 select list with a preceding pop up list of possible answers. A list of values 193 and labels need to be given to the pop_up_list so that the intended answer is 194 returned when a student selects an answer form the list. Notethe use of => to 195 associate the values on the left with the labels on the right, this means that, 196 for instance, the student will see the word True in the pop_up_list but the 197 answer that is returned to the grader is T, so that it corresponds with what 198 the professor typed in as the answer when using $sl->qa('blah blah', 'T'); 199 200 =for html 201 <PRE> 202 <I>$sl->ra_pop_up_list([</I>value<I> => </I>label<I>, 203 T => 'True', 204 F => 'False']);</I></PRE> 205 206 207 =head4 std_print_a 208 209 This is only intended to be used for debugging as there is rarely a reason to 210 print out the answers to a select list. 211 212 See std_print_a under Matching Lists above. 213 214 215 =head2 Multiple Choice macros 216 217 218 =head3 new_multiple_choice 219 220 Multiple choice object creation macro 221 222 Usage: 223 224 =for html 225 <PRE> 226 <I>$mc = new_multiple_choice;</I></PRE> 227 228 Which is equivalent to this direct call to Multiple 229 230 =for html 231 <PRE> 232 <I>$mc = new Multiple(random(1,2000,1), ~~&std_print_q, ~~&std_print_a);</I></PRE> 233 234 Either call will create a multiple choice object in the variable $mc. Note that 235 $mc cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT 236 block. 237 238 =for html 239 <P>See the documentation for <a href='Multiple'>Multiple.pm</a> to see how to use 240 this object to create a multiple choice question. 241 242 243 =head4 std_print_q 244 245 Standard method for printing questions 246 247 See std_print_q under Matching Lists above. 248 249 250 =head4 radio_print_a 251 252 Method for printing answers with radio buttons 253 254 This simple printing routine is used to print the answers to multiple choice 255 questions in a bulleted style with radio buttons preceding each possible answer. 256 When a multiple choice object is created, a reference to radio_print_a is passed 257 to that object so that it can be used from within the object later. 258 259 radio_print_a checks which mode the user is trying to print the answers from and 260 returns the appropriately formatted string. 261 262 263 =head3 new_checkbox_multiple_choice 264 265 Checkbox multiple choice object creation macro 266 267 Usage: 268 269 =for html 270 <PRE> 271 <I>$cmc = new_checkbox_multiple_choice;</I></PRE> 272 273 Which is equivalent to this direct call to Multiple 274 275 =for html 276 <PRE> 277 <I>$cmc = new Multiple(random(1,2000,1), ~~&std_print_q, ~~&checkbox_print_a);</I></PRE> 278 279 Either call will create a checkbox multiple choice object in the variable $cmc. Note that 280 $cmc cannot be a my variable if it is to be used within a BEGIN_TEXT/END_TEXT 281 block. 282 283 =for html 284 <P>See the documentation for <a href='Multiple'>Multiple.pm</a> to see how to use 285 this object to create a multiple choice question. 286 287 288 =head4 std_print_q 289 290 Standard method for printing questions 291 292 See std_print_q under Matching Lists above. 293 294 295 =head4 checkbox_print_a 296 297 Method for printing answers with radio buttons 298 299 This simple printing routine is used to print the answers to multiple choice 300 questions in a bulleted style with checkboxes preceding each possible answer. 301 When a multiple choice object is created, a reference to checkbox_print_a is passed 302 to that object so that it can be used from within the object later. 303 304 checkbox_print_a checks which mode the user is trying to print the answers from and 305 returns the appropriately formatted string. 306 307 308 309 =cut 310 BEGIN { 311 be_strict(); 312 } 313 sub _PGchoicemacros_init{ 314 } 315 316 =head4 new_match_list 317 318 Usage: $ml = new_match_list(); 319 320 321 Note that $ml cannot be a my variable if used within a BEGIN_TEXT/END_TEXT block 322 323 =cut 324 325 sub new_match_list { 326 new Match(random(1,2000,1), \&std_print_q, \&std_print_a); 327 } 328 329 =head4 new_select_list 330 sage: $sl = new_select_list(); 331 332 Note that $sl cannot be a my variable if used within a BEGIN_TEXT/END_TEXT block 333 334 =cut 335 336 sub new_select_list { 337 new Select(random(1,2000,1), \&std_print_q, \&std_print_a); 338 } 339 340 =head4 new_pop_up_select_list; 341 342 Usage: $pusl = new_pop_up_select_list(); 343 344 =cut 345 346 sub new_pop_up_select_list { 347 new Select(random(1,2000,1), \&pop_up_list_print_q, \&std_print_a); 348 } 349 350 =head4 new_multiple_choice 351 352 Usage: $mc = new_multiple_choice(); 353 354 =cut 355 356 357 sub new_multiple_choice { 358 new Multiple(random(1,2000,1), \&std_print_q, \&radio_print_a); 359 } 360 361 =head4 new_checkbox_multiple_choice 362 363 Usage: $mcc = new_checkbox_multiple_choice(); 364 365 =cut 366 367 sub new_checkbox_multiple_choice { 368 new Multiple(random(1,2000,1), \&std_print_q, \&checkbox_print_a); 369 } 370 371 =head4 initializing a pop_up_list 372 373 Usage: $sl->rf_print_a(~~&pop_up_list_print_q); 374 $sl->ra_pop_up_list([</I>value<I> => </I>label<I>, T => 'True', F => 'False']); 375 376 =cut 377 378 sub pop_up_list_print_q { 379 my $self = shift; 380 my (@questions) = @_; 381 my $length = $self->{ans_rule_len}; 382 my @list = @{$self->{ra_pop_up_list} }; 383 my $out = ""; 384 385 #if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') { 386 if ($main::displayMode =~ /^HTML/) { 387 my $i=1; my $quest; 388 foreach $quest (@questions) { 389 $out.= "\n<p>" . pop_up_list(@list) . " <B>$i.</B> $quest"; 390 $i++; 391 } 392 $out .= "<br>\n"; 393 } elsif ($main::displayMode eq 'Latex2HTML') { 394 my $i=1; my $quest; 395 foreach $quest (@questions) { 396 $out.= " \\begin{rawhtml}<p><B>\\end{rawhtml}" . pop_up_list(@list) . " $i. \\begin{rawhtml}</B>\\end{rawhtml} $quest"; 397 $i++; 398 } 399 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 400 } elsif ($main::displayMode eq 'TeX') { 401 $out = "\n\\par\\begin{enumerate}\n"; 402 my $i=1; my $quest; 403 foreach $quest (@questions) { 404 $out .= "\\item[" . pop_up_list(@list) . "$i.] $quest\n"; 405 $i++; 406 } 407 $out .= "\\end{enumerate}\n"; 408 } else { 409 $out = "Error: PGchoicemacros: pop_up_list_print_q: Unknown displayMode: $main::displayMode.\n"; 410 } 411 $out; 412 413 } 414 415 416 # For graphs in a matching question. 417 418 #sub format_graphs { 419 # my $self = shift; 420 # my @in = @_; 421 # my $out = ""; 422 # while (@in) { 423 # $out .= shift(@in). "#" ; 424 # } 425 # $out; 426 #} 427 428 429 # To put pop-up-list at the end of a question. 430 # contributed by Mark Schmitt 3-6-03 431 432 sub quest_first_pop_up_list_print_q { 433 my $self = shift; 434 my (@questions) = @_; 435 my $length = $self->{ans_rule_len}; 436 my @list = @{$self->{ra_pop_up_list} }; 437 my $out = ""; 438 439 if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth' 440 || $main::displayMode eq 'HTML_dpng'|| $main::displayMode eq 'HTML_img') { 441 my $i=1; my $quest; 442 foreach $quest (@questions) { 443 $out.= "\n<p>" . " $quest" . pop_up_list(@list); 444 $i++; 445 } 446 $out .= "<br>\n"; 447 } elsif ($main::displayMode eq 'Latex2HTML') { 448 my $i=1; my $quest; 449 foreach $quest (@questions) { 450 $out.= " \\begin{rawhtml}<p><B>\\end{rawhtml}" . pop_up_list(@list) . " $i. \\begin{rawhtml}</B>\\end{rawhtml} $quest"; 451 $i++; 452 } 453 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 454 } elsif ($main::displayMode eq 'TeX') { 455 $out = "\n\\par\\begin{enumerate}\n"; 456 my $i=1; my $quest; 457 foreach $quest (@questions) { 458 $out .= "\\item[" . pop_up_list(@list) . "$i.] $quest\n"; 459 $i++; 460 } 461 $out .= "\\end{enumerate}\n"; 462 } else { 463 $out = "Error: PGchoicemacros: pop_up_list_print_q: Unknown displayMode: $main::displayMode.\n"; 464 } 465 $out; 466 467 } 468 # To put pop-up-list in the middle of a question. 469 # contributed by Mark Schmitt 3-6-03 470 471 sub ans_in_middle_pop_up_list_print_q { 472 my $self = shift; 473 my (@questions) = @_; 474 my $length = $self->{ans_rule_len}; 475 my @list = @{$self->{ra_pop_up_list} }; 476 my $out = ""; 477 478 if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth' 479 || $main::displayMode eq 'HTML_dpng'|| $main::displayMode eq 'HTML_img') { 480 my $i=1; my $quest; 481 foreach $quest (@questions) { 482 $out.= "" . " $quest" . pop_up_list(@list); 483 $i++; 484 } 485 $out .= ""; 486 } elsif ($main::displayMode eq 'Latex2HTML') { 487 my $i=1; my $quest; 488 foreach $quest (@questions) { 489 $out.= " \\begin{rawhtml}<p><B>\\end{rawhtml}" . pop_up_list(@list) . " $i. \\begin{rawhtml}</B>\\end{rawhtml} $quest"; 490 $i++; 491 } 492 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 493 } elsif ($main::displayMode eq 'TeX') { 494 $out = "\n\\par\\begin{enumerate}\n"; 495 my $i=1; my $quest; 496 foreach $quest (@questions) { 497 $out .= "\\item[" . pop_up_list(@list) . "$i.] $quest\n"; 498 $i++; 499 } 500 $out .= "\\end{enumerate}\n"; 501 } else { 502 $out = "Error: PGchoicemacros: pop_up_list_print_q: Unknown displayMode: $main::displayMode.\n"; 503 } 504 $out; 505 506 } 507 508 509 # Units for physics class 510 # contributed by Mark Schmitt 3-6-03 511 512 sub units_list_print_q { 513 my $self = shift; 514 my (@questions) = @_; 515 my $length = $self->{ans_rule_len}; 516 my @list = @{$self->{ra_pop_up_list} }; 517 my $out = ''; 518 519 $out.= pop_up_list(@list); 520 521 $out; 522 } 523 524 #Standard method of printing answers in a matching list 525 sub std_print_a { 526 my $self = shift; 527 my(@array) = @_; 528 my $i = 0; 529 my $out= &main::M3( 530 "\\begin{enumerate}\n", 531 " \\begin{rawhtml} <OL TYPE=\"A\" VALUE=\"1\"> \\end{rawhtml} ", 532 "<OL COMPACT TYPE=\"A\" START=\"1\">\n" 533 ) ; 534 my $elem; 535 foreach $elem (@array) { 536 $out .= &main::M3( 537 "\\item[$main::ALPHABET[$i].] $elem\n", 538 " \\begin{rawhtml} <LI> \\end{rawhtml} $elem ", 539 "<LI> $elem\n" 540 ) ; 541 $i++; 542 } 543 $out .= &main::M3( 544 "\\end{enumerate}\n", 545 " \\begin{rawhtml} </OL>\n \\end{rawhtml} ", 546 "</OL>\n" 547 ) ; 548 $out; 549 550 } 551 552 553 554 555 #Alternate method of printing answers as a list of radio buttons for multiple choice 556 sub radio_print_a { 557 my $self = shift; 558 my (@answers) = @_; 559 my $out = ""; 560 my $i =0; 561 my @in = (); 562 #if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') { 563 if ($main::displayMode =~ /^HTML/) { 564 foreach my $ans (@answers) { 565 push (@in, ($main::ALPHABET[$i], "<B> $main::ALPHABET[$i]. </B> $ans")); 566 $i++; 567 } 568 my @radio_buttons = ans_radio_buttons(@in); 569 $out = "\n<BR>" . join "\n<BR>", @radio_buttons; 570 $out .= "<BR>\n"; 571 } elsif ($main::displayMode eq 'Latex2HTML') { 572 foreach my $ans (@answers) { 573 push (@in, ($main::ALPHABET[$i], "\\begin{rawhtml}<B> $main::ALPHABET[$i]. </B> \\end{rawhtml} $ans")); 574 $i++; 575 } 576 my @radio_buttons = ans_radio_buttons(@in); 577 $out = "\\begin{rawhtml}<BR>\\end{rawhtml}" . join "\\begin{rawhtml}<BR>\\end{rawhtml}", @radio_buttons; 578 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 579 } elsif ($main::displayMode eq 'TeX') { 580 foreach my $ans (@answers) { 581 push (@in, ($main::ALPHABET[$i], "$main::ALPHABET[$i]. $ans")); 582 $i++; 583 } 584 my @radio_buttons = ans_radio_buttons(@in); 585 #$out = "\n\\par\\begin{itemize}\n"; 586 $out .= join '', @radio_buttons; 587 #$out .= "\\end{itemize}\n"; 588 } else { 589 $out = "Error: PGchoicemacros: radio_print_a: Unknown displayMode: $main::displayMode.\n"; 590 } 591 $out; 592 593 } 594 595 #Second alternate method of printing answers as a list of radio buttons for multiple choice 596 #Method for naming radio buttons is no longer round about and hackish 597 sub checkbox_print_a { 598 my $self = shift; 599 my (@answers) = @_; 600 my $out = ""; 601 my $i =0; 602 my @in = (); 603 # if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') { 604 if ($main::displayMode =~ /^HTML/) { 605 foreach my $ans (@answers) { 606 push (@in, ($main::ALPHABET[$i], "<B> $main::ALPHABET[$i]. </B> $ans")); 607 $i++; 608 } 609 my @checkboxes = ans_checkbox(@in); 610 $out = "\n<BR>" . join "\n<BR>", @checkboxes; 611 $out .= "<BR>\n"; 612 } elsif ($main::displayMode eq 'Latex2HTML') { 613 foreach my $ans (@answers) { 614 push (@in, ($main::ALPHABET[$i], "\\begin{rawhtml}<B> $main::ALPHABET[$i]. </B> \\end{rawhtml} $ans")); 615 $i++; 616 } 617 my @checkboxes = ans_checkbox(@in); 618 $out = "\\begin{rawhtml}<BR>\\end{rawhtml}" . join "\\begin{rawhtml}<BR>\\end{rawhtml}", @checkboxes; 619 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 620 } elsif ($main::displayMode eq 'TeX') { 621 foreach my $ans (@answers) { 622 push (@in, ($main::ALPHABET[$i], "$main::ALPHABET[$i]. $ans")); 623 $i++; 624 } 625 my @radio_buttons = ans_checkbox(@in); 626 #$out = "\n\\par\\begin{itemize}\n"; 627 $out .= join '', @radio_buttons ; 628 #$out .= "\\end{itemize}\n"; 629 } else { 630 $out = "Error: PGchoicemacros: checkbox_print_a: Unknown displayMode: $main::displayMode.\n"; 631 } 632 $out; 633 634 } 635 636 637 #Standard method of printing questions in a matching or select list 638 sub std_print_q { 639 my $self = shift; 640 my (@questions) = @_; 641 my $length = $self->{ans_rule_len}; 642 my $out = ""; 643 #if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') { 644 if ($main::displayMode =~ /^HTML/) { 645 my $i=1; my $quest; 646 foreach $quest (@questions) { 647 $out.= "\n<BR>" . ans_rule($length) . "<B>$i.</B> $quest"; 648 $i++; 649 } 650 $out .= "<br>\n"; 651 } elsif ($main::displayMode eq 'Latex2HTML') { 652 my $i=1; my $quest; 653 foreach $quest (@questions) { 654 $out.= " \\begin{rawhtml}<BR>\\end{rawhtml} " . ans_rule($length) . "\\begin{rawhtml}<B>\\end{rawhtml} $i. \\begin{rawhtml}</B>\\end{rawhtml} $quest"; #"$i. $quest"; 655 $i++; 656 } 657 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 658 } elsif ($main::displayMode eq 'TeX') { 659 $out = "\n\\par\\begin{enumerate}\n"; 660 my $i=1; my $quest; 661 foreach $quest (@questions) { 662 $out .= "\\item[" . ans_rule($length) . "$i.] $quest\n"; 663 $i++; 664 } 665 $out .= "\\end{enumerate}\n"; 666 } else { 667 $out = "Error: PGchoicemacros: std_print_q: Unknown displayMode: $main::displayMode.\n"; 668 } 669 $out; 670 671 } 672 673 674 675 =head3 legacy macros 676 677 These are maintained for backward compatibility. 678 They can still be useful in constructing non-standard lists that don't fit 679 the various list objects. In general the using the list objects is likely 680 to give better results and is preferred. 681 682 =cut 683 684 =head4 qa 685 686 =cut 687 688 sub qa { 689 my($questionsRef,$answersRef,@questANDanswer) = @_; 690 while (@questANDanswer) { 691 push(@$questionsRef,shift(@questANDanswer)); 692 push(@$answersRef,shift(@questANDanswer)); 693 694 } 695 } 696 697 =head4 invert 698 699 =cut 700 701 sub invert { 702 my @array = @_; 703 my @out = (); 704 my $i; 705 for ($i=0;$i<=$#array;$i++) { 706 $out[$array[$i]]=$i; 707 } 708 @out; 709 } 710 711 =head4 NchooseK 712 713 =cut 714 715 sub NchooseK { 716 my($n,$k)=@_;; 717 my @array = 0..($n-1); 718 my @out = (); 719 while (@out<$k) { 720 push(@out, splice(@array, random(0,$#array,1) , 1) ); 721 } 722 @out; 723 } 724 725 =head4 shuffle 726 727 =cut 728 729 sub shuffle { 730 my ($i) = @_; 731 my @out = &NchooseK($i,$i); 732 @out; 733 } 734 735 =head4 match_questions_list 736 737 =cut 738 739 sub match_questions_list { 740 my (@questions) = @_; 741 my $out = ""; 742 #if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') { 743 if ($main::displayMode =~ /^HTML/) { 744 my $i=1; my $quest; 745 foreach $quest (@questions) { 746 $out.= "\n<BR>" . ans_rule(4) . "<B>$i.</B> $quest"; 747 $i++; 748 } 749 $out .= "<br>\n"; 750 } elsif ($main::displayMode eq 'Latex2HTML') { 751 my $i=1; my $quest; 752 foreach $quest (@questions) { 753 $out.= " \\begin{rawhtml}<BR>\\end{rawhtml} " . ans_rule(4) . "\\begin{rawhtml}<B>\\end{rawhtml} $i. \\begin{rawhtml}</B>\\end{rawhtml} $quest"; #"$i. $quest"; 754 $i++; 755 } 756 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 757 } elsif ($main::displayMode eq 'TeX') { 758 $out = "\n\\par\\begin{enumerate}\n"; 759 my $i=1; my $quest; 760 foreach $quest (@questions) { 761 $out .= "\\item[" . ans_rule(3) . "$i.] $quest\n"; 762 $i++; 763 } 764 $out .= "\\end{enumerate}\n"; 765 } else { 766 $out = "Error: PGchoicemacros: match_questions_list: Unknown displayMode: $main::displayMode.\n"; 767 } 768 $out; 769 } 770 771 772 773 sub match_questions_list_varbox { 774 my ($length, @questions) = @_; 775 my $out = ""; 776 #if ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth') { 777 if ($main::displayMode =~ /^HTML/) { 778 my $i=1; my $quest; 779 foreach $quest (@questions) { 780 $out.= "\n<BR>" . ans_rule($length) . "<B>$i.</B> $quest"; 781 $i++; 782 } 783 $out .= "<br>\n"; 784 } elsif ($main::displayMode eq 'Latex2HTML') { 785 my $i=1; my $quest; 786 foreach $quest (@questions) { 787 $out.= " \\begin{rawhtml}<BR>\\end{rawhtml} " . ans_rule($length) . "\\begin{rawhtml}<B>\\end{rawhtml} $i. \\begin{rawhtml}</B>\\end{rawhtml} $quest"; #"$i. $quest"; 788 $i++; 789 } 790 $out .= " \\begin{rawhtml}<BR>\\end{rawhtml} "; 791 } elsif ($main::displayMode eq 'TeX') { 792 $out = "\n\\par\\begin{enumerate}\n"; 793 my $i=1; my $quest; 794 foreach $quest (@questions) { 795 $out .= "\\item[" . ans_rule($length) . "$i.] $quest\n"; 796 $i++; 797 } 798 $out .= "\\end{enumerate}\n"; 799 } else { 800 $out = "Error: PGchoicemacros: match_questions_list_varbox: Unknown displayMode: $main::displayMode.\n"; 801 } 802 $out; 803 } 804 805 806 807 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |