[system] / trunk / webwork2 / lib / WeBWorK / PG.pm Repository:
ViewVC logotype

Annotation of /trunk/webwork2/lib/WeBWorK/PG.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 609 - (view) (download) (as text)

1 : sh002i 440 ################################################################################
2 : sh002i 494 # WeBWorK mod_perl (c) 2000-2002 WeBWorK Project
3 : sh002i 440 # $Id$
4 :     ################################################################################
5 :    
6 : sh002i 424 package WeBWorK::PG;
7 : sh002i 414
8 : sh002i 455 =head1 NAME
9 :    
10 : sh002i 476 WeBWorK::PG - Wrap the action of the PG Translator in an easy-to-use API.
11 : sh002i 455
12 :     =cut
13 :    
14 : sh002i 414 use strict;
15 :     use warnings;
16 : sh002i 555 use File::Path qw(rmtree);
17 : sh002i 526 use File::Temp qw(tempdir);
18 : sh002i 414 use WeBWorK::DB::Classlist;
19 :     use WeBWorK::DB::WW;
20 :     use WeBWorK::PG::Translator;
21 : sh002i 492 use WeBWorK::Problem;
22 : sh002i 562 use WeBWorK::Utils qw(readFile formatDateTime writeTimingLogEntry);
23 : sh002i 414
24 : sh002i 424 sub new($$$$$$$$) {
25 : sh002i 415 my $invocant = shift;
26 :     my $class = ref($invocant) || $invocant;
27 : sh002i 424 my (
28 :     $courseEnv,
29 : sh002i 502 $user,
30 : sh002i 424 $key,
31 : sh002i 502 $set,
32 :     $problem,
33 :     $psvn,
34 :     $formFields, # in CGI::Vars format
35 : sh002i 424 $translationOptions, # hashref containing options for the
36 :     # translator, such as whether to show
37 :     # hints and the display mode to use
38 :     ) = @_;
39 : sh002i 415
40 : sh002i 562 # 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 :    
45 : sh002i 558 # install a local warn handler to collect warnings
46 :     my $warnings = "";
47 : sh002i 608 if ($courseEnv->{pg}->{options}->{catchWarnings}) {
48 :     local $SIG{__WARN__} = sub { $warnings .= shift };
49 :     }
50 : sh002i 414
51 :     # create a Translator
52 : sh002i 558 #warn "PG: creating a Translator\n";
53 : sh002i 414 my $translator = WeBWorK::PG::Translator->new;
54 :    
55 : sh002i 424 # set the directory hash
56 : sh002i 558 #warn "PG: setting the directory hash\n";
57 : sh002i 414 $translator->rh_directories({
58 :     courseScriptsDirectory => $courseEnv->{webworkDirs}->{macros},
59 :     macroDirectory => $courseEnv->{courseDirs}->{macros},
60 :     templateDirectory => $courseEnv->{courseDirs}->{templates},
61 :     tempDirectory => $courseEnv->{courseDirs}->{html_temp},
62 :     });
63 :    
64 : sh002i 424 # evaluate modules and "extra packages"
65 : sh002i 558 #warn "PG: evaluating modules and \"extra packages\"\n";
66 : sh002i 424 my @modules = @{ $courseEnv->{pg}->{modules} };
67 : sh002i 476 foreach my $module_packages_ref (@modules) {
68 :     my ($module, @extra_packages) = @$module_packages_ref;
69 :     # the first item is the main package
70 :     $translator->evaluate_modules($module);
71 : sh002i 424 # the remaining items are "extra" packages
72 : sh002i 476 $translator->load_extra_packages(@extra_packages);
73 : sh002i 414 }
74 :    
75 : sh002i 424 # set the environment (from defineProblemEnvir)
76 : sh002i 558 #warn "PG: setting the environment (from defineProblemEnvir)\n";
77 : sh002i 555 my $envir = defineProblemEnvir(
78 : sh002i 502 $courseEnv,
79 :     $user,
80 :     $key,
81 :     $set,
82 :     $problem,
83 :     $psvn,
84 :     $formFields,
85 :     $translationOptions,
86 : sh002i 555 );
87 :     $translator->environment($envir);
88 : sh002i 414
89 : sh002i 424 # initialize the Translator
90 : sh002i 558 #warn "PG: initializing the Translator\n";
91 : sh002i 414 $translator->initialize();
92 :    
93 : sh002i 424 # load PG.pl and dangerousMacros.pl using unrestricted_load
94 : sh002i 425 # 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 : sh002i 558 #warn "PG: loading PG.pl and dangerousMacros.pl using unrestricted_load\n";
97 : sh002i 414 my $pg_pl = $courseEnv->{webworkDirs}->{macros} . "/PG.pl";
98 : sh002i 424 my $dangerousMacros_pl = $courseEnv->{webworkDirs}->{macros} . "/dangerousMacros.pl";
99 : sh002i 562 my $io_pl = $courseEnv->{webworkDirs}->{macros} . "/IO.pl";
100 : sh002i 414 my $err = $translator->unrestricted_load($pg_pl);
101 :     warn "Error while loading $pg_pl: $err" if $err;
102 :     $err = $translator->unrestricted_load($dangerousMacros_pl);
103 :     warn "Error while loading $dangerousMacros_pl: $err" if $err;
104 : sh002i 562 $err = $translator->unrestricted_load($io_pl);
105 :     warn "Error while loading $io_pl: $err" if $err;
106 : sh002i 414
107 : sh002i 424 # set the opcode mask (using default values)
108 : sh002i 558 #warn "PG: setting the opcode mask (using default values)\n";
109 : sh002i 414 $translator->set_mask();
110 :    
111 : sh002i 424 # store the problem source
112 : sh002i 558 #warn "PG: storing the problem source\n";
113 : sh002i 492 my $sourceFile = $problem->source_file;
114 :     $sourceFile = $courseEnv->{courseDirs}->{templates}."/".$sourceFile
115 :     unless ($sourceFile =~ /^\//);
116 : sh002i 526 eval { $translator->source_string(readFile($sourceFile)) };
117 :     if ($@) {
118 :     # well, we couldn't get the problem source, for some reason.
119 :     return bless {
120 :     translator => $translator,
121 :     head_text => "",
122 :     body_text => <<EOF,
123 :     WeBWorK::Utils::readFile($sourceFile) says:
124 :     $@
125 :     EOF
126 :     answers => {},
127 :     result => {},
128 :     state => {},
129 :     errors => "Failed to read the problem source file.",
130 : sh002i 558 warnings => $warnings,
131 : sh002i 526 flags => {error_flag => 1},
132 :     }, $class;
133 :     }
134 : sh002i 414
135 :     # install a safety filter (&safetyFilter)
136 : sh002i 558 #warn "PG: installing a safety filter\n";
137 : sh002i 414 $translator->rf_safety_filter(\&safetyFilter);
138 :    
139 : sh002i 415 # translate the PG source into text
140 : sh002i 558 #warn "PG: translating the PG source into text\n";
141 : sh002i 415 $translator->translate();
142 :    
143 : sh002i 555 # after we're done translating, we may have to clean up after the translator.
144 :     # for example, 'images' mode uses a tempdir for dvipng's temp files. We have
145 :     # to remove it.
146 :     if ($translationOptions->{displayMode} eq 'images' && $envir->{dvipngTempDir}) {
147 : sh002i 558 rmtree($envir->{dvipngTempDir}, 0, 0);
148 : sh002i 555 }
149 :    
150 : sh002i 476 my ($result, $state); # we'll need these on the other side of the if block!
151 :     if ($translationOptions->{processAnswers}) {
152 :    
153 :     # process student answers
154 : sh002i 558 #warn "PG: processing student answers\n";
155 : sh002i 476 $translator->process_answers($formFields);
156 :    
157 :     # retrieve the problem state and give it to the translator
158 : sh002i 558 #warn "PG: retrieving the problem state and giving it to the translator\n";
159 : sh002i 476 $translator->rh_problem_state({
160 :     recorded_score => $problem->status,
161 :     num_of_correct_ans => $problem->num_correct,
162 :     num_of_incorrect_ans => $problem->num_incorrect,
163 :     });
164 :    
165 :     # determine an entry order -- the ANSWER_ENTRY_ORDER flag is built by
166 :     # the PG macro package (PG.pl)
167 : sh002i 558 #warn "PG: determining an entry order\n";
168 : sh002i 476 my @answerOrder =
169 :     $translator->rh_flags->{ANSWER_ENTRY_ORDER}
170 :     ? @{ $translator->rh_flags->{ANSWER_ENTRY_ORDER} }
171 :     : keys %{ $translator->rh_evaluated_answers };
172 :    
173 :     # install a grader -- use the one specified in the problem,
174 :     # or fall back on the default from the course environment.
175 :     # (two magic strings are accepted, to avoid having to
176 :     # reference code when it would be difficult.)
177 : sh002i 558 #warn "PG: installing a grader\n";
178 : sh002i 476 my $grader = $translator->rh_flags->{PROBLEM_GRADER_TO_USE}
179 :     || $courseEnv->{pg}->{options}->{grader};
180 :     $grader = $translator->rf_std_problem_grader
181 :     if $grader eq "std_problem_grader";
182 :     $grader = $translator->rf_avg_problem_grader
183 :     if $grader eq "avg_problem_grader";
184 :     die "Problem grader $grader is not a CODE reference."
185 :     unless ref $grader eq "CODE";
186 :     $translator->rf_problem_grader($grader);
187 :    
188 :     # grade the problem
189 : sh002i 558 #warn "PG: grading the problem\n";
190 : sh002i 476 ($result, $state) = $translator->grade_problem(
191 :     answers_submitted => $translationOptions->{processAnswers},
192 :     ANSWER_ENTRY_ORDER => \@answerOrder,
193 :     );
194 :    
195 :     }
196 : sh002i 415
197 : sh002i 562 # write timing log entry
198 :     writeTimingLogEntry($courseEnv, "WeBWorK::PG::new", "", "end");
199 :    
200 : sh002i 424 # return an object which contains the translator and the results of
201 :     # the translation process. this is DIFFERENT from the "format expected
202 :     # by Webwork.pm (and I believe processProblem8, but check.)"
203 :     return bless {
204 :     translator => $translator,
205 :     head_text => ${ $translator->r_header },
206 :     body_text => ${ $translator->r_text },
207 :     answers => $translator->rh_evaluated_answers,
208 :     result => $result,
209 :     state => $state,
210 : sh002i 558 errors => $translator->errors,
211 :     warnings => $warnings,
212 : sh002i 424 flags => $translator->rh_flags,
213 :     }, $class;
214 : sh002i 414 }
215 :    
216 :     # -----
217 :    
218 : sh002i 424 sub defineProblemEnvir($$$$$$$) {
219 :     my (
220 :     $courseEnv,
221 :     $user,
222 :     $key,
223 :     $set,
224 :     $problem,
225 :     $psvn,
226 :     $formFields,
227 :     $options,
228 :     ) = @_;
229 : sh002i 414
230 :     my %envir;
231 :    
232 :     # PG environment variables
233 :     # from docs/pglanguage/pgreference/environmentvariables as of 06/25/2002
234 :     # any changes are noted by "ADDED:" or "REMOVED:"
235 :    
236 :     # Vital state information
237 : sh002i 476 # ADDED: displayHintsQ, displaySolutionsQ, refreshMath2img
238 : sh002i 414
239 :     $envir{psvn} = $psvn;
240 :     $envir{psvnNumber} = $envir{psvn};
241 :     $envir{probNum} = $problem->id;
242 :     $envir{questionNumber} = $envir{probNum};
243 :     $envir{fileName} = $problem->source_file;
244 :     $envir{probFileName} = $envir{fileName};
245 :     $envir{problemSeed} = $problem->problem_seed;
246 : sh002i 424 $envir{displayMode} = translateDisplayModeNames($options->{displayMode});
247 : sh002i 414 $envir{languageMode} = $envir{displayMode};
248 :     $envir{outputMode} = $envir{displayMode};
249 : sh002i 424 $envir{displayHintsQ} = $options->{hints};
250 :     $envir{displaySolutionsQ} = $options->{solutions};
251 : sh002i 434 $envir{refreshMath2img} = $options->{refreshMath2img};
252 : sh002i 414
253 :     # Problem Information
254 :     # ADDED: courseName
255 :    
256 :     $envir{openDate} = $set->open_date;
257 : sh002i 424 $envir{formattedOpenDate} = formatDateTime($envir{openDate});
258 : sh002i 414 $envir{dueDate} = $set->due_date;
259 : sh002i 424 $envir{formattedDueDate} = formatDateTime($envir{dueDate});
260 : sh002i 414 $envir{answerDate} = $set->answer_date;
261 : sh002i 424 $envir{formattedAnswerDate} = formatDateTime($envir{answerDate});
262 : sh002i 607 $envir{numOfAttempts} = ($problem->num_correct || 0) + ($problem->num_incorrect || 0);
263 : sh002i 414 $envir{problemValue} = $problem->value;
264 : sh002i 424 $envir{sessionKey} = $key;
265 : sh002i 414 $envir{courseName} = $courseEnv->{courseName};
266 :    
267 :     # Student Information
268 :     # ADDED: studentID
269 :    
270 :     $envir{sectionName} = $user->section;
271 :     $envir{sectionNumber} = $envir{sectionName};
272 :     $envir{recitationName} = $user->recitation;
273 :     $envir{recitationNumber} = $envir{recitationName};
274 :     $envir{setNumber} = $set->id;
275 :     $envir{studentLogin} = $user->id;
276 :     $envir{studentName} = $user->first_name . " " . $user->last_name;
277 : sh002i 424 $envir{studentID} = $user->student_id;
278 : sh002i 414
279 :     # Answer Information
280 : sh002i 434 # REMOVED: refSubmittedAnswers
281 : sh002i 414
282 : sh002i 434 $envir{inputs_ref} = $formFields;
283 : sh002i 414
284 : sh002i 433 # External Programs
285 : sh002i 562 # ADDED: externalLaTeXPath, externalDvipngPath,
286 :     # externalGif2EpsPath, externalPng2EpsPath
287 : sh002i 434
288 : sh002i 433 $envir{externalTTHPath} = $courseEnv->{externalPrograms}->{tth};
289 : sh002i 526 $envir{externalLaTeXPath} = $courseEnv->{externalPrograms}->{latex};
290 :     $envir{externalDvipngPath} = $courseEnv->{externalPrograms}->{dvipng};
291 : sh002i 562 $envir{externalGif2EpsPath} = $courseEnv->{externalPrograms}->{gif2eps};
292 :     $envir{externalPng2EpsPath} = $courseEnv->{externalPrograms}->{png2eps};
293 : sh002i 414
294 :     # Directories and URLs
295 :     # REMOVED: courseName
296 : sh002i 526 # ADDED: dvipngTempDir
297 : sh002i 414
298 : sh002i 526
299 : sh002i 414 $envir{cgiDirectory} = undef;
300 :     $envir{cgiURL} = undef;
301 :     $envir{classDirectory} = undef;
302 : sh002i 424 $envir{courseScriptsDirectory} = $courseEnv->{webworkDirs}->{macros}."/";
303 :     $envir{htmlDirectory} = $courseEnv->{courseDirs}->{html}."/";
304 : sh002i 562 $envir{htmlURL} = $courseEnv->{courseURLs}->{html}."/";
305 : sh002i 424 $envir{macroDirectory} = $courseEnv->{courseDirs}->{macros}."/";
306 :     $envir{templateDirectory} = $courseEnv->{courseDirs}->{templates}."/";
307 :     $envir{tempDirectory} = $courseEnv->{courseDirs}->{html_temp}."/";
308 : sh002i 562 $envir{tempURL} = $courseEnv->{courseURLs}->{html_temp}."/";
309 : sh002i 414 $envir{scriptDirectory} = undef;
310 : sh002i 562 $envir{webworkDocsURL} = $courseEnv->{webworkURLs}->{docs}."/";
311 : sh002i 555 $envir{dvipngTempDir} = $options->{displayMode} eq 'images'
312 : sh002i 558 ? tempdir("webwork-dvipng-XXXXXXXX", DIR => $envir{tempDirectory})
313 : sh002i 555 : undef;
314 : sh002i 414
315 : sh002i 433 # Default values for evaluating answers
316 : sh002i 425
317 : sh002i 433 my $ansEvalDefaults = $courseEnv->{pg}->{ansEvalDefaults};
318 :     $envir{$_} = $ansEvalDefaults->{$_} foreach (keys %$ansEvalDefaults);
319 :    
320 :     # Other things...
321 :    
322 : sh002i 425 $envir{PROBLEM_GRADER_TO_USE} = $courseEnv->{pg}->{options}->{grader};
323 :    
324 : sh002i 414 return \%envir;
325 :     }
326 :    
327 : sh002i 424 sub translateDisplayModeNames($) {
328 :     my $name = shift;
329 :     return {
330 : sh002i 476 tex => "TeX",
331 : sh002i 424 plainText => "HTML",
332 :     formattedText => "HTML_tth",
333 : sh002i 433 images => "HTML_img"
334 : sh002i 424 }->{$name};
335 :     }
336 :    
337 : sh002i 414 sub safetyFilter {
338 : sh002i 415 my $answer = shift; # accepts one answer and checks it
339 : sh002i 414 my $submittedAnswer = $answer;
340 :     $answer = '' unless defined $answer;
341 :     my ($errorno);
342 :     $answer =~ tr/\000-\037/ /;
343 :     # Return if answer field is empty
344 :     unless ($answer =~ /\S/) {
345 :     #$errorno = "<BR>No answer was submitted.";
346 :     $errorno = 0; ## don't report blank answer as error
347 :     return ($answer,$errorno);
348 :     }
349 :     # replace ^ with ** (for exponentiation)
350 :     # $answer =~ s/\^/**/g;
351 :     # Return if forbidden characters are found
352 :     unless ($answer =~ /^[a-zA-Z0-9_\-\+ \t\/@%\*\.\n^\(\)]+$/ ) {
353 :     $answer =~ tr/a-zA-Z0-9_\-\+ \t\/@%\*\.\n^\(\)/#/c;
354 :     $errorno = "<BR>There are forbidden characters in your answer: $submittedAnswer<BR>";
355 :     return ($answer,$errorno);
356 :     }
357 :     $errorno = 0;
358 :     return($answer, $errorno);
359 :     }
360 :    
361 :     1;
362 : sh002i 440
363 :     __END__
364 :    
365 :     =head1 SYNOPSIS
366 :    
367 :     $pg = WeBWorK::PG->new(
368 : sh002i 502 $courseEnv, # a WeBWorK::CourseEnvironment object
369 :     $user, # a WeBWorK::User object
370 : sh002i 440 $sessionKey,
371 : sh002i 502 $set, # a WeBWorK::Set object
372 :     $problem, # a WeBWorK::Problem object
373 :     $psvn,
374 :     $formFields # in &WeBWorK::Form::Vars format
375 : sh002i 440 { # translation options
376 :     displayMode => "images", # (plainText|formattedText|images)
377 :     showHints => 1, # (0|1)
378 :     showSolutions => 0, # (0|1)
379 :     refreshMath2img => 0, # (0|1)
380 :     processAnswers => 1, # (0|1)
381 :     },
382 :     );
383 :    
384 :     $translator = $pg->{translator}; # WeBWorK::PG::Translator
385 :     $body = $pg->{body_text}; # text string
386 :     $header = $pg->{head_text}; # text string
387 :     $answerHash = $pg->{answers}; # WeBWorK::PG::AnswerHash
388 :     $result = $pg->{result}; # hash reference
389 :     $state = $pg->{state}; # hash reference
390 :     $errors = $pg->{errors}; # text string
391 :     $warnings = $pg->{warnings}; # text string
392 :     $flags = $pg->{flags}; # hash reference
393 :    
394 :     =head1 DESCRIPTION
395 :    
396 :     WeBWorK::PG encapsulates the PG translation process, making multiple calls to
397 :     WeBWorK::PG::Translator. Much of the flexibility of the Translator is hidden,
398 :     instead making choices that are appropriate for the webwork-modperl system.
399 :    
400 :     =head1 CONSTRUCTION
401 :    
402 :     =over
403 :    
404 : sh002i 502 =item new (ENVIRONMENT, USER, KEY, SET, PROBLEM, PSVN, FIELDS, OPTIONS)
405 : sh002i 440
406 :     The C<new> method creates a translator, initializes it using the parameters
407 :     specified, translates a PG file, and processes answers. It returns a reference
408 :     to a blessed hash containing the results of the translation process.
409 :    
410 :     =back
411 :    
412 :     =head2 Parameters
413 :    
414 :     =over
415 :    
416 :     =item ENVIRONMENT
417 :    
418 :     a WeBWorK::CourseEnvironment object
419 :    
420 :     =item USER
421 :    
422 : sh002i 502 a WeBWorK::User object
423 : sh002i 440
424 :     =item KEY
425 :    
426 :     the session key of the current session
427 :    
428 :     =item SET
429 :    
430 : sh002i 502 a WeBWorK::Set object
431 : sh002i 440
432 :     =item PROBLEM
433 :    
434 : sh002i 526 a WeBWorK::Problem object. The contents of the source_file field can specify a
435 :     PG file either by absolute path or path relative to the "templates" directory.
436 :     I<The caller should remove taint from this value before passing!>
437 : sh002i 440
438 : sh002i 502 =item PSVN
439 :    
440 :     the problem set version number
441 :    
442 :     =item FIELDS
443 :    
444 :     a reference to a hash (as returned by &WeBWorK::Form::Vars) containing form
445 :     fields submitted by a problem processor. The translator will look for fields
446 :     like "AnSwEr[0-9]" containing submitted student answers.
447 :    
448 : sh002i 440 =item OPTIONS
449 :    
450 :     a reference to a hash containing the following data:
451 :    
452 :     =over
453 :    
454 :     =item displayMode
455 :    
456 :     one of "plainText", "formattedText", or "images"
457 :    
458 :     =item showHints
459 :    
460 :     boolean, render hints
461 :    
462 :     =item showSolutions
463 :    
464 :     boolean, render solutions
465 :    
466 :     =item refreshMath2img
467 :    
468 :     boolean, force images created by math2img (in "images" mode) to be recreated,
469 :     even if the PG source has not been updated.
470 :    
471 :     =item processAnswers
472 :    
473 :     boolean, call answer evaluators and graders
474 :    
475 :     =back
476 :    
477 :     =back
478 :    
479 :     =head2 RETURN VALUE
480 :    
481 :     The C<new> method returns a blessed hash reference containing the following
482 :     fields. More information can be found in the documentation for
483 :     WeBWorK::PG::Translator.
484 :    
485 :     =over
486 :    
487 :     =item translator
488 :    
489 :     The WeBWorK::PG::Translator object used to render the problem.
490 :    
491 :     =item head_text
492 :    
493 :     HTML code for the E<lt>headE<gt> block of an resulting web page. Used for
494 :     JavaScript features.
495 :    
496 :     =item body_text
497 :    
498 :     HTML code for the E<lt>bodyE<gt> block of an resulting web page.
499 :    
500 :     =item answers
501 :    
502 :     An C<AnswerHash> object containing submitted answers, and results of answer
503 :     evaluation.
504 :    
505 :     =item result
506 :    
507 :     A hash containing the results of grading the problem.
508 :    
509 :     =item state
510 :    
511 :     A hash containing the new problem state.
512 :    
513 :     =item errors
514 :    
515 :     A string containing any errors encountered while rendering the problem.
516 :    
517 :     =item warnings
518 :    
519 :     A string containing any warnings encountered while rendering the problem.
520 :    
521 :     =item flags
522 :    
523 :     A hash containing PG_flags (see the Translator docs).
524 :    
525 :     =back
526 :    
527 :     =head1 OPERATION
528 :    
529 :     WeBWorK::PG goes through the following operations when constructed:
530 :    
531 :     =over
532 :    
533 :     =item Get database information
534 :    
535 :     Retrieve information about the current user, set, and problem from the
536 :     database.
537 :    
538 :     =item Create a translator
539 :    
540 :     Instantiate a WeBWorK::PG::Translator object.
541 :    
542 :     =item Set the directory hash
543 :    
544 :     Set the translator's directory hash (courseScripts, macros, templates, and temp
545 :     directories) from the course environment.
546 :    
547 :     =item Evaluate PG modules
548 :    
549 :     Using the module list from the course environment (pg->modules), perform a
550 :     "use"-like operation to evaluate modules at runtime.
551 :    
552 :     =item Set the problem environment
553 :    
554 :     Use data from the user, set, and problem, as well as the course environemnt and
555 :     translation options, to set the problem environment.
556 :    
557 :     =item Initialize the translator
558 :    
559 :     Call &WeBWorK::PG::Translator::initialize. What more do you want?
560 :    
561 :     =item Load PG.pl and dangerousMacros.pl
562 :    
563 :     These macros must be loaded without opcode masking, so they are loaded here.
564 :    
565 :     =item Set the opcode mask
566 :    
567 :     Set the opcode mask to the default specified by WeBWorK::PG::Translator.
568 :    
569 :     =item Load the problem source
570 :    
571 :     Give the problem source to the translator.
572 :    
573 :     =item Install a safety filter
574 :    
575 :     The safety filter is used to preprocess student input before evaluation. The
576 :     default safety filter, &WeBWorK::PG::safetyFilter, is used.
577 :    
578 :     =item Translate the problem source
579 :    
580 :     Call &WeBWorK::PG::Translator::translate to render the problem source into the
581 :     format given by the display mode.
582 :    
583 :     =item Process student answers
584 :    
585 :     Use form field inputs to evaluate student answers.
586 :    
587 :     =item Load the problem state
588 :    
589 :     Use values from the database to initialize the problem state, so that the
590 :     grader will have a point of reference.
591 :    
592 :     =item Determine an entry order
593 :    
594 :     Use the ANSWER_ENTRY_ORDER flag to determine the order of answers in the
595 :     problem. This is important for problems with dependancies among parts.
596 :    
597 :     =item Install a grader
598 :    
599 :     Use the PROBLEM_GRADER_TO_USE flag, or a default from the course environment,
600 :     to install a grader.
601 :    
602 :     =item Grade the problem
603 :    
604 :     Use the selected grader to grade the problem.
605 :    
606 :     =back
607 :    
608 :     =head1 AUTHOR
609 :    
610 :     Written by Sam Hathaway, sh002i (at) math.rochester.edu.
611 :    
612 :     =cut

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9