Skip to content

Commit 91647a8

Browse files
committed
Fix grading proctored tests that require proctor authorization to do so.
The `can_recordAnswers` method of the `WeBWorK::ContentGenerator::GatewayQuiz` package can not call any of the `WeBWorK::ContentGenerator::GatewayQuiz` methods because it is called directly by the `WeBWorK::ContentGenerator::LoginProctor` module without a `WeBWorK::ContentGenerator::GatewayQuiz` object. Attempting to do so will cause an exception. This is a bit annoying as the conditions of the `can_gradeUnsubmittedTest` method (including the conditions of the `can_showProblemGrader` method it calls) must be directly used by the `can_recordAnswers` method. There is no way around that though. This definitely should be considered for a hotfix.
1 parent 0b1fa1c commit 91647a8

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/WeBWorK/ContentGenerator/GatewayQuiz.pm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ sub can_showSolutions ($c, $user, $permissionLevel, $effectiveUser, $set, $probl
118118
# Allow for a version_last_attempt_time which is the time the set was submitted. If that is present we use that instead
119119
# of the current time to decide if answers can be recorded. This deals with the time between the submission time and
120120
# the proctor authorization.
121+
# IMPORTANT: This method is called directly by the LoginProctor.pm package without a proper GatewayQuiz object, and so
122+
# it can not call any of the object methods in the GatewayQuiz package or use anything that is not set for a generic
123+
# ContentGenerator object.
121124
sub can_recordAnswers ($c, $user, $permissionLevel, $effectiveUser, $set, $problem, $tmplSet = 0, $submitAnswers = 0) {
122125
my $authz = $c->authz;
123126

@@ -130,8 +133,12 @@ sub can_recordAnswers ($c, $user, $permissionLevel, $effectiveUser, $set, $probl
130133
# allow that between the open and close dates, and so drop out of this conditional to the usual one.
131134
return 1
132135
if $authz->hasPermissions($user->user_id, 'record_answers_when_acting_as_student')
133-
|| $c->can_gradeUnsubmittedTest($user, $permissionLevel, $effectiveUser, $set, $problem, $tmplSet,
134-
$submitAnswers);
136+
|| (!$submitAnswers
137+
&& $authz->hasPermissions($user->user_id, 'access_instructor_tools')
138+
&& $authz->hasPermissions($user->user_id, 'problem_grader')
139+
&& !$c->{invalidSet}
140+
&& after($set->due_date + $c->ce->{gatewayGracePeriod})
141+
&& !$set->version_last_attempt_time);
135142
return 0 if !$authz->hasPermissions($user->user_id, 'record_set_version_answers_when_acting_as_student');
136143
}
137144

0 commit comments

Comments
 (0)