From 26946c793f8e4fa9d64974549ae09a1db4fcc1fb Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Fri, 8 Nov 2024 16:27:04 -0800 Subject: [PATCH] simplify check if gateway set has been attempted --- lib/WeBWorK/Utils/Sets.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/WeBWorK/Utils/Sets.pm b/lib/WeBWorK/Utils/Sets.pm index b4aa5d0c04..0ff5a346f5 100644 --- a/lib/WeBWorK/Utils/Sets.pm +++ b/lib/WeBWorK/Utils/Sets.pm @@ -157,13 +157,9 @@ sub gateway_attempted ($db, $setName, $studentName) { # if there is one version, check for an attempted problem if (@versionNums) { - my $versionedSet = $db->getSetVersion($studentName, $setName, $versionNums[0]); - - my @problemRecords = - $db->getAllMergedProblemVersions($studentName, $versionedSet->set_id, $versionedSet->version_id); - for my $problemRecord (@problemRecords) { - return 1 if $problemRecord->attempted; - } + my @problemNums = $db->listUserProblems($studentName, $setName); + my $problem = $db->getMergedProblemVersion($studentName, $setName, $versionNums[0], $problemNums[0]); + return defined $problem ? $problem->attempted : 0; } return 0;