[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 6059 Revision 6080
309 $tcol = $tcol < 40 ? $tcol : 40; ## get min 309 $tcol = $tcol < 40 ? $tcol : 40; ## get min
310 310
311 MODES( 311 MODES(
312 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}", 312 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
313 Latex2HTML => qq!\\begin{rawhtml}<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\\end{rawhtml}!, 313 Latex2HTML => qq!\\begin{rawhtml}<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\\end{rawhtml}!,
314 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME="$name" VALUE="$answer_value">!. 314 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME="$name" id="$name" VALUE="$answer_value">!.
315 qq!<INPUT TYPE=HIDDEN NAME="previous_$name" VALUE="$answer_value">! 315 qq!<INPUT TYPE=HIDDEN NAME="previous_$name" VALUE="$answer_value">!
316 ); 316 );
317} 317}
318 318
319sub NAMED_HIDDEN_ANS_RULE { # this is used to hold information being passed into and out of applets 319sub NAMED_HIDDEN_ANS_RULE { # this is used to hold information being passed into and out of applets
367 $answer_value =~ s/\s+/ /g; ## remove excessive whitespace from student answer 367 $answer_value =~ s/\s+/ /g; ## remove excessive whitespace from student answer
368 my $tcol = $col/2 > 3 ? $col/2 : 3; ## get max 368 my $tcol = $col/2 > 3 ? $col/2 : 3; ## get max
369 $tcol = $tcol < 40 ? $tcol : 40; ## get min 369 $tcol = $tcol < 40 ? $tcol : 40; ## get min
370 MODES( 370 MODES(
371 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}", 371 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
372 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!, 372 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME="$name" id="$name" VALUE = " ">\n\\end{rawhtml}\n!,
373 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME = "$name" VALUE = "$answer_value">!. 373 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME = "$name" id="$name" VALUE = "$answer_value">!.
374 qq!<INPUT TYPE=HIDDEN NAME="previous_$name" VALUE = "$answer_value">! 374 qq!<INPUT TYPE=HIDDEN NAME="previous_$name" VALUE = "$answer_value">!
375 ); 375 );
376} 376}
377 377
378sub ANS_RULE { #deprecated 378sub ANS_RULE { #deprecated
389 $name = RECORD_ANS_NAME($name); 389 $name = RECORD_ANS_NAME($name);
390 my $height = .07*$row; 390 my $height = .07*$row;
391 my $answer_value = ''; 391 my $answer_value = '';
392 $answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} ); 392 $answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} );
393# $answer_value =~ tr/\\$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3 393# $answer_value =~ tr/\\$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3
394 my $out = M3( 394 my $out = MODES(
395 qq!\\vskip $height in \\hrulefill\\quad !, 395 TeX => qq!\\vskip $height in \\hrulefill\\quad !,
396 qq!\\begin{rawhtml}<TEXTAREA NAME="$name" ROWS="$row" COLS="$col" 396 Latex2HTML => qq!\\begin{rawhtml}<TEXTAREA NAME="$name" id="$name" ROWS="$row" COLS="$col"
397 WRAP="VIRTUAL">$answer_value</TEXTAREA>\\end{rawhtml}!, 397 WRAP="VIRTUAL">$answer_value</TEXTAREA>\\end{rawhtml}!,
398 qq!<TEXTAREA NAME="$name" ROWS="$row" COLS="$col" 398 HTML => qq!<TEXTAREA NAME="$name" id="$name" ROWS="$row" COLS="$col"
399 WRAP="VIRTUAL">$answer_value</TEXTAREA> 399 WRAP="VIRTUAL">$answer_value</TEXTAREA>
400 <INPUT TYPE=HIDDEN NAME="previous_$name" VALUE = "$answer_value"> 400 <INPUT TYPE=HIDDEN NAME="previous_$name" VALUE = "$answer_value">
401 ! 401 !
402 ); 402 );
403 $out; 403 $out;
428 428
429 } 429 }
430 430
431 MODES( 431 MODES(
432 TeX => qq!\\item{$tag}\n!, 432 TeX => qq!\\item{$tag}\n!,
433 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=RADIO NAME="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!, 433 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=RADIO NAME="$name" id="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!,
434 HTML => qq!<INPUT TYPE=RADIO NAME="$name" VALUE="$value" $checked>$tag! 434 HTML => qq!<INPUT TYPE=RADIO NAME="$name" id="$name" VALUE="$value" $checked>$tag!
435 ); 435 );
436 436
437} 437}
438 438
439sub NAMED_ANS_RADIO_OPTION { #deprecated 439sub NAMED_ANS_RADIO_OPTION { #deprecated
460 460
461 } 461 }
462 462
463 MODES( 463 MODES(
464 TeX => qq!\\item{$tag}\n!, 464 TeX => qq!\\item{$tag}\n!,
465 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=RADIO NAME="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!, 465 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=RADIO NAME="$name" id="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!,
466 HTML => qq!<INPUT TYPE=RADIO NAME="$name" VALUE="$value" $checked>$tag! 466 HTML => qq!<INPUT TYPE=RADIO NAME="$name" id="$name" VALUE="$value" $checked>$tag!
467 ); 467 );
468 468
469} 469}
470 470
471sub NAMED_ANS_RADIO_BUTTONS { 471sub NAMED_ANS_RADIO_BUTTONS {
571 571
572 } 572 }
573 573
574 MODES( 574 MODES(
575 TeX => qq!\\item{$tag}\n!, 575 TeX => qq!\\item{$tag}\n!,
576 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=CHECKBOX NAME="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!, 576 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=CHECKBOX NAME="$name" id="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!,
577 HTML => qq!<INPUT TYPE=CHECKBOX NAME="$name" VALUE="$value" $checked>$tag! 577 HTML => qq!<INPUT TYPE=CHECKBOX NAME="$name" id="$name" VALUE="$value" $checked>$tag!
578 ); 578 );
579 579
580} 580}
581 581
582sub NAMED_ANS_CHECKBOX_OPTION { 582sub NAMED_ANS_CHECKBOX_OPTION {
600 600
601 } 601 }
602 602
603 MODES( 603 MODES(
604 TeX => qq!\\item{$tag}\n!, 604 TeX => qq!\\item{$tag}\n!,
605 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=CHECKBOX NAME="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!, 605 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=CHECKBOX NAME="$name" id="$name" VALUE="$value" $checked>\\end{rawhtml}$tag!,
606 HTML => qq!<INPUT TYPE=CHECKBOX NAME="$name" VALUE="$value" $checked>$tag! 606 HTML => qq!<INPUT TYPE=CHECKBOX NAME="$name" id="$name" VALUE="$value" $checked>$tag!
607 ); 607 );
608 608
609} 609}
610 610
611sub NAMED_ANS_CHECKBOX_BUTTONS { 611sub NAMED_ANS_CHECKBOX_BUTTONS {
793 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name}); 793 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
794 my $out = ""; 794 my $out = "";
795 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or 795 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or
796 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img' or $displayMode eq 'HTML_jsMath' or 796 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img' or $displayMode eq 'HTML_jsMath' or
797 $displayMode eq 'HTML_asciimath' or $displayMode eq 'HTML_LaTeXMathML') { 797 $displayMode eq 'HTML_asciimath' or $displayMode eq 'HTML_LaTeXMathML') {
798 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!; 798 $out = qq!<SELECT NAME = "$name" id="$name" SIZE=1> \n!;
799 my $i; 799 my $i;
800 foreach ($i=0; $i< @list; $i=$i+2) { 800 foreach ($i=0; $i< @list; $i=$i+2) {
801 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : ""; 801 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : "";
802 $out .= qq!<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\n!; 802 $out .= qq!<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\n!;
803 }; 803 };
804 $out .= " </SELECT>\n"; 804 $out .= " </SELECT>\n";
805 } elsif ( $displayMode eq "Latex2HTML") { 805 } elsif ( $displayMode eq "Latex2HTML") {
806 $out = qq! \\begin{rawhtml}<SELECT NAME = "$name" SIZE=1> \\end{rawhtml} \n !; 806 $out = qq! \\begin{rawhtml}<SELECT NAME = "$name" id="$name" SIZE=1> \\end{rawhtml} \n !;
807 my $i; 807 my $i;
808 foreach ($i=0; $i< @list; $i=$i+2) { 808 foreach ($i=0; $i< @list; $i=$i+2) {
809 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : ""; 809 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : "";
810 $out .= qq!\\begin{rawhtml}<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\\end{rawhtml}\n!; 810 $out .= qq!\\begin{rawhtml}<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\\end{rawhtml}\n!;
811 }; 811 };
885 } 885 }
886 886
887 $answer_value =~ tr/\\$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3 887 $answer_value =~ tr/\\$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3
888 MODES( 888 MODES(
889 TeX => "\\mbox{\\parbox[t]{10pt}{\\hrulefill}}\\hrulefill\\quad ", 889 TeX => "\\mbox{\\parbox[t]{10pt}{\\hrulefill}}\\hrulefill\\quad ",
890 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!, 890 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME="$name" id="$name" VALUE = "">\n\\end{rawhtml}\n!,
891 HTML => "<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"$answer_value\">\n" 891 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME="$name" id="$name" VALUE = "$answer_value">\n!
892 ); 892 );
893} 893}
894 894
895sub ans_array{ 895sub ans_array{
896 my $m = shift; 896 my $m = shift;

Legend:
Removed from v.6059  
changed lines
  Added in v.6080

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9