| … | |
… | |
| 43 | "begin"); |
43 | "begin"); |
| 44 | |
44 | |
| 45 | # install a local warn handler to collect warnings |
45 | # install a local warn handler to collect warnings |
| 46 | my $warnings = ""; |
46 | my $warnings = ""; |
| 47 | if ($courseEnv->{pg}->{options}->{catchWarnings}) { |
47 | if ($courseEnv->{pg}->{options}->{catchWarnings}) { |
|
|
48 | warn "PG: about to install a warnings handler...\n"; # *** |
| 48 | local $SIG{__WARN__} = sub { $warnings .= shift }; |
49 | local $SIG{__WARN__} = sub { $warnings .= shift }; |
| 49 | } |
50 | } |
| 50 | |
51 | |
| 51 | # create a Translator |
52 | # create a Translator |
| 52 | #warn "PG: creating a Translator\n"; |
53 | #warn "PG: creating a Translator\n"; |
| … | |
… | |
| 88 | |
89 | |
| 89 | # initialize the Translator |
90 | # initialize the Translator |
| 90 | #warn "PG: initializing the Translator\n"; |
91 | #warn "PG: initializing the Translator\n"; |
| 91 | $translator->initialize(); |
92 | $translator->initialize(); |
| 92 | |
93 | |
| 93 | # load PG.pl and dangerousMacros.pl using unrestricted_load |
94 | # load IO.pl, PG.pl, and dangerousMacros.pl using unrestricted_load |
| 94 | # i'd like to change this at some point to have the same sort of interface to global.conf |
95 | # i'd like to change this at some point to have the same sort of interface to global.conf |
| 95 | # that the module loading does -- have a list of macros to load unrestrictedly. |
96 | # that the module loading does -- have a list of macros to load unrestrictedly. |
| 96 | #warn "PG: loading PG.pl and dangerousMacros.pl using unrestricted_load\n"; |
97 | #warn "PG: loading IO.pl, PG.pl, and dangerousMacros.pl using unrestricted_load\n"; |
|
|
98 | foreach (qw(IO.pl PG.pl dangerousMacros.pl)) { |
|
|
99 | my $macroPath = $courseEnv->{webworkDirs}->{macros} . "/$_"; |
|
|
100 | my $err = $translator->unrestricted_load($macroPath); |
|
|
101 | warn "Error while loading $macroPath: $err" if $err; |
|
|
102 | } |
| 97 | my $pg_pl = $courseEnv->{webworkDirs}->{macros} . "/PG.pl"; |
103 | #my $pg_pl = $courseEnv->{webworkDirs}->{macros} . "/PG.pl"; |
| 98 | my $dangerousMacros_pl = $courseEnv->{webworkDirs}->{macros} . "/dangerousMacros.pl"; |
104 | #my $dangerousMacros_pl = $courseEnv->{webworkDirs}->{macros} . "/dangerousMacros.pl"; |
| 99 | my $io_pl = $courseEnv->{webworkDirs}->{macros} . "/IO.pl"; |
105 | #my $io_pl = $courseEnv->{webworkDirs}->{macros} . "/IO.pl"; |
| 100 | my $err = $translator->unrestricted_load($pg_pl); |
106 | #my $err = $translator->unrestricted_load($pg_pl); |
| 101 | warn "Error while loading $pg_pl: $err" if $err; |
107 | #warn "Error while loading $pg_pl: $err" if $err; |
| 102 | $err = $translator->unrestricted_load($dangerousMacros_pl); |
108 | #$err = $translator->unrestricted_load($dangerousMacros_pl); |
| 103 | warn "Error while loading $dangerousMacros_pl: $err" if $err; |
109 | #warn "Error while loading $dangerousMacros_pl: $err" if $err; |
| 104 | $err = $translator->unrestricted_load($io_pl); |
110 | #$err = $translator->unrestricted_load($io_pl); |
| 105 | warn "Error while loading $io_pl: $err" if $err; |
111 | #warn "Error while loading $io_pl: $err" if $err; |
| 106 | |
112 | |
| 107 | # set the opcode mask (using default values) |
113 | # set the opcode mask (using default values) |
| 108 | #warn "PG: setting the opcode mask (using default values)\n"; |
114 | #warn "PG: setting the opcode mask (using default values)\n"; |
| 109 | $translator->set_mask(); |
115 | $translator->set_mask(); |
| 110 | |
116 | |
| … | |
… | |
| 232 | # PG environment variables |
238 | # PG environment variables |
| 233 | # from docs/pglanguage/pgreference/environmentvariables as of 06/25/2002 |
239 | # from docs/pglanguage/pgreference/environmentvariables as of 06/25/2002 |
| 234 | # any changes are noted by "ADDED:" or "REMOVED:" |
240 | # any changes are noted by "ADDED:" or "REMOVED:" |
| 235 | |
241 | |
| 236 | # Vital state information |
242 | # Vital state information |
| 237 | # ADDED: displayHintsQ, displaySolutionsQ, refreshMath2img |
243 | # ADDED: displayHintsQ, displaySolutionsQ, refreshMath2img, |
|
|
244 | # texDisposition |
| 238 | |
245 | |
| 239 | $envir{psvn} = $psvn; |
246 | $envir{psvn} = $psvn; |
| 240 | $envir{psvnNumber} = $envir{psvn}; |
247 | $envir{psvnNumber} = $envir{psvn}; |
| 241 | $envir{probNum} = $problem->id; |
248 | $envir{probNum} = $problem->id; |
| 242 | $envir{questionNumber} = $envir{probNum}; |
249 | $envir{questionNumber} = $envir{probNum}; |
| … | |
… | |
| 247 | $envir{languageMode} = $envir{displayMode}; |
254 | $envir{languageMode} = $envir{displayMode}; |
| 248 | $envir{outputMode} = $envir{displayMode}; |
255 | $envir{outputMode} = $envir{displayMode}; |
| 249 | $envir{displayHintsQ} = $options->{hints}; |
256 | $envir{displayHintsQ} = $options->{hints}; |
| 250 | $envir{displaySolutionsQ} = $options->{solutions}; |
257 | $envir{displaySolutionsQ} = $options->{solutions}; |
| 251 | $envir{refreshMath2img} = $options->{refreshMath2img}; |
258 | $envir{refreshMath2img} = $options->{refreshMath2img}; |
|
|
259 | $envir{texDisposition} = "pdf"; # in webwork-modperl, we use pdflatex |
| 252 | |
260 | |
| 253 | # Problem Information |
261 | # Problem Information |
| 254 | # ADDED: courseName |
262 | # ADDED: courseName |
| 255 | |
263 | |
| 256 | $envir{openDate} = $set->open_date; |
264 | $envir{openDate} = $set->open_date; |
| … | |
… | |
| 288 | $envir{externalTTHPath} = $courseEnv->{externalPrograms}->{tth}; |
296 | $envir{externalTTHPath} = $courseEnv->{externalPrograms}->{tth}; |
| 289 | $envir{externalLaTeXPath} = $courseEnv->{externalPrograms}->{latex}; |
297 | $envir{externalLaTeXPath} = $courseEnv->{externalPrograms}->{latex}; |
| 290 | $envir{externalDvipngPath} = $courseEnv->{externalPrograms}->{dvipng}; |
298 | $envir{externalDvipngPath} = $courseEnv->{externalPrograms}->{dvipng}; |
| 291 | $envir{externalGif2EpsPath} = $courseEnv->{externalPrograms}->{gif2eps}; |
299 | $envir{externalGif2EpsPath} = $courseEnv->{externalPrograms}->{gif2eps}; |
| 292 | $envir{externalPng2EpsPath} = $courseEnv->{externalPrograms}->{png2eps}; |
300 | $envir{externalPng2EpsPath} = $courseEnv->{externalPrograms}->{png2eps}; |
|
|
301 | $envir{externalGif2PngPath} = $courseEnv->{externalPrograms}->{gif2png}; |
| 293 | |
302 | |
| 294 | # Directories and URLs |
303 | # Directories and URLs |
| 295 | # REMOVED: courseName |
304 | # REMOVED: courseName |
| 296 | # ADDED: dvipngTempDir |
305 | # ADDED: dvipngTempDir |
| 297 | |
|
|
| 298 | |
306 | |
| 299 | $envir{cgiDirectory} = undef; |
307 | $envir{cgiDirectory} = undef; |
| 300 | $envir{cgiURL} = undef; |
308 | $envir{cgiURL} = undef; |
| 301 | $envir{classDirectory} = undef; |
309 | $envir{classDirectory} = undef; |
| 302 | $envir{courseScriptsDirectory} = $courseEnv->{webworkDirs}->{macros}."/"; |
310 | $envir{courseScriptsDirectory} = $courseEnv->{webworkDirs}->{macros}."/"; |