From 78c73640af3f6533d1f4bef7142228348c622b15 Mon Sep 17 00:00:00 2001 From: Nathan Wallach <39089094+taniwallach@users.noreply.github.com> Date: Mon, 10 Apr 2023 22:05:03 +0300 Subject: [PATCH] Update lib/WeBWorK/DB.pm Corrections by @drgrice1 Co-authored-by: Glenn Rice <47527406+drgrice1@users.noreply.github.com> --- lib/WeBWorK/DB.pm | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/WeBWorK/DB.pm b/lib/WeBWorK/DB.pm index 1bd8498165..c8cdbcfc49 100644 --- a/lib/WeBWorK/DB.pm +++ b/lib/WeBWorK/DB.pm @@ -2137,28 +2137,18 @@ sub addUserProblem { sub addUserMultipleProblems { my ($self, @problemLists) = @_; - my $firstUserProblem = $problemLists[0][0]; - if (!defined($firstUserProblem) || !defined($firstUserProblem->user_id)) { - croak "Error in request to addUserMultipleProblems"; - } - my $user_id = $firstUserProblem->user_id; - my $set_id = $firstUserProblem->set_id; - - my ($nv_set_id, $versionNum) = grok_vsetID($set_id); - croak "addUserMultipleProblems does not support versioned sets" - if defined($versionNum); - - # Possible improvement, if a version set was sent, make calls to addUserProblem for each one. + croak "Error in request to addUserMultipleProblems" if ref($problemLists[0]) ne 'ARRAY'; # Do a single checkArgs call, all records in the list were made in the same manner - my @tmp = ($firstUserProblem); - $self->checkArgs(\@tmp, qw/VREC:problem_user/); + $self->checkArgs([ $problemLists[0][0] ], qw/REC:problem_user/); + + my $set_id = $problemLists[0][0]->set_id; # Array in which all records to add are collected - my @collectedProblemList = (); + my @collectedProblemList; for my $problemListRef (@problemLists) { - $user_id = $problemListRef->[0]->user_id; + my $user_id = $problemListRef->[0]->user_id; croak "addMultipleUserProblems: user set $set_id for user $user_id not found" unless $self->{set_user}->exists($user_id, $set_id);