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

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm

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

Revision 746 Revision 747
100 my %want = ( 100 my %want = (
101 showOldAnswers => $r->param("showOldAnswers") || $courseEnv->{pg}->{options}->{showOldAnswers}, 101 showOldAnswers => $r->param("showOldAnswers") || $courseEnv->{pg}->{options}->{showOldAnswers},
102 showCorrectAnswers => $r->param("showCorrectAnswers") || $courseEnv->{pg}->{options}->{showCorrectAnswers}, 102 showCorrectAnswers => $r->param("showCorrectAnswers") || $courseEnv->{pg}->{options}->{showCorrectAnswers},
103 showHints => $r->param("showHints") || $courseEnv->{pg}->{options}->{showHints}, 103 showHints => $r->param("showHints") || $courseEnv->{pg}->{options}->{showHints},
104 showSolutions => $r->param("showSolutions") || $courseEnv->{pg}->{options}->{showSolutions}, 104 showSolutions => $r->param("showSolutions") || $courseEnv->{pg}->{options}->{showSolutions},
105 #recordAnswers => $r->param("recordAnswers") || 1,
106 recordAnswers => $submitAnswers, 105 recordAnswers => $submitAnswers,
106 checkAnswers => $checkAnswers,
107 ); 107 );
108 108
109 # are certain options enforced? 109 # are certain options enforced?
110 my %must = ( 110 my %must = (
111 showOldAnswers => 0, 111 showOldAnswers => 0,
112 showCorrectAnswers => 0, 112 showCorrectAnswers => 0,
113 showHints => 0, 113 showHints => 0,
114 showSolutions => 0, 114 showSolutions => 0,
115 recordAnswers => mustRecordAnswers($permissionLevel), 115 recordAnswers => mustRecordAnswers($permissionLevel),
116 checkAnswers => 0,
116 ); 117 );
117 118
118 # does the user have permission to use certain options? 119 # does the user have permission to use certain options?
119 my %can = ( 120 my %can = (
120 showOldAnswers => 1, 121 showOldAnswers => 1,
121 showCorrectAnswers => canShowCorrectAnswers($permissionLevel, $set->answer_date), 122 showCorrectAnswers => canShowCorrectAnswers($permissionLevel, $set->answer_date),
122 showHints => 1, 123 showHints => 1,
123 showSolutions => canShowSolutions($permissionLevel, $set->answer_date), 124 showSolutions => canShowSolutions($permissionLevel, $set->answer_date),
125 # attempts=num_correct+num_incorrect+1, as this happens before updating $problem
124 recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date, 126 recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date,
125 $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1), 127 $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1),
126 # num_correct+num_incorrect+1 -- as this happens before updating $problem 128 checkAnswers => canCheckAnswers($permissionLevel, $set->open_date,
129 $set->due_date, $set->answer_date, $problem->max_attempts,
130 $problem->num_correct + $problem->num_incorrect + 1),
127 ); 131 );
128 132
129 # final values for options 133 # final values for options
130 my %will; 134 my %will;
131 foreach (keys %must) { 135 foreach (keys %must) {
400 CGI::p( 404 CGI::p(
401 ($can{recordAnswers} 405 ($can{recordAnswers}
402 ? CGI::submit(-name=>"submitAnswers", 406 ? CGI::submit(-name=>"submitAnswers",
403 -label=>"Submit Answers") 407 -label=>"Submit Answers")
404 : ""), 408 : ""),
405 ($can{recordAnswers} 409 ($can{checkAnswers}
406 ? CGI::submit(-name=>"checkAnswers", 410 ? CGI::submit(-name=>"checkAnswers",
407 -label=>"Check Answers") 411 -label=>"Check Answers")
408 : ""), 412 : ""),
409 CGI::submit(-name=>"previewAnswers", 413 CGI::submit(-name=>"previewAnswers",
410 -label=>"Preview Answers"), 414 -label=>"Preview Answers"),
437 if ($pg->{warnings} ne "") { 441 if ($pg->{warnings} ne "") {
438 print CGI::hr(), $self->warningOutput($pg->{warnings}); 442 print CGI::hr(), $self->warningOutput($pg->{warnings});
439 } 443 }
440 444
441 # debugging stuff 445 # debugging stuff
442 if (1) { 446 if (0) {
443 print 447 print
444 CGI::hr(), 448 CGI::hr(),
445 CGI::h2("debugging information"), 449 CGI::h2("debugging information"),
446 CGI::h3("form fields"), 450 CGI::h3("form fields"),
447 ref2string($self->{formFields}), 451 ref2string($self->{formFields}),
650 my $attemptsOK = $maxAttempts == -1 || $attempts <= $maxAttempts; 654 my $attemptsOK = $maxAttempts == -1 || $attempts <= $maxAttempts;
651 my $recordAnswers = $permHigh || ($timeOK && $attemptsOK); 655 my $recordAnswers = $permHigh || ($timeOK && $attemptsOK);
652 return $recordAnswers; 656 return $recordAnswers;
653} 657}
654 658
659sub canCheckAnswers($$$$$) {
660 my ($permissionLevel, $openDate, $dueDate, $answerDate, $maxAttempts, $attempts) = @_;
661 return time >= $answerDate or canRecordAnswers($permissionLevel, $openDate, $dueDate, $maxAttempts, $attempts);
662}
663
655sub mustRecordAnswers($) { 664sub mustRecordAnswers($) {
656 my ($permissionLevel) = @_; 665 my ($permissionLevel) = @_;
657 return $permissionLevel == 0; 666 return $permissionLevel == 0;
658} 667}
659 668

Legend:
Removed from v.746  
changed lines
  Added in v.747

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9