| 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: webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.140 2004/06/02 20:27:22 toenail Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.141 2004/06/04 21:40:07 jj 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. |
| … | |
… | |
| 252 | showHints => 1, |
252 | showHints => 1, |
| 253 | showSolutions => canShowSolutions($permissionLevel, $set->answer_date), |
253 | showSolutions => canShowSolutions($permissionLevel, $set->answer_date), |
| 254 | recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date, |
254 | recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date, |
| 255 | $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1), |
255 | $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1), |
| 256 | # attempts=num_correct+num_incorrect+1, as this happens before updating $problem |
256 | # attempts=num_correct+num_incorrect+1, as this happens before updating $problem |
| 257 | checkAnswers => canCheckAnswers($permissionLevel, $set->answer_date), |
257 | checkAnswers => canCheckAnswers($permissionLevel, $set->due_date), |
| 258 | ); |
258 | ); |
| 259 | |
259 | |
| 260 | # more complicated logic for showing check answer button: |
260 | # more complicated logic for showing check answer button: |
| 261 | # checkAnswers button shows up after due date -- once a student can't record anymore |
261 | # checkAnswers button shows up after due date -- once a student can't record anymore |
| 262 | # checkAnswers button always shows up when an instructor or TA is acting |
262 | # checkAnswers button always shows up when an instructor or TA is acting |
| … | |
… | |
| 1144 | my $recordAnswers = $permHigh || ($timeOK && $attemptsOK); |
1144 | my $recordAnswers = $permHigh || ($timeOK && $attemptsOK); |
| 1145 | return $recordAnswers; |
1145 | return $recordAnswers; |
| 1146 | } |
1146 | } |
| 1147 | |
1147 | |
| 1148 | sub canCheckAnswers($$) { |
1148 | sub canCheckAnswers($$) { |
| 1149 | my ($permissionLevel, $answerDate) = @_; |
1149 | my ($permissionLevel, $dueDate) = @_; |
| 1150 | my $permHigh = $permissionLevel > 0; |
1150 | my $permHigh = $permissionLevel > 0; |
| 1151 | my $timeOK = time >= $answerDate; |
1151 | my $timeOK = time >= $dueDate; |
| 1152 | my $recordAnswers = $permHigh || $timeOK; |
1152 | my $recordAnswers = $permHigh || $timeOK; |
| 1153 | return $recordAnswers; |
1153 | return $recordAnswers; |
| 1154 | } |
1154 | } |
| 1155 | |
1155 | |
| 1156 | sub mustRecordAnswers($) { |
1156 | sub mustRecordAnswers($) { |