From daffef434cb3efd5fb79d61f69ccb4a32183db5c Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 6 May 2026 07:34:55 -0500 Subject: [PATCH] Make sure that a proctored test becomes unproctored when graded by instructor. When an instructor uses the "Grade Test for" button and the test is on its final submission, currently the grading occurs, but the test is still set as a proctored test. To fix this the condition that determines if the assignment type should be changed needs to check the `$can{recordAnswers}` value in the case that the `$userID` and `$effectiveUserID` are different. In that case `$can{recordAnswers}` is the result of the `can_recordAnswers` method which will be true if either the user has the `record_answers_when_acting_as_student` permission or the user can grade an unsubmitted test. This fixes issue #2962. The `GatewayQuiz.pm` module is really so convoluted at this point that it is really becoming impossible to do anything with, and is in desperate need of a complete overhaul and rewrite. Any time any new feature is added to the module or change is made to the module it is almost impossible to go through all of the possibilities and ensure you haven't broken something. --- lib/WeBWorK/ContentGenerator/GatewayQuiz.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm index f97712269f..c3a3324277 100644 --- a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -1248,7 +1248,7 @@ async sub pre_header_initialize ($c) { ($userID eq $effectiveUserID && !$can{recordAnswersNextTime}) || ( $userID ne $effectiveUserID - && $authz->hasPermissions($userID, 'record_answers_when_acting_as_student') + && $can{recordAnswers} && $set->attempts_per_version > 0 && ($problem->num_correct + $problem->num_incorrect + ($c->{submitAnswers} ? 1 : 0) >= $set->attempts_per_version)