| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader$ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.109 2003/12/09 01:12:31 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 33 | use WeBWorK::PG::IO; |
33 | use WeBWorK::PG::IO; |
| 34 | use WeBWorK::Utils qw(writeLog writeCourseLog encodeAnswers decodeAnswers ref2string makeTempDirectory); |
34 | use WeBWorK::Utils qw(writeLog writeCourseLog encodeAnswers decodeAnswers ref2string makeTempDirectory); |
| 35 | use WeBWorK::DB::Utils qw(global2user user2global findDefaults); |
35 | use WeBWorK::DB::Utils qw(global2user user2global findDefaults); |
| 36 | use WeBWorK::Timing; |
36 | use WeBWorK::Timing; |
| 37 | |
37 | |
| 38 | my $timer0_ON=0; # times pg translation phase |
|
|
| 39 | |
38 | |
| 40 | ############################################################ |
39 | ############################################################ |
| 41 | # |
40 | # |
| 42 | # user |
41 | # user |
| 43 | # effectiveUser |
42 | # effectiveUser |
| … | |
… | |
| 276 | $formFields->{$_} = $oldAnswers{$_} foreach keys %oldAnswers; |
275 | $formFields->{$_} = $oldAnswers{$_} foreach keys %oldAnswers; |
| 277 | } |
276 | } |
| 278 | |
277 | |
| 279 | ##### translation ##### |
278 | ##### translation ##### |
| 280 | |
279 | |
| 281 | $WeBWorK::timer0->continue("begin pg processing") if $timer0_ON; |
280 | $WeBWorK::timer->continue("begin pg processing") if defined($WeBWorK::timer); |
| 282 | my $pg = WeBWorK::PG->new( |
281 | my $pg = WeBWorK::PG->new( |
| 283 | $courseEnv, |
282 | $courseEnv, |
| 284 | $effectiveUser, |
283 | $effectiveUser, |
| 285 | $key, |
284 | $key, |
| 286 | $set, |
285 | $set, |
| … | |
… | |
| 294 | refreshMath2img => $will{showHints} || $will{showSolutions}, |
293 | refreshMath2img => $will{showHints} || $will{showSolutions}, |
| 295 | processAnswers => 1, |
294 | processAnswers => 1, |
| 296 | }, |
295 | }, |
| 297 | ); |
296 | ); |
| 298 | |
297 | |
| 299 | $WeBWorK::timer0->continue("end pg processing") if $timer0_ON; |
298 | $WeBWorK::timer->continue("end pg processing") if defined($WeBWorK::timer); |
| 300 | ##### fix hint/solution options ##### |
299 | ##### fix hint/solution options ##### |
| 301 | |
300 | |
| 302 | $can{showHints} &&= $pg->{flags}->{hintExists} |
301 | $can{showHints} &&= $pg->{flags}->{hintExists} |
| 303 | &&= $pg->{flags}->{showHintLimit}<=$pg->{state}->{num_of_incorrect_ans}; |
302 | &&= $pg->{flags}->{showHintLimit}<=$pg->{state}->{num_of_incorrect_ans}; |
| 304 | $can{showSolutions} &&= $pg->{flags}->{solutionExists}; |
303 | $can{showSolutions} &&= $pg->{flags}->{solutionExists}; |
| … | |
… | |
| 381 | |
380 | |
| 382 | return ""; |
381 | return ""; |
| 383 | } |
382 | } |
| 384 | |
383 | |
| 385 | sub nav { |
384 | sub nav { |
| 386 | $WeBWorK::timer0->continue("begin nav subroutine") if $timer0_ON; |
385 | $WeBWorK::timer->continue("begin nav subroutine") if defined($WeBWorK::timer); |
| 387 | my $self = shift; |
386 | my $self = shift; |
| 388 | my $args = $_[-1]; |
387 | my $args = $_[-1]; |
| 389 | my $setName = $self->{set}->set_id; |
388 | my $setName = $self->{set}->set_id; |
| 390 | my $problemNumber = $self->{problem}->problem_id; |
389 | my $problemNumber = $self->{problem}->problem_id; |
| 391 | |
390 | |
| … | |
… | |
| 414 | push @links, "Next Problem" , ($nextID |
413 | push @links, "Next Problem" , ($nextID |
| 415 | ? "$root/$courseName/$setName/".$nextID |
414 | ? "$root/$courseName/$setName/".$nextID |
| 416 | : "") , "navNext"; |
415 | : "") , "navNext"; |
| 417 | |
416 | |
| 418 | my $result = $self->navMacro($args, $tail, @links); |
417 | my $result = $self->navMacro($args, $tail, @links); |
| 419 | $WeBWorK::timer0->continue("end nav subroutine") if $timer0_ON; |
418 | $WeBWorK::timer->continue("end nav subroutine") if defined($WeBWorK::timer); |
| 420 | return $result; |
419 | return $result; |
| 421 | } |
420 | } |
| 422 | |
421 | |
| 423 | sub title { |
422 | sub title { |
| 424 | my $self = shift; |
423 | my $self = shift; |
| … | |
… | |
| 468 | if ($pg->{flags}->{error_flag}) { |
467 | if ($pg->{flags}->{error_flag}) { |
| 469 | return $self->errorOutput($pg->{errors}, $pg->{body_text}.CGI::p($editorLinkMessage)); |
468 | return $self->errorOutput($pg->{errors}, $pg->{body_text}.CGI::p($editorLinkMessage)); |
| 470 | } |
469 | } |
| 471 | |
470 | |
| 472 | ##### answer processing ##### |
471 | ##### answer processing ##### |
| 473 | $WeBWorK::timer0->continue("begin answer processing") if $timer0_ON; |
472 | $WeBWorK::timer->continue("begin answer processing") if defined($WeBWorK::timer); |
| 474 | # if answers were submitted: |
473 | # if answers were submitted: |
| 475 | my $scoreRecordedMessage; |
474 | my $scoreRecordedMessage; |
| 476 | if ($submitAnswers) { |
475 | if ($submitAnswers) { |
| 477 | # get a "pure" (unmerged) UserProblem to modify |
476 | # get a "pure" (unmerged) UserProblem to modify |
| 478 | # this will be undefined if the problem has not been assigned to this user |
477 | # this will be undefined if the problem has not been assigned to this user |
| … | |
… | |
| 564 | ); |
563 | ); |
| 565 | |
564 | |
| 566 | } |
565 | } |
| 567 | } |
566 | } |
| 568 | |
567 | |
| 569 | $WeBWorK::timer0->continue("end answer processing") if $timer0_ON; |
568 | $WeBWorK::timer->continue("end answer processing") if defined($WeBWorK::timer); |
| 570 | |
569 | |
| 571 | ##### output ##### |
570 | ##### output ##### |
| 572 | |
571 | |
| 573 | print CGI::start_div({class=>"problemHeader"}); |
572 | print CGI::start_div({class=>"problemHeader"}); |
| 574 | |
573 | |