[system] / trunk / webwork-modperl / lib / WeBWorK / PG.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WeBWorK/PG.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 561 Revision 562
17use File::Temp qw(tempdir); 17use File::Temp qw(tempdir);
18use WeBWorK::DB::Classlist; 18use WeBWorK::DB::Classlist;
19use WeBWorK::DB::WW; 19use WeBWorK::DB::WW;
20use WeBWorK::PG::Translator; 20use WeBWorK::PG::Translator;
21use WeBWorK::Problem; 21use WeBWorK::Problem;
22use WeBWorK::Utils qw(readFile formatDateTime); 22use WeBWorK::Utils qw(readFile formatDateTime writeTimingLogEntry);
23 23
24sub new($$$$$$$$) { 24sub new($$$$$$$$) {
25 my $invocant = shift; 25 my $invocant = shift;
26 my $class = ref($invocant) || $invocant; 26 my $class = ref($invocant) || $invocant;
27 my ( 27 my (
35 $translationOptions, # hashref containing options for the 35 $translationOptions, # hashref containing options for the
36 # translator, such as whether to show 36 # translator, such as whether to show
37 # hints and the display mode to use 37 # hints and the display mode to use
38 ) = @_; 38 ) = @_;
39 39
40 # write timing log entry
41 writeTimingLogEntry($courseEnv, "WeBWorK::PG::new",
42 "user=".$user->id.",problem=".$courseEnv->{courseName}."/".$set->id."/".$problem->id.",mode=".$translationOptions->{displayMode},
43 "begin");
44
40 # install a local warn handler to collect warnings 45 # install a local warn handler to collect warnings
41 my $warnings = ""; 46 my $warnings = "";
42 local $SIG{__WARN__} = sub { $warnings .= shift }; 47 local $SIG{__WARN__} = sub { $warnings .= shift };
43 48
44 # create a Translator 49 # create a Translator
87 # i'd like to change this at some point to have the same sort of interface to global.conf 92 # i'd like to change this at some point to have the same sort of interface to global.conf
88 # that the module loading does -- have a list of macros to load unrestrictedly. 93 # that the module loading does -- have a list of macros to load unrestrictedly.
89 #warn "PG: loading PG.pl and dangerousMacros.pl using unrestricted_load\n"; 94 #warn "PG: loading PG.pl and dangerousMacros.pl using unrestricted_load\n";
90 my $pg_pl = $courseEnv->{webworkDirs}->{macros} . "/PG.pl"; 95 my $pg_pl = $courseEnv->{webworkDirs}->{macros} . "/PG.pl";
91 my $dangerousMacros_pl = $courseEnv->{webworkDirs}->{macros} . "/dangerousMacros.pl"; 96 my $dangerousMacros_pl = $courseEnv->{webworkDirs}->{macros} . "/dangerousMacros.pl";
97 my $io_pl = $courseEnv->{webworkDirs}->{macros} . "/IO.pl";
92 my $err = $translator->unrestricted_load($pg_pl); 98 my $err = $translator->unrestricted_load($pg_pl);
93 warn "Error while loading $pg_pl: $err" if $err; 99 warn "Error while loading $pg_pl: $err" if $err;
94 $err = $translator->unrestricted_load($dangerousMacros_pl); 100 $err = $translator->unrestricted_load($dangerousMacros_pl);
95 warn "Error while loading $dangerousMacros_pl: $err" if $err; 101 warn "Error while loading $dangerousMacros_pl: $err" if $err;
102 $err = $translator->unrestricted_load($io_pl);
103 warn "Error while loading $io_pl: $err" if $err;
96 104
97 # set the opcode mask (using default values) 105 # set the opcode mask (using default values)
98 #warn "PG: setting the opcode mask (using default values)\n"; 106 #warn "PG: setting the opcode mask (using default values)\n";
99 $translator->set_mask(); 107 $translator->set_mask();
100 108
182 ANSWER_ENTRY_ORDER => \@answerOrder, 190 ANSWER_ENTRY_ORDER => \@answerOrder,
183 ); 191 );
184 192
185 } 193 }
186 194
195 # write timing log entry
196 writeTimingLogEntry($courseEnv, "WeBWorK::PG::new", "", "end");
197
187 # return an object which contains the translator and the results of 198 # return an object which contains the translator and the results of
188 # the translation process. this is DIFFERENT from the "format expected 199 # the translation process. this is DIFFERENT from the "format expected
189 # by Webwork.pm (and I believe processProblem8, but check.)" 200 # by Webwork.pm (and I believe processProblem8, but check.)"
190 return bless { 201 return bless {
191 translator => $translator, 202 translator => $translator,
267 # REMOVED: refSubmittedAnswers 278 # REMOVED: refSubmittedAnswers
268 279
269 $envir{inputs_ref} = $formFields; 280 $envir{inputs_ref} = $formFields;
270 281
271 # External Programs 282 # External Programs
272 # ADDED: externalLaTeXPath, externalDvipngPath, externalMath2imgPath 283 # ADDED: externalLaTeXPath, externalDvipngPath,
284 # externalGif2EpsPath, externalPng2EpsPath
273 285
274 $envir{externalTTHPath} = $courseEnv->{externalPrograms}->{tth}; 286 $envir{externalTTHPath} = $courseEnv->{externalPrograms}->{tth};
275 $envir{externalLaTeXPath} = $courseEnv->{externalPrograms}->{latex}; 287 $envir{externalLaTeXPath} = $courseEnv->{externalPrograms}->{latex};
276 $envir{externalDvipngPath} = $courseEnv->{externalPrograms}->{dvipng}; 288 $envir{externalDvipngPath} = $courseEnv->{externalPrograms}->{dvipng};
277 $envir{externalMath2imgPath} = $courseEnv->{externalPrograms}->{math2img}; 289 $envir{externalGif2EpsPath} = $courseEnv->{externalPrograms}->{gif2eps};
290 $envir{externalPng2EpsPath} = $courseEnv->{externalPrograms}->{png2eps};
278 291
279 # Directories and URLs 292 # Directories and URLs
280 # REMOVED: courseName 293 # REMOVED: courseName
281 # ADDED: dvipngTempDir 294 # ADDED: dvipngTempDir
282 295
284 $envir{cgiDirectory} = undef; 297 $envir{cgiDirectory} = undef;
285 $envir{cgiURL} = undef; 298 $envir{cgiURL} = undef;
286 $envir{classDirectory} = undef; 299 $envir{classDirectory} = undef;
287 $envir{courseScriptsDirectory} = $courseEnv->{webworkDirs}->{macros}."/"; 300 $envir{courseScriptsDirectory} = $courseEnv->{webworkDirs}->{macros}."/";
288 $envir{htmlDirectory} = $courseEnv->{courseDirs}->{html}."/"; 301 $envir{htmlDirectory} = $courseEnv->{courseDirs}->{html}."/";
289 $envir{htmlURL} = $courseEnv->{courseURLs}->{html}; 302 $envir{htmlURL} = $courseEnv->{courseURLs}->{html}."/";
290 $envir{macroDirectory} = $courseEnv->{courseDirs}->{macros}."/"; 303 $envir{macroDirectory} = $courseEnv->{courseDirs}->{macros}."/";
291 $envir{templateDirectory} = $courseEnv->{courseDirs}->{templates}."/"; 304 $envir{templateDirectory} = $courseEnv->{courseDirs}->{templates}."/";
292 $envir{tempDirectory} = $courseEnv->{courseDirs}->{html_temp}."/"; 305 $envir{tempDirectory} = $courseEnv->{courseDirs}->{html_temp}."/";
293 $envir{tempURL} = $courseEnv->{courseURLs}->{html_temp}; 306 $envir{tempURL} = $courseEnv->{courseURLs}->{html_temp}."/";
294 $envir{scriptDirectory} = undef; 307 $envir{scriptDirectory} = undef;
295 $envir{webworkDocsURL} = $courseEnv->{webworkURLs}->{docs}; 308 $envir{webworkDocsURL} = $courseEnv->{webworkURLs}->{docs}."/";
296 $envir{dvipngTempDir} = $options->{displayMode} eq 'images' 309 $envir{dvipngTempDir} = $options->{displayMode} eq 'images'
297 ? tempdir("webwork-dvipng-XXXXXXXX", DIR => $envir{tempDirectory}) 310 ? tempdir("webwork-dvipng-XXXXXXXX", DIR => $envir{tempDirectory})
298 : undef; 311 : undef;
299 312
300 # Default values for evaluating answers 313 # Default values for evaluating answers

Legend:
Removed from v.561  
changed lines
  Added in v.562

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9