From 5cf018660e18da952fadb12281aca8839385601e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 12 Nov 2026 16:48:49 -0600 Subject: [PATCH] Allow entering a timed out proctored test version without a proctor. A proctored test version was only considered complete if at least one submission had been recorded. So if a student never submitted a version and it timed out, the student needed proctor authorization to enter it again. Now a version that has timed out is complete whether or not it was ever submitted, so the student can enter it without a proctor. Answers still can not be submitted for the version. With the develop branch if a student takes a test version but never submits it and the test times out, then if the student attempts to reenter the test after the grace period has ended, the student must enter (or have entered) the proctor password to get in. Before #3240, a student also had to have the proctor password entered; however, once that were done the test was converted into an unproctored test, and from then on the student could enter the test without the proctor. With this change the student can directly enter the timed out test. Co-Authored-By: Claude Opus 5.5 --- lib/WeBWorK/Utils/Sets.pm | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/WeBWorK/Utils/Sets.pm b/lib/WeBWorK/Utils/Sets.pm index 228350fd43..cdccee8f58 100644 --- a/lib/WeBWorK/Utils/Sets.pm +++ b/lib/WeBWorK/Utils/Sets.pm @@ -292,11 +292,17 @@ sub restricted_set_message($c, $set, $status) { } sub test_version_is_complete ($c, $setVersion, $problem = undef) { - return 0 unless $setVersion->version_last_attempt_time; - my $authz = $c->authz; my $userID = $setVersion->user_id; + # A version that has timed out is complete regardless of whether it was ever submitted. + if (after($setVersion->due_date + $c->ce->{gatewayGracePeriod})) { + return !$authz->hasPermissions($userID, + after($setVersion->answer_date) ? 'record_answers_after_answer_date' : 'record_answers_after_due_date'); + } + + return 0 unless $setVersion->version_last_attempt_time; + # All problems in a test version have the same number of attempts, so the attempts for the first problem are used. # This is determined in a closure so that the database queries are only made if this information is needed below. my $attemptsUsed = sub { @@ -309,13 +315,6 @@ sub test_version_is_complete ($c, $setVersion, $problem = undef) { return ($problem->num_correct // 0) + ($problem->num_incorrect // 0); }; - if (after($setVersion->due_date + $c->ce->{gatewayGracePeriod})) { - return 0 - if $authz->hasPermissions($userID, - after($setVersion->answer_date) ? 'record_answers_after_answer_date' : 'record_answers_after_due_date'); - return $attemptsUsed->() > 0; - } - my $attemptsPerVersion = $setVersion->attempts_per_version || 0; my $canRecordWithAttempts = $authz->hasPermissions($userID, 'record_answers_after_open_date_with_attempts'); my $canRecordWithoutAttempts = @@ -433,22 +432,22 @@ check for lis_source_did when using homework grade passback. Usage: C -Returns true if at least one submission has been recorded for the test version -C<$setVersion> (a merged set version), and the user the version belongs to can -no longer record answers for it, either because all attempts for the version -have been used or because time has expired. This is determined from the -permissions of that user in the same way that it is determined when the test is -submitted. +Returns true if the user the test version C<$setVersion> (a merged set version) +belongs to can no longer record answers for it. That is the case if time has +expired for the version, whether or not it was ever submitted, or if at least +one submission has been recorded and all attempts for the version have been +used. This is determined from the permissions of that user in the same way that +it is determined when the test is submitted. The optional C<$problem> should be a problem version from C<$setVersion>. If it is given, then the number of recorded attempts is taken from it. Otherwise the first problem of the version is obtained from the database to find the number of -recorded attempts. +recorded attempts if needed. This is used to determine if a proctored test version can be viewed without proctor authorization. Since this is determined from the current data for the version, a version that is complete is no longer complete if more attempts are allowed or its close date is extended, and then proctor authorization is -required again. A version with no recorded submissions is never complete. +required again. =cut