From e34631cbe1cf1096bf282cb64115e35078174741 Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Tue, 17 Dec 2024 15:24:20 -0800 Subject: [PATCH] more efficient database accessing Co-authored-by: Glenn Rice <47527406+drgrice1@users.noreply.github.com> --- lib/WeBWorK/AchievementItems/ExtendDueDate.pm | 4 +--- lib/WeBWorK/AchievementItems/ReducedCred.pm | 4 +--- lib/WeBWorK/AchievementItems/SuperExtendDueDate.pm | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/WeBWorK/AchievementItems/ExtendDueDate.pm b/lib/WeBWorK/AchievementItems/ExtendDueDate.pm index ecc5816b0e..f645c59734 100644 --- a/lib/WeBWorK/AchievementItems/ExtendDueDate.pm +++ b/lib/WeBWorK/AchievementItems/ExtendDueDate.pm @@ -79,9 +79,7 @@ sub use_item ($self, $userName, $c) { # Change the seed for all of the problems if the set is currently closed. if (after($set->due_date)) { - my @probIDs = $db->listUserProblems($userName, $setID); - for my $probID (@probIDs) { - my $problem = $db->getUserProblem($userName, $setID, $probID); + for my $problem ($db->getUserProblemsWhere({ user_id => $userName, set_id => $setID })) { $problem->problem_seed($problem->problem_seed % 2**31 + 1); $db->putUserProblem($problem); } diff --git a/lib/WeBWorK/AchievementItems/ReducedCred.pm b/lib/WeBWorK/AchievementItems/ReducedCred.pm index 23a8ff0dc2..297c275d7e 100644 --- a/lib/WeBWorK/AchievementItems/ReducedCred.pm +++ b/lib/WeBWorK/AchievementItems/ReducedCred.pm @@ -85,9 +85,7 @@ sub use_item ($self, $userName, $c) { # Change the seed for all of the problems if the set is currently closed. if (after($set->due_date)) { - my @probIDs = $db->listUserProblems($userName, $setID); - for my $probID (@probIDs) { - my $problem = $db->getUserProblem($userName, $setID, $probID); + for my $problem ($db->getUserProblemsWhere({ user_id => $userName, set_id => $setID })) { $problem->problem_seed($problem->problem_seed % 2**31 + 1); $db->putUserProblem($problem); } diff --git a/lib/WeBWorK/AchievementItems/SuperExtendDueDate.pm b/lib/WeBWorK/AchievementItems/SuperExtendDueDate.pm index eb9cf88da1..ccf960321d 100644 --- a/lib/WeBWorK/AchievementItems/SuperExtendDueDate.pm +++ b/lib/WeBWorK/AchievementItems/SuperExtendDueDate.pm @@ -79,9 +79,7 @@ sub use_item ($self, $userName, $c) { # Change the seed for all of the problems if the set is currently closed. if (after($set->due_date)) { - my @probIDs = $db->listUserProblems($userName, $setID); - for my $probID (@probIDs) { - my $problem = $db->getUserProblem($userName, $setID, $probID); + for my $problem ($db->getUserProblemsWhere({ user_id => $userName, set_id => $setID })) { $problem->problem_seed($problem->problem_seed % 2**31 + 1); $db->putUserProblem($problem); }