[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 3267 Revision 3268
69 $rh_sticky_answers, 69 $rh_sticky_answers,
70 $r_ans_rule_count, 70 $r_ans_rule_count,
71 ); 71 );
72 72
73sub _PGbasicmacros_init { 73sub _PGbasicmacros_init {
74
75 # The big problem is that at compile time in the cached Safe compartment 74 # The big problem is that at compile time in the cached Safe compartment
76 # main:: has one definition, probably Safe::Root1:: 75 # main:: has one definition, probably Safe::Root1::
77 # At runtime main has another definition Safe::Rootx:: where x is > 1 76 # At runtime main has another definition Safe::Rootx:: where x is > 1
78 77
79 # It is important to 78 # It is important to
265 NAMED_ANS_RULE($name,$col); 264 NAMED_ANS_RULE($name,$col);
266} 265}
267 266
268sub NAMED_ANS_RULE { 267sub NAMED_ANS_RULE {
269 my($name,$col) = @_; 268 my($name,$col) = @_;
270 my $len = 0.07*$col;
271 my $answer_value = ''; 269 my $answer_value = '';
272 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name}); 270 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
273 if ($answer_value =~ /\0/ ) { 271 if ($answer_value =~ /\0/ ) {
274 my @answers = split("\0", $answer_value); 272 my @answers = split("\0", $answer_value);
275 $answer_value = shift(@answers); # use up the first answer 273 $answer_value = shift(@answers); # use up the first answer
287 } 285 }
288 286
289 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3 287 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
290 $name = RECORD_ANS_NAME($name); 288 $name = RECORD_ANS_NAME($name);
291 289
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 290 my $tcol = $col/2 > 3 ? $col/2 : 3; ## get max
296 $tcol = $tcol < 40 ? $tcol : 40; ## get min 291 $tcol = $tcol < 40 ? $tcol : 40; ## get min
297 292
298 MODES( 293 MODES(
299 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}", 294 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
307 &NAMED_ANS_RULE_EXTENSION; 302 &NAMED_ANS_RULE_EXTENSION;
308} 303}
309 304
310sub NAMED_ANS_RULE_EXTENSION { 305sub NAMED_ANS_RULE_EXTENSION {
311 my($name,$col) = @_; 306 my($name,$col) = @_;
312 my $len = 0.07*$col;
313 my $answer_value = ''; 307 my $answer_value = '';
314 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name}); 308 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
315 if ( defined( $rh_sticky_answers->{$name} ) ) { 309 if ( defined( $rh_sticky_answers->{$name} ) ) {
316 $answer_value = shift( @{ $rh_sticky_answers->{$name} }); 310 $answer_value = shift( @{ $rh_sticky_answers->{$name} });
317 $answer_value = '' unless defined($answer_value); 311 $answer_value = '' unless defined($answer_value);
318 } 312 }
319 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3 313 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
314 my $tcol = $col/2 > 3 ? $col/2 : 3; ## get max
315 $tcol = $tcol < 40 ? $tcol : 40; ## get min
320 MODES( 316 MODES(
321 TeX => '\\hrulefill\\quad ', 317 TeX => "\\mbox{\\parbox[t]{${tcol}ex}{\\hrulefill}}",
322 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!, 318 Latex2HTML => qq!\\begin{rawhtml}\n<INPUT TYPE=TEXT SIZE=$col NAME=\"$name\" VALUE = \"\">\n\\end{rawhtml}\n!,
323 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME = "$name" VALUE = "$answer_value">\n 319 HTML => qq!<INPUT TYPE=TEXT SIZE=$col NAME = "$name" VALUE = "$answer_value">!.
324 <INPUT TYPE=HIDDEN NAME="previous_$name" VALUE = "$answer_value"> 320 qq!<INPUT TYPE=HIDDEN NAME="previous_$name" VALUE = "$answer_value">!
325 !
326 ); 321 );
327} 322}
328 323
329sub ANS_RULE { #deprecated 324sub ANS_RULE { #deprecated
330 my($number,$col) = @_; 325 my($number,$col) = @_;
336sub NAMED_ANS_BOX { 331sub NAMED_ANS_BOX {
337 my($name,$row,$col) = @_; 332 my($name,$row,$col) = @_;
338 $row = 10 unless defined($row); 333 $row = 10 unless defined($row);
339 $col = 80 unless defined($col); 334 $col = 80 unless defined($col);
340 $name = RECORD_ANS_NAME($name); 335 $name = RECORD_ANS_NAME($name);
341 my $len = 0.07*$col;
342 my $height = .07*$row; 336 my $height = .07*$row;
343 my $answer_value = ''; 337 my $answer_value = '';
344 $answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} ); 338 $answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} );
345 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3 339 $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3
346 my $out = M3( 340 my $out = M3(
1162# Adopted Davide Cervone's improvements to PAR, LTS, GTS, LTE, GTE, LBRACE, RBRACE, LB, RB. 7-14-03 AKP 1156# Adopted Davide Cervone's improvements to PAR, LTS, GTS, LTE, GTE, LBRACE, RBRACE, LB, RB. 7-14-03 AKP
1163sub PAR { MODES( TeX => '\\par ', Latex2HTML => '\\begin{rawhtml}<P>\\end{rawhtml}', HTML => '<P>'); }; 1157sub PAR { MODES( TeX => '\\par ', Latex2HTML => '\\begin{rawhtml}<P>\\end{rawhtml}', HTML => '<P>'); };
1164sub BR { MODES( TeX => '\\par\\noindent ', Latex2HTML => '\\begin{rawhtml}<BR>\\end{rawhtml}', HTML => '<BR>'); }; 1158sub BR { MODES( TeX => '\\par\\noindent ', Latex2HTML => '\\begin{rawhtml}<BR>\\end{rawhtml}', HTML => '<BR>'); };
1165# Alternate definition of BR which is slightly more flexible and gives more white space in printed output 1159# Alternate definition of BR which is slightly more flexible and gives more white space in printed output
1166# which looks better but kills more trees. 1160# which looks better but kills more trees.
1167#sub BR { MODES( TeX => '\\\\', Latex2HTML => '\\begin{rawhtml}<BR>\\end{rawhtml}', HTML => '<BR>'); }; 1161#sub BR { MODES( TeX => '\\leavevmode\\\\', Latex2HTML => '\\begin{rawhtml}<BR>\\end{rawhtml}', HTML => '<BR>'); };
1168sub LQ { MODES( TeX => "``", Latex2HTML => '"', HTML => '&quot;' ); }; 1162sub LQ { MODES( TeX => "``", Latex2HTML => '"', HTML => '&quot;' ); };
1169sub RQ { MODES( TeX => "''", Latex2HTML => '"', HTML => '&quot;' ); }; 1163sub RQ { MODES( TeX => "''", Latex2HTML => '"', HTML => '&quot;' ); };
1170sub BM { MODES(TeX => '\\(', Latex2HTML => '\\(', HTML => ''); }; # begin math mode 1164sub BM { MODES(TeX => '\\(', Latex2HTML => '\\(', HTML => ''); }; # begin math mode
1171sub EM { MODES(TeX => '\\)', Latex2HTML => '\\)', HTML => ''); }; # end math mode 1165sub EM { MODES(TeX => '\\)', Latex2HTML => '\\)', HTML => ''); }; # end math mode
1172sub BDM { MODES(TeX => '\\[', Latex2HTML => '\\[', HTML => '<P ALIGN=CENTER>'); }; #begin displayMath mode 1166sub BDM { MODES(TeX => '\\[', Latex2HTML => '\\[', HTML => '<P ALIGN=CENTER>'); }; #begin displayMath mode

Legend:
Removed from v.3267  
changed lines
  Added in v.3268

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9