| … | |
… | |
| 96 | # num_correct+num_incorrect+1 -- as this happens before updating $problem |
96 | # num_correct+num_incorrect+1 -- as this happens before updating $problem |
| 97 | ); |
97 | ); |
| 98 | |
98 | |
| 99 | # final values for options |
99 | # final values for options |
| 100 | my %will; |
100 | my %will; |
| 101 | foreach(keys %must) { |
101 | foreach (keys %must) { |
| 102 | $will{$_} = $can{$_} && ($want{$_} || $must{$_}); |
102 | $will{$_} = $can{$_} && ($want{$_} || $must{$_}); |
|
|
103 | #warn "$_: can? $can{$_} want? $want{$_} must? $must{$_} will? $will{$_}\n"; |
| 103 | } |
104 | } |
| 104 | |
105 | |
| 105 | ##### sticky answers ##### |
106 | ##### sticky answers ##### |
| 106 | |
107 | |
| 107 | if (not $submitAnswers and $will{showOldAnswers}) { |
108 | if (not $submitAnswers and $will{showOldAnswers}) { |
| … | |
… | |
| 536 | |
537 | |
| 537 | sub canRecordAnswers($$$$$) { |
538 | sub canRecordAnswers($$$$$) { |
| 538 | my ($permissionLevel, $openDate, $dueDate, $maxAttempts, $attempts) = @_; |
539 | my ($permissionLevel, $openDate, $dueDate, $maxAttempts, $attempts) = @_; |
| 539 | my $permHigh = $permissionLevel > 0; |
540 | my $permHigh = $permissionLevel > 0; |
| 540 | my $timeOK = time >= $openDate && time <= $dueDate; |
541 | my $timeOK = time >= $openDate && time <= $dueDate; |
| 541 | my $attemptsOK = $attempts <= $maxAttempts; |
542 | my $attemptsOK = $maxAttempts == -1 || $attempts <= $maxAttempts; |
| 542 | return $permHigh || ($timeOK && $attemptsOK); |
543 | my $recordAnswers = $permHigh || ($timeOK && $attemptsOK); |
|
|
544 | return $recordAnswers; |
| 543 | } |
545 | } |
| 544 | |
546 | |
| 545 | sub mustRecordAnswers($) { |
547 | sub mustRecordAnswers($) { |
| 546 | my ($permissionLevel) = @_; |
548 | my ($permissionLevel) = @_; |
| 547 | return $permissionLevel == 0; |
549 | return $permissionLevel == 0; |