| … | |
… | |
| 14 | use strict; |
14 | use strict; |
| 15 | use warnings; |
15 | use warnings; |
| 16 | use File::Path qw(rmtree); |
16 | use File::Path qw(rmtree); |
| 17 | use File::Temp qw(tempdir); |
17 | use File::Temp qw(tempdir); |
| 18 | use WeBWorK::PG::Translator; |
18 | use WeBWorK::PG::Translator; |
| 19 | use WeBWorK::Problem; |
|
|
| 20 | use WeBWorK::Utils qw(readFile formatDateTime writeTimingLogEntry); |
19 | use WeBWorK::Utils qw(readFile formatDateTime writeTimingLogEntry); |
| 21 | |
20 | |
| 22 | sub new($$$$$$$$) { |
21 | sub new($$$$$$$$) { |
| 23 | my $invocant = shift; |
22 | my $invocant = shift; |
| 24 | my $class = ref($invocant) || $invocant; |
23 | my $class = ref($invocant) || $invocant; |
| … | |
… | |
| 35 | # hints and the display mode to use |
34 | # hints and the display mode to use |
| 36 | ) = @_; |
35 | ) = @_; |
| 37 | |
36 | |
| 38 | # write timing log entry |
37 | # write timing log entry |
| 39 | writeTimingLogEntry($courseEnv, "WeBWorK::PG::new", |
38 | writeTimingLogEntry($courseEnv, "WeBWorK::PG::new", |
| 40 | "user=".$user->id.",problem=".$courseEnv->{courseName}."/".$set->id."/".$problem->id.",mode=".$translationOptions->{displayMode}, |
39 | "user=".$user->id.",problem=".$courseEnv->{courseName}."/".$set->set_id."/".$problem->problem_id.",mode=".$translationOptions->{displayMode}, |
| 41 | "begin"); |
40 | "begin"); |
| 42 | |
41 | |
| 43 | # install a local warn handler to collect warnings |
42 | # install a local warn handler to collect warnings |
| 44 | my $warnings = ""; |
43 | my $warnings = ""; |
| 45 | local $SIG{__WARN__} = sub { $warnings .= shift } |
44 | local $SIG{__WARN__} = sub { $warnings .= shift } |
| … | |
… | |
| 235 | # ADDED: displayHintsQ, displaySolutionsQ, refreshMath2img, |
234 | # ADDED: displayHintsQ, displaySolutionsQ, refreshMath2img, |
| 236 | # texDisposition |
235 | # texDisposition |
| 237 | |
236 | |
| 238 | $envir{psvn} = $psvn; |
237 | $envir{psvn} = $psvn; |
| 239 | $envir{psvnNumber} = $envir{psvn}; |
238 | $envir{psvnNumber} = $envir{psvn}; |
| 240 | $envir{probNum} = $problem->id; |
239 | $envir{probNum} = $problem->problem_id; |
| 241 | $envir{questionNumber} = $envir{probNum}; |
240 | $envir{questionNumber} = $envir{probNum}; |
| 242 | $envir{fileName} = $problem->source_file; |
241 | $envir{fileName} = $problem->source_file; |
| 243 | $envir{probFileName} = $envir{fileName}; |
242 | $envir{probFileName} = $envir{fileName}; |
| 244 | $envir{problemSeed} = $problem->problem_seed; |
243 | $envir{problemSeed} = $problem->problem_seed; |
| 245 | $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); |
244 | $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); |
| … | |
… | |
| 270 | |
269 | |
| 271 | $envir{sectionName} = $user->section; |
270 | $envir{sectionName} = $user->section; |
| 272 | $envir{sectionNumber} = $envir{sectionName}; |
271 | $envir{sectionNumber} = $envir{sectionName}; |
| 273 | $envir{recitationName} = $user->recitation; |
272 | $envir{recitationName} = $user->recitation; |
| 274 | $envir{recitationNumber} = $envir{recitationName}; |
273 | $envir{recitationNumber} = $envir{recitationName}; |
| 275 | $envir{setNumber} = $set->id; |
274 | $envir{setNumber} = $set->set_id; |
| 276 | $envir{studentLogin} = $user->id; |
275 | $envir{studentLogin} = $user->id; |
| 277 | $envir{studentName} = $user->first_name . " " . $user->last_name; |
276 | $envir{studentName} = $user->first_name . " " . $user->last_name; |
| 278 | $envir{studentID} = $user->student_id; |
277 | $envir{studentID} = $user->student_id; |
| 279 | |
278 | |
| 280 | # Answer Information |
279 | # Answer Information |
| … | |
… | |
| 371 | |
370 | |
| 372 | =head1 SYNOPSIS |
371 | =head1 SYNOPSIS |
| 373 | |
372 | |
| 374 | $pg = WeBWorK::PG->new( |
373 | $pg = WeBWorK::PG->new( |
| 375 | $courseEnv, # a WeBWorK::CourseEnvironment object |
374 | $courseEnv, # a WeBWorK::CourseEnvironment object |
| 376 | $user, # a WeBWorK::User object |
375 | $user, # a WeBWorK::DB::Record::User object |
| 377 | $sessionKey, |
376 | $sessionKey, |
| 378 | $set, # a WeBWorK::Set object |
377 | $set, # a WeBWorK::DB::Record::UserSet object |
| 379 | $problem, # a WeBWorK::Problem object |
378 | $problem, # a WeBWorK::DB::Record::UserProblem object |
| 380 | $psvn, |
379 | $psvn, |
| 381 | $formFields # in &WeBWorK::Form::Vars format |
380 | $formFields # in &WeBWorK::Form::Vars format |
| 382 | { # translation options |
381 | { # translation options |
| 383 | displayMode => "images", # (plainText|formattedText|images) |
382 | displayMode => "images", # (plainText|formattedText|images) |
| 384 | showHints => 1, # (0|1) |
383 | showHints => 1, # (0|1) |
| … | |
… | |
| 436 | |
435 | |
| 437 | a WeBWorK::Set object |
436 | a WeBWorK::Set object |
| 438 | |
437 | |
| 439 | =item PROBLEM |
438 | =item PROBLEM |
| 440 | |
439 | |
| 441 | a WeBWorK::Problem object. The contents of the source_file field can specify a |
440 | a WeBWorK::DB::Record::UserProblem object. The contents of the source_file |
| 442 | PG file either by absolute path or path relative to the "templates" directory. |
441 | field can specify a PG file either by absolute path or path relative to the |
| 443 | I<The caller should remove taint from this value before passing!> |
442 | "templates" directory. I<The caller should remove taint from this value before |
|
|
443 | passing!> |
| 444 | |
444 | |
| 445 | =item PSVN |
445 | =item PSVN |
| 446 | |
446 | |
| 447 | the problem set version number |
447 | the problem set version number |
| 448 | |
448 | |