| … | |
… | |
| 209 | recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date, |
209 | recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date, |
| 210 | $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1), |
210 | $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1), |
| 211 | # attempts=num_correct+num_incorrect+1, as this happens before updating $problem |
211 | # attempts=num_correct+num_incorrect+1, as this happens before updating $problem |
| 212 | checkAnswers => canCheckAnswers($permissionLevel, $set->answer_date), |
212 | checkAnswers => canCheckAnswers($permissionLevel, $set->answer_date), |
| 213 | ); |
213 | ); |
|
|
214 | ######################################################### |
| 214 | # more complicated logic for showing check answer button: |
215 | # more complicated logic for showing check answer button: |
|
|
216 | ######################################################### |
| 215 | # checkAnswers button shows up after due date -- once a student can't record anymore |
217 | # checkAnswers button shows up after due date -- once a student can't record anymore |
| 216 | # checkAnswers button always shows up when an instructor or TA is acting |
218 | # checkAnswers button always shows up when an instructor or TA is acting |
| 217 | # as someone else (the $user and $effectiveUserName aren't the same). |
219 | # as someone else (the $user and $effectiveUserName aren't the same). |
| 218 | $can{checkAnswers} = ($can{checkAnswers} && not $can{recordAnswers} ) || |
220 | $can{checkAnswers} = ($can{checkAnswers} && not $can{recordAnswers} ) || |
| 219 | ( $permissionLevel >= 5 and |
|
|
| 220 | defined($userName) and defined($effectiveUserName) and |
221 | ( defined($userName) and defined($effectiveUserName) and |
| 221 | ($userName ne $effectiveUserName) |
222 | ($userName ne $effectiveUserName) |
| 222 | ); |
223 | ); |
|
|
224 | ######################################################### |
|
|
225 | # more complicated logif for showing "submit answer" button |
|
|
226 | ######################################################### |
|
|
227 | # We hide the submit answer button if someone is acting as a student |
|
|
228 | # This prevents errors where you accidently submit the answer for a student |
|
|
229 | # Not sure whether this a feature or a bug |
|
|
230 | |
|
|
231 | $can{recordAnswers} = ($can{recordAnswers} and not |
|
|
232 | ( defined($userName) and defined($effectiveUserName) and |
|
|
233 | ($userName ne $effectiveUserName) |
|
|
234 | ) |
| 223 | |
235 | ); |
| 224 | |
|
|
| 225 | # final values for options |
236 | # final values for options |
| 226 | my %will; |
237 | my %will; |
| 227 | foreach (keys %must) { |
238 | foreach (keys %must) { |
| 228 | $will{$_} = $can{$_} && ($want{$_} || $must{$_}); |
239 | $will{$_} = $can{$_} && ($want{$_} || $must{$_}); |
| 229 | } |
240 | } |