[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 1155 Revision 1462
23BEGIN{ 23BEGIN{
24 be_strict; 24 be_strict;
25} 25}
26 26
27 27
28my $displayMode=$main::displayMode; 28my $displayMode;
29 29
30my ($PAR, 30my ($PAR,
31 $BR, 31 $BR,
32 $LQ, 32 $LQ,
33 $RQ, 33 $RQ,
61 $PERCENT, 61 $PERCENT,
62 $CARET, 62 $CARET,
63 $PI, 63 $PI,
64 $E, 64 $E,
65 @ALPHABET, 65 @ALPHABET,
66 $envir,
67 $PG_random_generator,
68 $inputs_ref,
69 $rh_sticky_answers,
70 $r_ans_rule_count,
66 ); 71 );
67 72
68sub _PGbasicmacros_init { 73sub _PGbasicmacros_init {
74
75 # The big problem is that at compile time in the cached Safe compartment
76 # main:: has one definition, probably Safe::Root1::
77 # At runtime main has another definition Safe::Rootx:: where x is > 1
78
79 # It is important to
80 # initialize the my variable version of $displayMode from the "runtime" version
81 # of main::displayMode
82
83 $displayMode = main::PG_restricted_eval(q!$main::displayMode!);
84
85# This is initializes the remaining variables in the runtime main:: compartment.
86
87main::PG_restricted_eval( <<'EndOfFile');
69 $displayMode =$main::displayMode; 88 $displayMode = $displayMode;
89
70 $main::PAR = PAR(); 90 $main::PAR = PAR();
71 $main::BR = BR(); 91 $main::BR = BR();
72 $main::LQ = LQ(); 92 $main::LQ = LQ();
73 $main::RQ = RQ(); 93 $main::RQ = RQ();
74 $main::BM = BM(); 94 $main::BM = BM();
101 $main::PERCENT = PERCENT(); 121 $main::PERCENT = PERCENT();
102 $main::CARET = CARET(); 122 $main::CARET = CARET();
103 $main::PI = PI(); 123 $main::PI = PI();
104 $main::E = E(); 124 $main::E = E();
105 @main::ALPHABET = ('A'..'ZZ'); 125 @main::ALPHABET = ('A'..'ZZ');
126 %main::STICKY_ANSWERS = ();
106 127
128
129EndOfFile
130
131# Next we transfer the correct definitions in the main:: compartment to the local my variables
132# This can't be done inside the eval above because my variables seem to be invisible inside the eval
133
134
107 $PAR = PAR(); 135 $PAR = PAR();
108 $BR = BR(); 136 $BR = BR();
109 $LQ = LQ(); 137 $LQ = LQ();
110 $RQ = RQ(); 138 $RQ = RQ();
111 $BM = BM(); 139 $BM = BM();
112 $EM = EM(); 140 $EM = EM();
113 $BDM = BDM(); 141 $BDM = BDM();
114 $EDM = EDM(); 142 $EDM = EDM();
115 $LTS = LTS(); 143 $LTS = LTS();
116 $GTS = GTS(); 144 $GTS = GTS();
117 $LTE = LTE(); 145 $LTE = LTE();
118 $GTE = GTE(); 146 $GTE = GTE();
119 $BEGIN_ONE_COLUMN = BEGIN_ONE_COLUMN(); 147 $BEGIN_ONE_COLUMN = BEGIN_ONE_COLUMN();
120 $END_ONE_COLUMN = END_ONE_COLUMN(); 148 $END_ONE_COLUMN = END_ONE_COLUMN();
121 $SOL = SOLUTION_HEADING(); 149 $SOL = SOLUTION_HEADING();
122 $SOLUTION = SOLUTION_HEADING(); 150 $SOLUTION = SOLUTION_HEADING();
123 $HINT = HINT_HEADING(); 151 $HINT = HINT_HEADING();
124 $US = US(); 152 $US = US();
125 $SPACE = SPACE(); 153 $SPACE = SPACE();
126 $BBOLD = BBOLD(); 154 $BBOLD = BBOLD();
127 $EBOLD = EBOLD(); 155 $EBOLD = EBOLD();
156 $BITALIC = BITALIC();
157 $EITALIC = EITALIC();
158 $BCENTER = BCENTER();
159 $ECENTER = ECENTER();
128 $HR = HR(); 160 $HR = HR();
129 $LBRACE = LBRACE(); 161 $LBRACE = LBRACE();
130 $RBRACE = RBRACE(); 162 $RBRACE = RBRACE();
131 $LB = LB(); 163 $LB = LB();
132 $RB = RB(); 164 $RB = RB();
133 $DOLLAR = DOLLAR(); 165 $DOLLAR = DOLLAR();
134 $PERCENT = PERCENT(); 166 $PERCENT = PERCENT();
135 $CARET = CARET(); 167 $CARET = CARET();
136 $PI = PI(); 168 $PI = PI();
137 $E = E(); 169 $E = E();
138 @ALPHABET = ('A'..'ZZ'); 170 @ALPHABET = ('A'..'ZZ');
139 171
140 172 $envir = PG_restricted_eval(q!\%main::envir!);
141 173 $PG_random_generator = PG_restricted_eval(q!$main::PG_random_generator!);
174 $inputs_ref = $envir{inputs_ref};
175 $rh_sticky_answers = PG_restricted_eval(q!\%main::STICKY_ANSWERS!);
176 $r_ans_rule_count = PG_restricted_eval(q!\$ans_rule_count!);
142} 177}
143 178
144=head2 Answer blank macros: 179=head2 Answer blank macros:
145 180
146These produce answer blanks of various sizes or pop up lists or radio answer buttons. 181These produce answer blanks of various sizes or pop up lists or radio answer buttons.
220 ANS_RADIO_OPTION( question_number, value,tag ); # equivalent to NAMED_ANS_RADIO_EXTENSION( ANS_NUM_TO_NAME(number), value,tag) 255 ANS_RADIO_OPTION( question_number, value,tag ); # equivalent to NAMED_ANS_RADIO_EXTENSION( ANS_NUM_TO_NAME(number), value,tag)
221 256
222 257
223=cut 258=cut
224 259
260
261
225sub labeled_ans_rule { # syntactic sugar for NAMED_ANS_RULE 262sub labeled_ans_rule { # syntactic sugar for NAMED_ANS_RULE
226 my($name,$col) = @_; 263 my($name,$col) = @_;
227 $col = 20 unless defined($col); 264 $col = 20 unless defined($col);
228 NAMED_ANS_RULE($name,$col); 265 NAMED_ANS_RULE($name,$col);
229} 266}
230 267
231sub NAMED_ANS_RULE { 268sub NAMED_ANS_RULE {
232 my($name,$col) = @_; 269 my($name,$col) = @_;
233 my $len = 0.07*$col; 270 my $len = 0.07*$col;
234 my $answer_value = ''; 271 my $answer_value = '';
235 $answer_value = ${$main::inputs_ref}{$name} if defined(${$main::inputs_ref}{$name}); 272 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
236 if ($answer_value =~ /\0/ ) { 273 if ($answer_value =~ /\0/ ) {
237 my @answers = split("\0", $answer_value); 274 my @answers = split("\0", $answer_value);
238 $answer_value = shift(@answers); # use up the first answer 275 $answer_value = shift(@answers); # use up the first answer
239 $main::rh_sticky_answers{$name}=\@answers; # store the rest 276 $rh_sticky_answers->{$name}=\@answers;
277 # store the rest -- beacuse this stores to a main:; variable
278 # it must be evaluated at run time
240 $answer_value= '' unless defined($answer_value); 279 $answer_value= '' unless defined($answer_value);
241 } elsif (ref($answer_value) eq 'ARRAY') { 280 } elsif (ref($answer_value) eq 'ARRAY') {
242 my @answers = @{ $answer_value}; 281 my @answers = @{ $answer_value};
243 $answer_value = shift(@answers); # use up the first answer 282 $answer_value = shift(@answers); # use up the first answer
244 $main::rh_sticky_answers{$name}=\@answers; # store the rest 283 $rh_sticky_answers->{$name}=\@answers;
284 # store the rest -- beacuse this stores to a main:; variable
285 # it must be evaluated at run time
245 $answer_value= '' unless defined($answer_value); 286 $answer_value= '' unless defined($answer_value);
246 } 287 }
247 288
248 $answer_value =~ tr/$@`//d; ## make sure student answers can not be interpolated by e.g. EV3 289 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
249 $name = RECORD_ANS_NAME($name); 290 $name = RECORD_ANS_NAME($name);
291
292 # incorporated Davide Cervone's changes
293 # removed newlines from around <INPUT> tags
294 # made TeX rule be based on specified width rather than varying size.
295 my $tcol = $col/2 > 3 ? $col/2 : 3; ## get max
296 $tcol = $tcol < 40 ? $tcol : 40; ## get min
297
250 MODES( 298 MODES(
251 TeX => "\\mbox{\\parbox[t]{10pt}{\\hrulefill}}\\hrulefill\\quad ", 299 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
252 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!, 300 Latex2HTML => qq!\\begin{rawhtml}<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\\end{rawhtml}!,
253 HTML => "<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"$answer_value\">\n" 301 HTML => "<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"$answer_value\">"
254 ); 302 );
255} 303}
256 304
257sub NAMED_ANS_RULE_OPTION { # deprecated 305sub NAMED_ANS_RULE_OPTION { # deprecated
258 &NAMED_ANS_RULE_EXTENSION; 306 &NAMED_ANS_RULE_EXTENSION;
260 308
261sub NAMED_ANS_RULE_EXTENSION { 309sub NAMED_ANS_RULE_EXTENSION {
262 my($name,$col) = @_; 310 my($name,$col) = @_;
263 my $len = 0.07*$col; 311 my $len = 0.07*$col;
264 my $answer_value = ''; 312 my $answer_value = '';
265 $answer_value = ${$main::inputs_ref}{$name} if defined(${$main::inputs_ref}{$name}); 313 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
266 if ( defined($main::rh_sticky_answers{$name}) ) { 314 if ( defined( $rh_sticky_answers->{$name} ) ) {
267 $answer_value = shift( @{$main::rh_sticky_answers{$name}}); 315 $answer_value = shift( @{ $rh_sticky_answers->{$name} });
268 $answer_value = '' unless defined($answer_value); 316 $answer_value = '' unless defined($answer_value);
269 } 317 }
270 $answer_value =~ tr/$@//d; ## make sure student answers can not be interpolated by e.g. EV3 318 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
271 MODES( 319 MODES(
272 TeX => '\\hrulefill\\quad ', 320 TeX => '\\hrulefill\\quad ',
273 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!, 321 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!,
274 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME = "$name" VALUE = "$answer_value">\n! 322 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME = "$name" VALUE = "$answer_value">\n!
275 ); 323 );
288 $col = 80 unless defined($col); 336 $col = 80 unless defined($col);
289 $name = RECORD_ANS_NAME($name); 337 $name = RECORD_ANS_NAME($name);
290 my $len = 0.07*$col; 338 my $len = 0.07*$col;
291 my $height = .07*$row; 339 my $height = .07*$row;
292 my $answer_value = ''; 340 my $answer_value = '';
293 $answer_value = $main::inputs_ref->{$name} if defined( $main::inputs_ref->{$name} ); 341 $answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} );
294 $answer_value =~ tr/$@//d; ## make sure student answers can not be interpolated by e.g. EV3 342 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
295 my $out = M3( 343 my $out = M3(
296 qq!\\vskip $height in \\hrulefill\\quad !, 344 qq!\\vskip $height in \\hrulefill\\quad !,
297 qq!\\begin{rawhtml}<TEXTAREA NAME="$name" ROWS="$row" COLS="$col" 345 qq!\\begin{rawhtml}<TEXTAREA NAME="$name" ROWS="$row" COLS="$col"
298 WRAP="VIRTUAL">$answer_value</TEXTAREA>\\end{rawhtml}!, 346 WRAP="VIRTUAL">$answer_value</TEXTAREA>\\end{rawhtml}!,
299 qq!<TEXTAREA NAME="$name" ROWS="$row" COLS="$col" 347 qq!<TEXTAREA NAME="$name" ROWS="$row" COLS="$col"
316 my $checked = ''; 364 my $checked = '';
317 if ($value =~/^\%/) { 365 if ($value =~/^\%/) {
318 $value =~ s/^\%//; 366 $value =~ s/^\%//;
319 $checked = 'CHECKED' 367 $checked = 'CHECKED'
320 } 368 }
321 if (defined($main::inputs_ref->{$name}) ) { 369 if (defined($inputs_ref->{$name}) ) {
322 if ($main::inputs_ref->{$name} eq $value) { 370 if ($inputs_ref->{$name} eq $value) {
323 $checked = 'CHECKED' 371 $checked = 'CHECKED'
324 } else { 372 } else {
325 $checked = ''; 373 $checked = '';
326 } 374 }
327 375
348 my $checked = ''; 396 my $checked = '';
349 if ($value =~/^\%/) { 397 if ($value =~/^\%/) {
350 $value =~ s/^\%//; 398 $value =~ s/^\%//;
351 $checked = 'CHECKED' 399 $checked = 'CHECKED'
352 } 400 }
353 if (defined($main::inputs_ref->{$name}) ) { 401 if (defined($inputs_ref->{$name}) ) {
354 if ($main::inputs_ref->{$name} eq $value) { 402 if ($inputs_ref->{$name} eq $value) {
355 $checked = 'CHECKED' 403 $checked = 'CHECKED'
356 } else { 404 } else {
357 $checked = ''; 405 $checked = '';
358 } 406 }
359 407
425 if ($value =~/^\%/) { 473 if ($value =~/^\%/) {
426 $value =~ s/^\%//; 474 $value =~ s/^\%//;
427 $checked = 'CHECKED' 475 $checked = 'CHECKED'
428 } 476 }
429 477
430 if (defined($main::inputs_ref->{$name}) ) { 478 if (defined($inputs_ref->{$name}) ) {
431 if ($main::inputs_ref->{$name} eq $value) { 479 if ($inputs_ref->{$name} eq $value) {
432 $checked = 'CHECKED' 480 $checked = 'CHECKED'
433 } 481 }
434 else { 482 else {
435 $checked = ''; 483 $checked = '';
436 } 484 }
454 if ($value =~/^\%/) { 502 if ($value =~/^\%/) {
455 $value =~ s/^\%//; 503 $value =~ s/^\%//;
456 $checked = 'CHECKED' 504 $checked = 'CHECKED'
457 } 505 }
458 506
459 if (defined($main::inputs_ref->{$name}) ) { 507 if (defined($inputs_ref->{$name}) ) {
460 if ($main::inputs_ref->{$name} eq $value) { 508 if ($inputs_ref->{$name} eq $value) {
461 $checked = 'CHECKED' 509 $checked = 'CHECKED'
462 } 510 }
463 else { 511 else {
464 $checked = ''; 512 $checked = '';
465 } 513 }
527} 575}
528 576
529sub ans_rule { 577sub ans_rule {
530 my $len = shift; # gives the optional length of the answer blank 578 my $len = shift; # gives the optional length of the answer blank
531 $len = 20 unless $len ; 579 $len = 20 unless $len ;
532 my $name = NEW_ANS_NAME(++$main::ans_rule_count); 580 my $name = NEW_ANS_NAME(inc_ans_rule_count());
533 NAMED_ANS_RULE($name ,$len); 581 NAMED_ANS_RULE($name ,$len);
534} 582}
535sub ans_rule_extension { 583sub ans_rule_extension {
536 my $len = shift; 584 my $len = shift;
537 $len = 20 unless $len ; 585 $len = 20 unless $len ;
538 my $name = NEW_ANS_NAME($main::ans_rule_count); # don't update the answer name 586 my $name = NEW_ANS_NAME($$r_ans_rule_count); # don't update the answer name
539 NAMED_ANS_RULE($name ,$len); 587 NAMED_ANS_RULE($name ,$len);
540} 588}
541sub ans_radio_buttons { 589sub ans_radio_buttons {
542 my $name = NEW_ANS_NAME(++$main::ans_rule_count); 590 my $name = NEW_ANS_NAME(inc_ans_rule_count());
543 my @radio_buttons = NAMED_ANS_RADIO_BUTTONS($name, @_); 591 my @radio_buttons = NAMED_ANS_RADIO_BUTTONS($name, @_);
544 592
545 if ($displayMode eq 'TeX') { 593 if ($displayMode eq 'TeX') {
546 $radio_buttons[0] = "\n\\begin{itemize}\n" . $radio_buttons[0]; 594 $radio_buttons[0] = "\n\\begin{itemize}\n" . $radio_buttons[0];
547 $radio_buttons[$#radio_buttons] .= "\n\\end{itemize}\n"; 595 $radio_buttons[$#radio_buttons] .= "\n\\end{itemize}\n";
550 (wantarray) ? @radio_buttons: join(" ", @radio_buttons); 598 (wantarray) ? @radio_buttons: join(" ", @radio_buttons);
551} 599}
552 600
553#added 6/14/2000 by David Etlinger 601#added 6/14/2000 by David Etlinger
554sub ans_checkbox { 602sub ans_checkbox {
555 my $name = NEW_ANS_NAME( ++$main::ans_rule_count ); 603 my $name = NEW_ANS_NAME( inc_ans_rule_count() );
556 my @checkboxes = NAMED_ANS_CHECKBOX_BUTTONS( $name, @_ ); 604 my @checkboxes = NAMED_ANS_CHECKBOX_BUTTONS( $name, @_ );
557 605
558 if ($displayMode eq 'TeX') { 606 if ($displayMode eq 'TeX') {
559 $checkboxes[0] = "\n\\begin{itemize}\n" . $checkboxes[0]; 607 $checkboxes[0] = "\n\\begin{itemize}\n" . $checkboxes[0];
560 $checkboxes[$#checkboxes] .= "\n\\end{itemize}\n"; 608 $checkboxes[$#checkboxes] .= "\n\\end{itemize}\n";
569## This will not work with latex2HTML mode since it creates gif equations. 617## This will not work with latex2HTML mode since it creates gif equations.
570 618
571sub tex_ans_rule { 619sub tex_ans_rule {
572 my $len = shift; 620 my $len = shift;
573 $len = 20 unless $len ; 621 $len = 20 unless $len ;
574 my $name = NEW_ANS_NAME(++$main::ans_rule_count); 622 my $name = NEW_ANS_NAME(inc_ans_rule_count());
575 my $answer_rule = NAMED_ANS_RULE($name ,$len); # we don't want to create three answer rules in different modes. 623 my $answer_rule = NAMED_ANS_RULE($name ,$len); # we don't want to create three answer rules in different modes.
576 my $out = MODES( 624 my $out = MODES(
577 'TeX' => $answer_rule, 625 'TeX' => $answer_rule,
578 'Latex2HTML' => '\\fbox{Answer boxes cannot be placed inside typeset equations}', 626 'Latex2HTML' => '\\fbox{Answer boxes cannot be placed inside typeset equations}',
579 'HTML_tth' => '\\begin{rawhtml} '. $answer_rule.'\\end{rawhtml}', 627 'HTML_tth' => '\\begin{rawhtml} '. $answer_rule.'\\end{rawhtml}',
584 $out; 632 $out;
585} 633}
586sub tex_ans_rule_extension { 634sub tex_ans_rule_extension {
587 my $len = shift; 635 my $len = shift;
588 $len = 20 unless $len ; 636 $len = 20 unless $len ;
589 my $name = NEW_ANS_NAME($main::ans_rule_count); 637 my $name = NEW_ANS_NAME($$r_ans_rule_count);
590 my $answer_rule = NAMED_ANS_RULE($name ,$len); # we don't want to create three answer rules in different modes. 638 my $answer_rule = NAMED_ANS_RULE($name ,$len); # we don't want to create three answer rules in different modes.
591 my $out = MODES( 639 my $out = MODES(
592 'TeX' => $answer_rule, 640 'TeX' => $answer_rule,
593 'Latex2HTML' => '\fbox{Answer boxes cannot be placed inside typeset equations}', 641 'Latex2HTML' => '\fbox{Answer boxes cannot be placed inside typeset equations}',
594 'HTML_tth' => '\\begin{rawhtml} '. $answer_rule.'\\end{rawhtml}', 642 'HTML_tth' => '\\begin{rawhtml} '. $answer_rule.'\\end{rawhtml}',
632sub ans_box { 680sub ans_box {
633 my $row = shift; 681 my $row = shift;
634 my $col =shift; 682 my $col =shift;
635 $row = 5 unless $row; 683 $row = 5 unless $row;
636 $col = 80 unless $col; 684 $col = 80 unless $col;
637 my $name = NEW_ANS_NAME(++$main::ans_rule_count); 685 my $name = NEW_ANS_NAME(inc_ans_rule_count());
638 NAMED_ANS_BOX($name ,$row,$col); 686 NAMED_ANS_BOX($name ,$row,$col);
639} 687}
640 688
641#this is legacy code; use ans_checkbox instead 689#this is legacy code; use ans_checkbox instead
642sub checkbox { 690sub checkbox {
648sub NAMED_POP_UP_LIST { 696sub NAMED_POP_UP_LIST {
649 my $name = shift; 697 my $name = shift;
650 my @list = @_; 698 my @list = @_;
651 $name = RECORD_ANS_NAME($name); # record answer name 699 $name = RECORD_ANS_NAME($name); # record answer name
652 my $answer_value = ''; 700 my $answer_value = '';
653 $answer_value = ${$main::inputs_ref}{$name} if defined(${$main::inputs_ref}{$name}); 701 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
654 my $out = ""; 702 my $out = "";
655 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or 703 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or
656 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img') { 704 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img') {
657 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!; 705 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!;
658 my $i; 706 my $i;
675 723
676} 724}
677 725
678sub pop_up_list { 726sub pop_up_list {
679 my @list = @_; 727 my @list = @_;
680 my $name = NEW_ANS_NAME(++$main::ans_rule_count); # get new answer name 728 my $name = NEW_ANS_NAME(inc_ans_rule_count()); # get new answer name
681 NAMED_POP_UP_LIST($name, @list); 729 NAMED_POP_UP_LIST($name, @list);
682} 730}
683 731
684 732
685 733
686=head5 answer_matrix 734=head5 answer_matrix
687 735
688 Usage \[ \{ answer_matrix(rows,columns,width_of_ans_rule, @options) \} \] 736 Usage \[ \{ answer_matrix(rows,columns,width_of_ans_rule, @options) \} \]
689 737
690 Creates an array of answer blanks and passes it to display_matrix which returns 738 Creates an array of answer blanks and passes it to display_matrix which returns
691 text which represents the matrix in TeX format used in math display mode. Answers 739 text which represents the matrix in TeX format used in math display mode. Answers
692 are then passed back to whatever answer evaluators you write at the end of the problem. 740 are then passed back to whatever answer evaluators you write at the end of the problem.
693 (note, if you have an m x n matrix, you will need mn answer evaluators, and they will be 741 (note, if you have an m x n matrix, you will need mn answer evaluators, and they will be
694 returned to the evaluaters starting in the top left hand corner and proceed to the left 742 returned to the evaluaters starting in the top left hand corner and proceed to the left
695 and then at the end moving down one row, just as you would read them.) 743 and then at the end moving down one row, just as you would read them.)
696 744
697 The options are passed on to display_matrix. 745 The options are passed on to display_matrix.
698 746
699 747
700=cut 748=cut
701 749
707 my @options = @_; 755 my @options = @_;
708 my @array=(); 756 my @array=();
709 for( my $i = 0; $i < $m; $i+=1) 757 for( my $i = 0; $i < $m; $i+=1)
710 { 758 {
711 my @row_array = (); 759 my @row_array = ();
712 760
713 for( my $i = 0; $i < $n; $i+=1) 761 for( my $i = 0; $i < $n; $i+=1)
714 { 762 {
715 push @row_array, ans_rule($width); 763 push @row_array, ans_rule($width);
716 } 764 }
717 my $r_row_array = \@row_array; 765 my $r_row_array = \@row_array;
718 push @array, $r_row_array; 766 push @array, $r_row_array;
719 } 767 }
768 # display_matrix hasn't been loaded into the cache safe compartment
769 # so we need to refer to the subroutine in this way to make
770 # sure that main is defined correctly.
771 my $ra_local_display_matrix=PG_restricted_eval(q!\&main::display_matrix!);
720 display_matrix( \@array, @options ); 772 &$ra_local_display_matrix( \@array, @options );
721 773
722} 774}
723 775
724sub NAMED_ANS_ARRAY_EXTENSION{ 776sub NAMED_ANS_ARRAY_EXTENSION{
725 777
726 my $name = shift; 778 my $name = shift;
727 my $col = shift; 779 my $col = shift;
728 $col = 20 unless $col; 780 $col = 20 unless $col;
729 my $answer_value = ''; 781 my $answer_value = '';
730 782
731 $answer_value = ${$main::inputs_ref}{$name} if defined(${$main::inputs_ref}{$name}); 783 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
732 if ($answer_value =~ /\0/ ) { 784 if ($answer_value =~ /\0/ ) {
733 my @answers = split("\0", $answer_value); 785 my @answers = split("\0", $answer_value);
734 $answer_value = shift(@answers); 786 $answer_value = shift(@answers);
735 $answer_value= '' unless defined($answer_value); 787 $answer_value= '' unless defined($answer_value);
736 } elsif (ref($answer_value) eq 'ARRAY') { 788 } elsif (ref($answer_value) eq 'ARRAY') {
737 my @answers = @{ $answer_value}; 789 my @answers = @{ $answer_value};
738 $answer_value = shift(@answers); 790 $answer_value = shift(@answers);
739 $answer_value= '' unless defined($answer_value); 791 $answer_value= '' unless defined($answer_value);
740 } 792 }
741 793
742 $answer_value =~ tr/$@`//d; ## make sure student answers can not be interpolated by e.g. EV3 794 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
743 MODES( 795 MODES(
744 TeX => "\\mbox{\\parbox[t]{10pt}{\\hrulefill}}\\hrulefill\\quad ", 796 TeX => "\\mbox{\\parbox[t]{10pt}{\\hrulefill}}\\hrulefill\\quad ",
745 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!, 797 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!,
746 HTML => "<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"$answer_value\">\n" 798 HTML => "<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"$answer_value\">\n"
747 ); 799 );
750sub ans_array{ 802sub ans_array{
751 my $m = shift; 803 my $m = shift;
752 my $n = shift; 804 my $n = shift;
753 my $col = shift; 805 my $col = shift;
754 $col = 20 unless $col; 806 $col = 20 unless $col;
755 my $num = ++$main::ans_rule_count ; 807 my $num = inc_ans_rule_count() ;
756 my $name = NEW_ANS_ARRAY_NAME($num,0,0); 808 my $name = NEW_ANS_ARRAY_NAME($num,0,0);
757 my @options = @_; 809 my @options = @_;
758 my @array=(); 810 my @array=();
759 my $string; 811 my $string;
760 my $answer_value = ""; 812 my $answer_value = "";
761 813
762 $array[0][0] = NAMED_ANS_RULE($name,$col); 814 $array[0][0] = NAMED_ANS_RULE($name,$col);
763 815
764 for( my $i = 1; $i < $n; $i+=1) 816 for( my $i = 1; $i < $n; $i+=1)
765 { 817 {
766 $name = NEW_ANS_ARRAY_NAME_EXTENSION($num,0,$i); 818 $name = NEW_ANS_ARRAY_NAME_EXTENSION($num,0,$i);
767 $array[0][$i] = NAMED_ANS_ARRAY_EXTENSION($name,$col); 819 $array[0][$i] = NAMED_ANS_ARRAY_EXTENSION($name,$col);
768 820
769 } 821 }
770 822
771 for( my $j = 1; $j < $m; $j+=1 ){ 823 for( my $j = 1; $j < $m; $j+=1 ){
772 824
773 for( my $i = 0; $i < $n; $i+=1) 825 for( my $i = 0; $i < $n; $i+=1)
774 { 826 {
775 $name = NEW_ANS_ARRAY_NAME_EXTENSION($num,$j,$i); 827 $name = NEW_ANS_ARRAY_NAME_EXTENSION($num,$j,$i);
776 $array[$j][$i] = NAMED_ANS_ARRAY_EXTENSION($name,$col); 828 $array[$j][$i] = NAMED_ANS_ARRAY_EXTENSION($name,$col);
777 829
778 }
779
780 } 830 }
831
832 }
833 my $ra_local_display_matrix=PG_restricted_eval(q!\&main::display_matrix!);
781 display_matrix( \@array, @options ); 834 &$ra_local_display_matrix( \@array, @options );
782 835
783} 836}
784 837
785sub ans_array_extension{ 838sub ans_array_extension{
786 my $m = shift; 839 my $m = shift;
787 my $n = shift; 840 my $n = shift;
788 my $col = shift; 841 my $col = shift;
789 $col = 20 unless $col; 842 $col = 20 unless $col;
790 my $num = $main::ans_rule_count; 843 my $num = PG_restricted_eval(q!$main::ans_rule_count!);
791 my @options = @_; 844 my @options = @_;
792 my $name; 845 my $name;
793 my @array=(); 846 my @array=();
794 my $string; 847 my $string;
795 my $answer_value = ""; 848 my $answer_value = "";
796 849
797 for( my $j = 0; $j < $m; $j+=1 ){ 850 for( my $j = 0; $j < $m; $j+=1 ){
798 851
799 for( my $i = 0; $i < $n; $i+=1) 852 for( my $i = 0; $i < $n; $i+=1)
800 { 853 {
801 $name = NEW_ANS_ARRAY_NAME_EXTENSION($num,$j,$i); 854 $name = NEW_ANS_ARRAY_NAME_EXTENSION($num,$j,$i);
802 $array[$j][$i] = NAMED_ANS_ARRAY_EXTENSION($name,$col); 855 $array[$j][$i] = NAMED_ANS_ARRAY_EXTENSION($name,$col);
803 856
804 }
805
806 } 857 }
858
859 }
860 my $ra_local_display_matrix=PG_restricted_eval(q!\&main::display_matrix!);
807 display_matrix( \@array, @options ); 861 &$ra_local_display_matrix( \@array, @options );
808 862
809} 863}
810 864
811 865
812# end answer blank macros 866# end answer blank macros
813 867
821 875
822Solution prints its concatenated input when the check box named 'ShowSol' is set and 876Solution prints its concatenated input when the check box named 'ShowSol' is set and
823the time is after the answer date. The check box 'ShowSol' is visible only after the 877the time is after the answer date. The check box 'ShowSol' is visible only after the
824answer date or when the problem is viewed by a professor. 878answer date or when the problem is viewed by a professor.
825 879
826$envir{'displaySolutionsQ'} is set to 1 when a solution is to be displayed. 880$main::envir{'displaySolutionsQ'} is set to 1 when a solution is to be displayed.
827 881
828Hints are shown only after the number of attempts is greater than $:showHint 882Hints are shown only after the number of attempts is greater than $:showHint
829($main::showHint defaults to 1) and the check box named 'ShowHint' is set. The check box 883($main::showHint defaults to 1) and the check box named 'ShowHint' is set. The check box
830'ShowHint' is visible only after the number of attempts is greater than $main::showHint. 884'ShowHint' is visible only after the number of attempts is greater than $main::showHint.
831 885
832$envir{'displayHintsQ'} is set to 1 when a hint is to be displayed. 886$main::envir{'displayHintsQ'} is set to 1 when a hint is to be displayed.
833 887
834 888
835=cut 889=cut
836 890
837 891
844 898
845 899
846sub solution { 900sub solution {
847 my @in = @_; 901 my @in = @_;
848 my $out = ''; 902 my $out = '';
849 $main::solutionExists =1; 903 PG_restricted_eval(q!$main::solutionExists =1!);
850 if ($envir{'displaySolutionsQ'}) {$out = join(' ',@in);} 904 if (PG_restricted_eval(q!$main::envir{'displaySolutionsQ'}!)) {$out = join(' ',@in);}
851 $out; 905 $out;
852} 906}
853 907
854 908
855sub SOLUTION { 909sub SOLUTION {
860 914
861sub hint { 915sub hint {
862 my @in = @_; 916 my @in = @_;
863 my $out = ''; 917 my $out = '';
864 918
865 $main::hintExists =1; 919 PG_restricted_eval(q!$main::hintExists =1;
866 $main::numOfAttempts = 0 unless defined($main::numOfAttempts); 920 $main::numOfAttempts = 0 unless defined($main::numOfAttempts);
921 !);
867 922
868 if ($main::displayMode eq 'TeX') { 923 if ($displayMode eq 'TeX') {
869 $out = ''; # do nothing since hints are not available for download 924 $out = ''; # do nothing since hints are not available for download
870 } elsif (($envir{'displayHintsQ'}) and ($main::numOfAttempts >= $main::showHint)) 925 } elsif (($envir->{'displayHintsQ'}) and
926 PG_restricted_eval(q!($main::numOfAttempts >= $main::showHint)!))
871 927
872 ## the second test above prevents a hint being shown if a doctored form is submitted 928 ## the second test above prevents a hint being shown if a doctored form is submitted
873 929
874 {$out = join(' ',@in);} # show hint 930 {$out = join(' ',@in);} # show hint
875 931
876 $out ; 932 $out ;
877} 933}
878 934
879 935
880sub HINT { 936sub HINT {
881 TEXT("$main::BR" . hint(@_) . "$main::BR") if hint(@_); 937 TEXT("$BR" . hint(@_) . "$BR") if hint(@_);
882} 938}
883 939
884 940
885 941
886# End hints and solutions macros 942# End hints and solutions macros
902 958
903 959
904SRAND(time) will create a different problem everytime it is called. This makes it difficult 960SRAND(time) will create a different problem everytime it is called. This makes it difficult
905to check the answers :-). 961to check the answers :-).
906 962
907SRAND($envir{'inputs_ref'}->{'key'} ) will create a different problem for each login session. 963SRAND($envir->{'inputs_ref'}->{'key'} ) will create a different problem for each login session.
908This is probably what is desired. 964This is probably what is desired.
909 965
910=cut 966=cut
911 967
912 968
913sub random { 969sub random {
914 my ($begin, $end, $incr) = @_; 970 my ($begin, $end, $incr) = @_;
915 $main::PG_random_generator->random($begin,$end,$incr); 971 $PG_random_generator->random($begin,$end,$incr);
916} 972}
917 973
918 974
919sub non_zero_random { ##gives a non-zero random number 975sub non_zero_random { ##gives a non-zero random number
920 my (@arguments)=@_; 976 my (@arguments)=@_;
931 return $li[random(1,scalar(@li))-1]; 987 return $li[random(1,scalar(@li))-1];
932} 988}
933 989
934sub SRAND { # resets the main random generator -- use cautiously 990sub SRAND { # resets the main random generator -- use cautiously
935 my $seed = shift; 991 my $seed = shift;
936 $main::PG_random_generator -> srand($seed); 992 $PG_random_generator -> srand($seed);
937} 993}
938 994
939# display macros 995# display macros
940 996
941=head2 Display Macros 997=head2 Display Macros
1074} 1130}
1075 1131
1076############################################################### 1132###############################################################
1077# Some constants which are different in tex and in HTML 1133# Some constants which are different in tex and in HTML
1078# The order of arguments is TeX, Latex2HTML, HTML 1134# The order of arguments is TeX, Latex2HTML, HTML
1135# Adopted Davide Cervone's improvements to PAR, LTS, GTS, LTE, GTE, LBRACE, RBRACE, LB, RB. 7-14-03 AKP
1079sub PAR { MODES( TeX => '\\par ',Latex2HTML => '\\par ',HTML => '<P>' ); }; 1136sub PAR { MODES( TeX => '\\par ', Latex2HTML => '\\begin{rawhtml}<P>\\end{rawhtml}', HTML => '<P>'); };
1080sub BR { MODES( TeX => '\\par\\noindent ',Latex2HTML => '\\par\\noindent ',HTML => '<BR>'); }; 1137sub BR { MODES( TeX => '\\par\\noindent ', Latex2HTML => '\\begin{rawhtml}<BR>\\end{rawhtml}', HTML => '<BR>'); };
1138# Alternate definition of BR which is slightly more flexible and gives more white space in printed output
1139# which looks better but kills more trees.
1140#sub BR { MODES( TeX => '\\\\', Latex2HTML => '\\begin{rawhtml}<BR>\\end{rawhtml}', HTML => '<BR>'); };
1081sub LQ { MODES( TeX => "``", Latex2HTML => '"', HTML => '&quot;' ); }; 1141sub LQ { MODES( TeX => "``", Latex2HTML => '"', HTML => '&quot;' ); };
1082sub RQ { MODES( TeX => "''", Latex2HTML => '"', HTML => '&quot;' ); }; 1142sub RQ { MODES( TeX => "''", Latex2HTML => '"', HTML => '&quot;' ); };
1083sub BM { MODES(TeX => '\\(', Latex2HTML => '\\(', HTML => ''); }; # begin math mode 1143sub BM { MODES(TeX => '\\(', Latex2HTML => '\\(', HTML => ''); }; # begin math mode
1084sub EM { MODES(TeX => '\\)', Latex2HTML => '\\)', HTML => ''); }; # end math mode 1144sub EM { MODES(TeX => '\\)', Latex2HTML => '\\)', HTML => ''); }; # end math mode
1085sub BDM { MODES(TeX => '\\[', Latex2HTML => '\\[', HTML => '<P ALIGN=CENTER>'); }; #begin displayMath mode 1145sub BDM { MODES(TeX => '\\[', Latex2HTML => '\\[', HTML => '<P ALIGN=CENTER>'); }; #begin displayMath mode
1086sub EDM { MODES(TeX => '\\]', Latex2HTML => '\\]', HTML => '</P>'); }; #end displayMath mode 1146sub EDM { MODES(TeX => '\\]', Latex2HTML => '\\]', HTML => '</P>'); }; #end displayMath mode
1087sub LTS { MODES(TeX => ' < ', Latex2HTML => ' \\lt ', HTML => '&lt;'); }; 1147sub LTS { MODES(TeX => '<', Latex2HTML => '\\lt ', HTML => '&lt;', HTML_tth => '<' ); };
1088sub GTS {MODES(TeX => ' > ', Latex2HTML => ' \\gt ', HTML => '&gt;'); }; 1148sub GTS { MODES(TeX => '>', Latex2HTML => '\\gt ', HTML => '&gt;', HTML_tth => '>' ); };
1089sub LTE { MODES(TeX => ' \\le ', Latex2HTML => ' \\le ', HTML => '&lt;=' ); }; 1149sub LTE { MODES(TeX => '\\le ', Latex2HTML => '\\le ', HTML => '<U>&lt;</U>', HTML_tth => '\\le ' ); };
1090sub GTE { MODES(TeX => ' \\ge ', Latex2HTML => ' \\ge ', HTML => '&gt;'); }; 1150sub GTE { MODES(TeX => '\\ge ', Latex2HTML => '\\ge ', HTML => '<U>&gt;</U>', HTML_tth => '\\ge ' ); };
1091sub BEGIN_ONE_COLUMN { MODES(TeX => " \\end{multicols}\n", Latex2HTML => " ", HTML => " "); }; 1151sub BEGIN_ONE_COLUMN { MODES(TeX => " \\end{multicols}\n", Latex2HTML => " ", HTML => " "); };
1092sub END_ONE_COLUMN { MODES(TeX => 1152sub END_ONE_COLUMN { MODES(TeX =>
1093 " \\begin{multicols}{2}\n\\columnwidth=\\linewidth\n", 1153 " \\begin{multicols}{2}\n\\columnwidth=\\linewidth\n",
1094 Latex2HTML => ' ', HTML => ' '); 1154 Latex2HTML => ' ', HTML => ' ');
1095 1155
1106sub BITALIC { MODES(TeX => '{\\it ', Latex2HTML => '{\\it ', HTML => '<I>'); }; 1166sub BITALIC { MODES(TeX => '{\\it ', Latex2HTML => '{\\it ', HTML => '<I>'); };
1107sub EITALIC { MODES(TeX => '} ', Latex2HTML => '} ', HTML => '</I>'); }; 1167sub EITALIC { MODES(TeX => '} ', Latex2HTML => '} ', HTML => '</I>'); };
1108sub BCENTER { MODES(TeX => '\\begin{center} ', Latex2HTML => ' \\begin{rawhtml} <div align="center"> \\end{rawhtml} ', HTML => '<div align="center">'); }; 1168sub BCENTER { MODES(TeX => '\\begin{center} ', Latex2HTML => ' \\begin{rawhtml} <div align="center"> \\end{rawhtml} ', HTML => '<div align="center">'); };
1109sub ECENTER { MODES(TeX => '\\end{center} ', Latex2HTML => ' \\begin{rawhtml} </div> \\end{rawhtml} ', HTML => '</div>'); }; 1169sub ECENTER { MODES(TeX => '\\end{center} ', Latex2HTML => ' \\begin{rawhtml} </div> \\end{rawhtml} ', HTML => '</div>'); };
1110sub HR { MODES(TeX => '\\par\\hrulefill\\par ', Latex2HTML => '\\begin{rawhtml} <HR> \\end{rawhtml}', HTML => '<HR>'); }; 1170sub HR { MODES(TeX => '\\par\\hrulefill\\par ', Latex2HTML => '\\begin{rawhtml} <HR> \\end{rawhtml}', HTML => '<HR>'); };
1111sub LBRACE { MODES( TeX => '\{', Latex2HTML => '\\lbrace', HTML => '\{' , HTML_tth=> '\\lbrace' ); }; 1171sub LBRACE { MODES( TeX => '\{', Latex2HTML => '\\lbrace', HTML => '{' , HTML_tth=> '\\lbrace' ); };
1112sub RBRACE { MODES( TeX => '\}', Latex2HTML => '\\rbrace', HTML => '\}' , HTML_tth=> '\\rbrace',); }; 1172sub RBRACE { MODES( TeX => '\}', Latex2HTML => '\\rbrace', HTML => '}' , HTML_tth=> '\\rbrace',); };
1113sub LB { MODES( TeX => '\{', Latex2HTML => '\\lbrace', HTML => '\{' , HTML_tth=> '\\lbrace' ); }; 1173sub LB { MODES( TeX => '\{', Latex2HTML => '\\lbrace', HTML => '{' , HTML_tth=> '\\lbrace' ); };
1114sub RB { MODES( TeX => '\}', Latex2HTML => '\\rbrace', HTML => '\}' , HTML_tth=> '\\rbrace',); }; 1174sub RB { MODES( TeX => '\}', Latex2HTML => '\\rbrace', HTML => '}' , HTML_tth=> '\\rbrace',); };
1115sub DOLLAR { MODES( TeX => '\\$', Latex2HTML => '\\$', HTML => '$' ); }; 1175sub DOLLAR { MODES( TeX => '\\$', Latex2HTML => '\\$', HTML => '$' ); };
1116sub PERCENT { MODES( TeX => '\\%', Latex2HTML => '\\%', HTML => '%' ); }; 1176sub PERCENT { MODES( TeX => '\\%', Latex2HTML => '\\%', HTML => '%' ); };
1117sub CARET { MODES( TeX => '\\verb+^+', Latex2HTML => '\\verb+^+', HTML => '^' ); }; 1177sub CARET { MODES( TeX => '\\verb+^+', Latex2HTML => '\\verb+^+', HTML => '^' ); };
1118sub PI {4*atan2(1,1);}; 1178sub PI {4*atan2(1,1);};
1119sub E {exp(1);}; 1179sub E {exp(1);};
1248 my $start_delim = shift; 1308 my $start_delim = shift;
1249 my $end_delim = shift; 1309 my $end_delim = shift;
1250 my $actionRef = shift; 1310 my $actionRef = shift;
1251 my ($eval_out,$PG_eval_errors,$PG_full_error_report)=(); 1311 my ($eval_out,$PG_eval_errors,$PG_full_error_report)=();
1252 my $out = ""; 1312 my $out = "";
1313 #
1314 # DPVC -- 2001/12/07
1315 # original "while ($string)" fails to process the string "0" correctly
1316 #
1253 while ($string) { 1317 while ($string ne "") {
1318 #
1319 # end DPVC
1320 #
1254 if ($string =~ /\Q$start_delim\E/s) { 1321 if ($string =~ /\Q$start_delim\E/s) {
1255 #print "$start_delim $end_delim evaluating_substring=$string<BR>"; 1322 #print "$start_delim $end_delim evaluating_substring=$string<BR>";
1256 $string =~ s/^(.*?)\Q$start_delim\E//s; # get string up to next \{ ---treats string as a single line, ignoring returns 1323 $string =~ s/^(.*?)\Q$start_delim\E//s; # get string up to next \{ ---treats string as a single line, ignoring returns
1257 $out .= $1; 1324 $out .= $1;
1258 #print "$start_delim $end_delim substring_out=$out<BR>"; 1325 #print "$start_delim $end_delim substring_out=$out<BR>";
1260 #print "$start_delim $end_delim evaluate_string=$1<BR>"; 1327 #print "$start_delim $end_delim evaluate_string=$1<BR>";
1261 ($eval_out,$PG_eval_errors,$PG_full_error_report) = &$actionRef($1); 1328 ($eval_out,$PG_eval_errors,$PG_full_error_report) = &$actionRef($1);
1262 $eval_out = "$start_delim $eval_out $end_delim" if $PG_full_error_report; 1329 $eval_out = "$start_delim $eval_out $end_delim" if $PG_full_error_report;
1263 $out = $out . $eval_out; 1330 $out = $out . $eval_out;
1264 #print "$start_delim $end_delim new substring_out=$out<BR><p><BR>"; 1331 #print "$start_delim $end_delim new substring_out=$out<BR><p><BR>";
1265 $out .="$main::PAR ERROR $0 in ev_substring, PGbasicmacros.pl:$main::PAR <PRE> $@ </PRE>$main::PAR" if $@; 1332 $out .="$PAR ERROR $0 in ev_substring, PGbasicmacros.pl:$PAR <PRE> $@ </PRE>$PAR" if $@;
1266 } 1333 }
1267 else { 1334 else {
1268 $out .= $string; # flush the last part of the string 1335 $out .= $string; # flush the last part of the string
1269 last; 1336 last;
1270 } 1337 }
1282 my $in = shift; 1349 my $in = shift;
1283 my ($out,$PG_eval_errors,$PG_full_error_report) = PG_restricted_eval("$in;"); 1350 my ($out,$PG_eval_errors,$PG_full_error_report) = PG_restricted_eval("$in;");
1284 # the addition of the ; seems to provide better error reporting 1351 # the addition of the ; seems to provide better error reporting
1285 if ($PG_eval_errors) { 1352 if ($PG_eval_errors) {
1286 my @errorLines = split("\n",$PG_eval_errors); 1353 my @errorLines = split("\n",$PG_eval_errors);
1287 #$out = "<PRE>$main::PAR % ERROR in $0:old_safe_ev, PGbasicmacros.pl: $main::PAR % There is an error occuring inside evaluation brackets \\{ ...code... \\} $main::BR % somewhere in an EV2 or EV3 or BEGIN_TEXT block. $main::BR % Code evaluated:$main::BR $in $main::BR % $main::BR % $errorLines[0]\n % $errorLines[1]$main::BR % $main::BR % $main::BR </PRE> "; 1354 #$out = "<PRE>$PAR % ERROR in $0:old_safe_ev, PGbasicmacros.pl: $PAR % There is an error occuring inside evaluation brackets \\{ ...code... \\} $BR % somewhere in an EV2 or EV3 or BEGIN_TEXT block. $BR % Code evaluated:$BR $in $BR % $BR % $errorLines[0]\n % $errorLines[1]$BR % $BR % $BR </PRE> ";
1288 warn " ERROR in old_safe_ev, PGbasicmacros.pl: <PRE> 1355 warn " ERROR in old_safe_ev, PGbasicmacros.pl: <PRE>
1289 ## There is an error occuring inside evaluation brackets \\{ ...code... \\} 1356 ## There is an error occuring inside evaluation brackets \\{ ...code... \\}
1290 ## somewhere in an EV2 or EV3 or BEGIN_TEXT block. 1357 ## somewhere in an EV2 or EV3 or BEGIN_TEXT block.
1291 ## Code evaluated: 1358 ## Code evaluated:
1292 ## $in 1359 ## $in
1293 ##" .join("\n ", @errorLines). " 1360 ##" .join("\n ", @errorLines). "
1294 ##</PRE>$main::BR 1361 ##</PRE>$BR
1295 "; 1362 ";
1296 $out ="$main::PAR $main::BBOLD $in $main::EBOLD $main::PAR"; 1363 $out ="$PAR $BBOLD $in $EBOLD $PAR";
1297 1364
1298 1365
1299 } 1366 }
1300 1367
1301 ($out,$PG_eval_errors,$PG_full_error_report); 1368 ($out,$PG_eval_errors,$PG_full_error_report);
1319#sub math_ev3 { 1386#sub math_ev3 {
1320# my $in = shift; #print "in=$in<BR>"; 1387# my $in = shift; #print "in=$in<BR>";
1321# my ($out,$PG_eval_errors,$PG_full_error_report); 1388# my ($out,$PG_eval_errors,$PG_full_error_report);
1322# $in = FEQ($in); 1389# $in = FEQ($in);
1323# $in =~ s/%/\\%/g; # % causes trouble in TeX and HTML_tth it usually (always?) indicates an error, not comment 1390# $in =~ s/%/\\%/g; # % causes trouble in TeX and HTML_tth it usually (always?) indicates an error, not comment
1324# return("$main::BM $in $main::EM") unless ($displayMode eq 'HTML_tth'); 1391# return("$BM $in $EM") unless ($displayMode eq 'HTML_tth');
1325# $in = "\\(" . $in . "\\)"; 1392# $in = "\\(" . $in . "\\)";
1326# $out = tth($in); 1393# $out = tth($in);
1327# ($out,$PG_eval_errors,$PG_full_error_report); 1394# ($out,$PG_eval_errors,$PG_full_error_report);
1328# 1395#
1329#} 1396#}
1353 my $in = shift; 1420 my $in = shift;
1354 my $mode = shift || "inline"; 1421 my $mode = shift || "inline";
1355 1422
1356 $in = FEQ($in); # Format EQuations 1423 $in = FEQ($in); # Format EQuations
1357 $in =~ s/%/\\%/g; # avoid % becoming TeX comments 1424 $in =~ s/%/\\%/g; # avoid % becoming TeX comments
1358 1425
1426 ## remove leading and trailing spaces so that HTML mode will
1427 ## not include unwanted spaces as per Davide Cervone.
1428 $in =~ s/^\s+//;
1429 $in =~ s/\s+$//;
1430
1359 # some modes want the delimiters, some don't 1431 # some modes want the delimiters, some don't
1360 my $in_delim = $mode eq "inline" 1432 my $in_delim = $mode eq "inline"
1361 ? "\\($in\\)" 1433 ? "\\($in\\)"
1362 : "\\[$in\\]"; 1434 : "\\[$in\\]";
1363 1435
1364 my $out; 1436 my $out;
1365 if($displayMode eq "HTML_tth") { 1437 if($displayMode eq "HTML_tth") {
1366 $out = tth($in_delim); 1438 $out = tth($in_delim);
1439 ## remove leading and trailing spaces as per Davide Cervone.
1440 $in =~ s/^\s+//;
1441 $in =~ s/\s+$//;
1367 } elsif ($displayMode eq "HTML_dpng") { 1442 } elsif ($displayMode eq "HTML_dpng") {
1443 # for jj's version of ImageGenerator
1368 #$out = $envir{'imagegen'}->add($in_delim); 1444 $out = $envir->{'imagegen'}->add($in_delim);
1445 # for my version of ImageGenerator
1369 $out = $envir{'imagegen'}->add($in, $mode); 1446 #$out = $envir->{'imagegen'}->add($in, $mode);
1370 } elsif ($displayMode eq "HTML_img") { 1447 } elsif ($displayMode eq "HTML_img") {
1371 $out = math2img($in, $mode); 1448 $out = math2img($in, $mode);
1372 } else { 1449 } else {
1373 $out = "\\($in\\)" if $mode eq "inline"; 1450 $out = "\\($in\\)" if $mode eq "inline";
1374 $out = "\\[$in\\]" if $mode eq "display"; 1451 $out = "\\[$in\\]" if $mode eq "display";
1382 $string = ev_substring($string,"\\{","\\}",\&old_safe_ev); 1459 $string = ev_substring($string,"\\{","\\}",\&old_safe_ev);
1383 $string = ev_substring($string,"\\<","\\>",\&old_safe_ev); 1460 $string = ev_substring($string,"\\<","\\>",\&old_safe_ev);
1384 $string = ev_substring($string,"\\(","\\)",\&math_ev3); 1461 $string = ev_substring($string,"\\(","\\)",\&math_ev3);
1385 $string = ev_substring($string,"\\[","\\]",\&display_math_ev3); 1462 $string = ev_substring($string,"\\[","\\]",\&display_math_ev3);
1386 # macros for displaying math 1463 # macros for displaying math
1387 $string =~ s/\\\(/$main::BM/g; 1464 $string =~ s/\\\(/$BM/g;
1388 $string =~ s/\\\)/$main::EM/g; 1465 $string =~ s/\\\)/$EM/g;
1389 $string =~ s/\\\[/$main::BDM/g; 1466 $string =~ s/\\\[/$BDM/g;
1390 $string =~ s/\\\]/$main::EDM/g; 1467 $string =~ s/\\\]/$EDM/g;
1391 $string; 1468 $string;
1392} 1469}
1393 1470
1394sub EV3{ 1471sub EV3{
1395 my $string = join(" ",@_); 1472 my $string = join(" ",@_);
1398 # interpolate variables 1475 # interpolate variables
1399 my ($evaluated_string,$PG_eval_errors,$PG_full_errors) = PG_restricted_eval("<<END_OF_EVALUATION_STRING\n$string\nEND_OF_EVALUATION_STRING\n"); 1476 my ($evaluated_string,$PG_eval_errors,$PG_full_errors) = PG_restricted_eval("<<END_OF_EVALUATION_STRING\n$string\nEND_OF_EVALUATION_STRING\n");
1400 if ($PG_eval_errors) { 1477 if ($PG_eval_errors) {
1401 my @errorLines = split("\n",$PG_eval_errors); 1478 my @errorLines = split("\n",$PG_eval_errors);
1402 $string =~ s/</&lt;/g; $string =~ s/>/&gt;/g; 1479 $string =~ s/</&lt;/g; $string =~ s/>/&gt;/g;
1403 $evaluated_string = "<PRE>$main::PAR % ERROR in $0:EV3, PGbasicmacros.pl: $main::PAR % There is an error occuring in the following code:$main::BR $string $main::BR % $main::BR % $errorLines[0]\n % $errorLines[1]$main::BR % $main::BR % $main::BR </PRE> "; 1480 $evaluated_string = "<PRE>$PAR % ERROR in $0:EV3, PGbasicmacros.pl: $PAR % There is an error occuring in the following code:$BR $string $BR % $BR % $errorLines[0]\n % $errorLines[1]$BR % $BR % $BR </PRE> ";
1404 $@=""; 1481 $@="";
1405 } 1482 }
1406 $string = $evaluated_string; 1483 $string = $evaluated_string;
1407 $string = ev_substring($string,"\\(","\\)",\&math_ev3); 1484 $string = ev_substring($string,"\\(","\\)",\&math_ev3);
1408 $string = ev_substring($string,"\\[","\\]",\&display_math_ev3); 1485 $string = ev_substring($string,"\\[","\\]",\&display_math_ev3);
1437 1514
1438=cut 1515=cut
1439 1516
1440sub beginproblem { 1517sub beginproblem {
1441 my $out = ""; 1518 my $out = "";
1519 my $problemValue = $envir->{problemValue};
1520 my $fileName = $envir->{fileName};
1521 my $probNum = $envir->{probNum};
1442 my $TeXFileName = protect_underbar($main::fileName); 1522 my $TeXFileName = protect_underbar($envir->{fileName});
1443 my $l2hFileName = protect_underbar($main::fileName); 1523 my $l2hFileName = protect_underbar($envir->{fileName});
1444 my %inlist; 1524 my %inlist;
1445 my $points ='pts'; 1525 my $points ='pts';
1526
1446 $points = 'pt' if $main::problemValue == 1; 1527 $points = 'pt' if $problemValue == 1;
1447 ## Prepare header for the problem 1528 ## Prepare header for the problem
1448 grep($inlist{$_}++,@{ $envir{'PRINT_FILE_NAMES_FOR'} }); 1529 grep($inlist{$_}++,@{ $envir->{'PRINT_FILE_NAMES_FOR'} });
1449 if ( defined($inlist{$main::studentLogin}) and ($inlist{$main::studentLogin} > 0) ) { 1530 if ( defined($inlist{$envir->{studentLogin}}) and ($inlist{$envir->{studentLogin}} > 0) ) {
1450 $out = &M3("\n\n\\medskip\\hrule\\smallskip\\par{\\bf ${main::probNum}.{\\footnotesize ($main::problemValue $points) $TeXFileName}}\\newline ", 1531 $out = &M3("\n\n\\medskip\\hrule\\smallskip\\par{\\bf ${probNum}.{\\footnotesize ($problemValue $points) $TeXFileName}}\\newline ",
1451 " \\begin{rawhtml} ($main::problemValue $points) <B>$l2hFileName</B><BR>\\end{rawhtml}", 1532 " \\begin{rawhtml} ($problemValue $points) <B>$l2hFileName</B><BR>\\end{rawhtml}",
1452 "($main::problemValue $points) <B>$main::fileName</B><BR>" 1533 "($problemValue $points) <B>$fileName</B><BR>"
1453 ); 1534 );
1454 } else { 1535 } else {
1455 $out = &M3("\n\n\\smallskip\\hrule\\smallskip\\par{\\bf ${main::probNum}.}($main::problemValue $points) ", 1536 $out = &M3("\n\n\\smallskip\\hrule\\smallskip\\par{\\bf ${probNum}.}($problemValue $points) ",
1456 "($main::problemValue $points) ", 1537 "($problemValue $points) ",
1457 "($main::problemValue $points) " 1538 "($problemValue $points) "
1458 ); 1539 );
1459 } 1540 }
1460 $out; 1541 $out;
1461 1542
1462} 1543}
1484 "<OL TYPE=\"A\" VALUE=\"1\">\n" 1565 "<OL TYPE=\"A\" VALUE=\"1\">\n"
1485 ) ; 1566 ) ;
1486 my $elem; 1567 my $elem;
1487 foreach $elem (@array) { 1568 foreach $elem (@array) {
1488 $out .= MODES( 1569 $out .= MODES(
1489 TeX=> "\\item[$main::ALPHABET[$i].] $elem\n", 1570 TeX=> "\\item[$ALPHABET[$i].] $elem\n",
1490 Latex2HTML=> " \\begin{rawhtml} <LI> \\end{rawhtml} $elem ", 1571 Latex2HTML=> " \\begin{rawhtml} <LI> \\end{rawhtml} $elem ",
1491 HTML=> "<LI> $elem\n", 1572 HTML=> "<LI> $elem\n",
1492 HTML_dpng=> "<LI> $elem <br /> <br /> \n" 1573 HTML_dpng=> "<LI> $elem <br /> <br /> \n"
1493 ); 1574 );
1494 $i++; 1575 $i++;
1503sub htmlLink { 1584sub htmlLink {
1504 my $url = shift; 1585 my $url = shift;
1505 my $text = shift; 1586 my $text = shift;
1506 my $options = shift; 1587 my $options = shift;
1507 $options = "" unless defined($options); 1588 $options = "" unless defined($options);
1508 return "${main::BBOLD}[ broken link: $text ] ${main::EBOLD}" unless defined($url); 1589 return "$BBOLD\[ broken link: $text \] $EBOLD" unless defined($url);
1509 M3( "{\\bf \\underline{$text} }", 1590 M3( "{\\bf \\underline{$text} }",
1510 "\\begin{rawhtml} <A HREF=\"$url\" $options> $text </A>\\end{rawhtml}", 1591 "\\begin{rawhtml} <A HREF=\"$url\" $options> $text </A>\\end{rawhtml}",
1511 "<A HREF=\"$url\" $options> $text </A>" 1592 "<A HREF=\"$url\" $options> $text </A>"
1512 ); 1593 );
1513} 1594}
1595
1514sub appletLink { 1596sub appletLink {
1515 my $url = shift; 1597 my $url = shift;
1516 my $options = shift; 1598 my $options = shift;
1517 $options = "" unless defined($options); 1599 $options = "" unless defined($options);
1518 M3( "{\\bf \\underline{APPLET} }", 1600 M3( "{\\bf \\underline{APPLET} }",
1605 } 1687 }
1606 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img') { 1688 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img') {
1607 $out .= "<TABLE BORDER=1>\n" 1689 $out .= "<TABLE BORDER=1>\n"
1608 } 1690 }
1609 else { 1691 else {
1610 $out = "Error: PGchoicemacros: begintable: Unknown displayMode: $displayMode.\n"; 1692 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n";
1611 } 1693 }
1612 $out; 1694 $out;
1613 } 1695 }
1614 1696
1615sub endtable { 1697sub endtable {
1622 } 1704 }
1623 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img') { 1705 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img') {
1624 $out .= "</TABLE>\n"; 1706 $out .= "</TABLE>\n";
1625 } 1707 }
1626 else { 1708 else {
1627 $out = "Error: PGchoicemacros: endtable: Unknown displayMode: $displayMode.\n"; 1709 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n";
1628 } 1710 }
1629 $out; 1711 $out;
1630 } 1712 }
1631 1713
1632 1714
1646 while (@elements) { 1728 while (@elements) {
1647 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n"; 1729 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n";
1648 } 1730 }
1649 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n"; 1731 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n";
1650 } 1732 }
1651 elsif ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img') { 1733 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img') {
1652 $out .= "<TR>\n"; 1734 $out .= "<TR>\n";
1653 while (@elements) { 1735 while (@elements) {
1654 $out .= "<TD>" . shift(@elements) . "</TD>"; 1736 $out .= "<TD>" . shift(@elements) . "</TD>";
1655 } 1737 }
1656 $out .= "\n</TR>\n"; 1738 $out .= "\n</TR>\n";
1657 } 1739 }
1658 else { 1740 else {
1659 $out = "Error: PGchoicemacros: row: Unknown displayMode: $main::displayMode.\n"; 1741 $out = "Error: PGbasicmacros: row: Unknown displayMode: $displayMode.\n";
1660 } 1742 }
1661 $out; 1743 $out;
1662} 1744}
1663 1745
1664=head2 Macros for displaying static images 1746=head2 Macros for displaying static images
1711 my @output_list = (); 1793 my @output_list = ();
1712 while(@image_list) { 1794 while(@image_list) {
1713 my $imageURL = alias(shift @image_list); 1795 my $imageURL = alias(shift @image_list);
1714 my $out=""; 1796 my $out="";
1715 1797
1716 if ($main::displayMode eq 'TeX') { 1798 if ($displayMode eq 'TeX') {
1717 my $imagePath = $imageURL; # in TeX mode, alias gives us a path, not a URL 1799 my $imagePath = $imageURL; # in TeX mode, alias gives us a path, not a URL
1718 if ($envir{texDisposition} eq "pdf") { 1800 if ($envir->{texDisposition} eq "pdf") {
1719 # We're going to create PDF files with our TeX (using pdflatex), so 1801 # We're going to create PDF files with our TeX (using pdflatex), so
1720 # alias should have given us the path to a PNG image. What we need 1802 # alias should have given us the path to a PNG image. What we need
1721 # to do is find out the dimmensions of this image, since pdflatex 1803 # to do is find out the dimmensions of this image, since pdflatex
1722 # is too dumb to live. 1804 # is too dumb to live.
1723 1805
1732 # Since we're not creating PDF files, alias should have given us the 1814 # Since we're not creating PDF files, alias should have given us the
1733 # path to an EPS file. latex can get its dimmensions no problem! 1815 # path to an EPS file. latex can get its dimmensions no problem!
1734 1816
1735 $out = "\\includegraphics[width=$width_ratio\\linewidth]{$imagePath}\n"; 1817 $out = "\\includegraphics[width=$width_ratio\\linewidth]{$imagePath}\n";
1736 } 1818 }
1737 } elsif ($main::displayMode eq 'Latex2HTML') { 1819 } elsif ($displayMode eq 'Latex2HTML') {
1738 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n 1820 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n
1739 \\end{rawhtml}\n ! 1821 \\end{rawhtml}\n !
1740 } elsif ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img') { 1822 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img') {
1741 $out = qq!<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A> 1823 $out = qq!<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>
1742 ! 1824 !
1743 } else { 1825 } else {
1744 $out = "Error: PGchoicemacros: image: Unknown displayMode: $main::displayMode.\n"; 1826 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n";
1745 } 1827 }
1746 push(@output_list, $out); 1828 push(@output_list, $out);
1747 } 1829 }
1748 return wantarray ? @output_list : $output_list[0]; 1830 return wantarray ? @output_list : $output_list[0];
1749} 1831}
1759} 1841}
1760 1842
1761 1843
1762sub caption { 1844sub caption {
1763 my ($out) = @_; 1845 my ($out) = @_;
1764 $out = " $out \n" if $main::displayMode eq 'TeX'; 1846 $out = " $out \n" if $displayMode eq 'TeX';
1765 $out = " $out " if $main::displayMode eq 'HTML'; 1847 $out = " $out " if $displayMode eq 'HTML';
1766 $out = " $out " if $main::displayMode eq 'HTML_tth'; 1848 $out = " $out " if $displayMode eq 'HTML_tth';
1767 $out = " $out " if $main::displayMode eq 'HTML_dpng'; 1849 $out = " $out " if $displayMode eq 'HTML_dpng';
1768 $out = " $out " if $main::displayMode eq 'HTML_img'; 1850 $out = " $out " if $displayMode eq 'HTML_img';
1769 $out = " $out " if $main::displayMode eq 'Latex2HTML'; 1851 $out = " $out " if $displayMode eq 'Latex2HTML';
1770 $out; 1852 $out;
1771} 1853}
1772 1854
1773sub captions { 1855sub captions {
1774 my @in = @_; 1856 my @in = @_;
1792 'height' => 100, 1874 'height' => 100,
1793 'width' => 100, 1875 'width' => 100,
1794 @_ # overwrite any default options 1876 @_ # overwrite any default options
1795 ); 1877 );
1796 1878
1797 if ($main::displayMode eq 'TeX') { 1879 if ($displayMode eq 'TeX') {
1798 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n"; 1880 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n";
1799 while (@images) { 1881 while (@images) {
1800 $out .= &image( shift(@images),%options ) . '&'; 1882 $out .= &image( shift(@images),%options ) . '&';
1801 } 1883 }
1802 chop($out); 1884 chop($out);
1804 while (@captions) { 1886 while (@captions) {
1805 $out .= &caption( shift(@captions) ) . '&'; 1887 $out .= &caption( shift(@captions) ) . '&';
1806 } 1888 }
1807 chop($out); 1889 chop($out);
1808 $out .= "\\\\ \\hline \n\\end {tabular}\\end{center}\\par\\smallskip\n"; 1890 $out .= "\\\\ \\hline \n\\end {tabular}\\end{center}\\par\\smallskip\n";
1809 } elsif ($main::displayMode eq 'Latex2HTML'){ 1891 } elsif ($displayMode eq 'Latex2HTML'){
1810 1892
1811 $out .= "\n\\begin{rawhtml} <TABLE BORDER=1><TR>\n\\end{rawhtml}\n"; 1893 $out .= "\n\\begin{rawhtml} <TABLE BORDER=1><TR>\n\\end{rawhtml}\n";
1812 while (@images) { 1894 while (@images) {
1813 $out .= "\n\\begin{rawhtml} <TD>\n\\end{rawhtml}\n" . &image( shift(@images),%options ) 1895 $out .= "\n\\begin{rawhtml} <TD>\n\\end{rawhtml}\n" . &image( shift(@images),%options )
1814 . "\n\\begin{rawhtml} </TD>\n\\end{rawhtml}\n" ; 1896 . "\n\\begin{rawhtml} </TD>\n\\end{rawhtml}\n" ;
1819 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) ) 1901 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) )
1820 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ; 1902 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ;
1821 } 1903 }
1822 1904
1823 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}"; 1905 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}";
1824 } elsif ($main::displayMode eq 'HTML' || $main::displayMode eq 'HTML_tth' || $main::displayMode eq 'HTML_dpng'|| $main::displayMode eq 'HTML_img'){ 1906 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'|| $displayMode eq 'HTML_img'){
1825 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n"; 1907 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n";
1826 while (@images) { 1908 while (@images) {
1827 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>"; 1909 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>";
1828 } 1910 }
1829 $out .= "</TR>\n<TR>"; 1911 $out .= "</TR>\n<TR>";
1831 $out .= " <TH>". &caption( shift(@captions) ) ."</TH>"; 1913 $out .= " <TH>". &caption( shift(@captions) ) ."</TH>";
1832 } 1914 }
1833 $out .= "\n</TR></TABLE></P>\n" 1915 $out .= "\n</TR></TABLE></P>\n"
1834 } 1916 }
1835 else { 1917 else {
1836 $out = "Error: PGchoicemacros: imageRow: Unknown languageMode: $main::displayMode.\n"; 1918 $out = "Error: PGbasicmacros: imageRow: Unknown languageMode: $displayMode.\n";
1837 warn $out; 1919 warn $out;
1838 } 1920 }
1839 $out; 1921 $out;
1840} 1922}
1841 1923

Legend:
Removed from v.1155  
changed lines
  Added in v.1462

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9