| 1 | |
1 | #!/usr/local/bin/webwork-perl |
| 2 | |
2 | |
| 3 | # This file provided the fundamental macros for the pg language |
3 | # This file provided the fundamental macros for the pg language |
| 4 | # These macros define the interface between the problems written by |
4 | # These macros define the interface between the problems written by |
| 5 | # the professor and the processing which occurs in the script |
5 | # the professor and the processing which occurs in the script |
| 6 | # processProblem.pl |
6 | # processProblem.pl |
| … | |
… | |
| 125 | |
125 | |
| 126 | foreach my $var ( keys %main::envir ) { |
126 | foreach my $var ( keys %main::envir ) { |
| 127 | eval("\$main::$var =\$main::envir{'$var'}"); |
127 | eval("\$main::$var =\$main::envir{'$var'}"); |
| 128 | warn "Problem defining ", q{\$main::$var}, " while inititializing the PG problem: $@" if $@; |
128 | warn "Problem defining ", q{\$main::$var}, " while inititializing the PG problem: $@" if $@; |
| 129 | } |
129 | } |
|
|
130 | |
| 130 | @main::submittedAnswers = @{$main::refSubmittedAnswers} if defined($main::refSubmittedAnswers); |
131 | @main::submittedAnswers = @{$main::refSubmittedAnswers} if defined($main::refSubmittedAnswers); |
| 131 | $main::PG_original_problemSeed = $main::problemSeed; |
132 | $main::PG_original_problemSeed = $main::problemSeed; |
| 132 | $main::PG_random_generator = new PGrandom($main::problemSeed) || die "Can't create random number generator."; |
133 | $main::PG_random_generator = new PGrandom($main::problemSeed) || die "Can't create random number generator."; |
| 133 | $main::ans_rule_count = 0; # counts questions |
134 | $main::ans_rule_count = 0; # counts questions |
| 134 | |
135 | |
| … | |
… | |
| 239 | sub ANS_NUM_TO_NAME { # This converts a number to an answer label for use in |
240 | sub ANS_NUM_TO_NAME { # This converts a number to an answer label for use in |
| 240 | # radio button and check box answers. No new answer |
241 | # radio button and check box answers. No new answer |
| 241 | # name is recorded. |
242 | # name is recorded. |
| 242 | my $number=shift; |
243 | my $number=shift; |
| 243 | my $label = "$main::ANSWER_PREFIX$number"; |
244 | my $label = "$main::ANSWER_PREFIX$number"; |
|
|
245 | $label; |
|
|
246 | } |
|
|
247 | |
|
|
248 | my $vecnum; |
|
|
249 | |
|
|
250 | sub NEW_ANS_ARRAY_NAME { # this keeps track of the answers which are entered implicitly, |
|
|
251 | # rather than with a specific label |
|
|
252 | my $number=shift; |
|
|
253 | $vecnum = 0; |
|
|
254 | my $row = shift; |
|
|
255 | my $col = shift; |
|
|
256 | my $label = "ArRaY"."$number"."["."$vecnum".","."$row".","."$col"."]"; |
|
|
257 | push(@PG_UNLABELED_ANSWERS,$label); |
|
|
258 | $label; |
|
|
259 | } |
|
|
260 | |
|
|
261 | sub NEW_ANS_ARRAY_NAME_EXTENSION { # this keeps track of the answers which are entered implicitly, |
|
|
262 | # rather than with a specific label |
|
|
263 | my $number=shift; |
|
|
264 | my $row = shift; |
|
|
265 | my $col = shift; |
|
|
266 | if( $row == 0 && $col == 0 ){ |
|
|
267 | $vecnum += 1; |
|
|
268 | } |
|
|
269 | my $label = "ArRaY"."$number"."["."$vecnum".","."$row".","."$col"."]"; |
| 244 | $label; |
270 | $label; |
| 245 | } |
271 | } |
| 246 | |
272 | |
| 247 | # ENDDOCUMENT must come at the end of every .pg file. |
273 | # ENDDOCUMENT must come at the end of every .pg file. |
| 248 | # It exports the resulting text of the problem, the text to be used in HTML header material |
274 | # It exports the resulting text of the problem, the text to be used in HTML header material |