Skip to content

Commit

Permalink
Hotfix: Prevent error when adding new course.
Browse files Browse the repository at this point in the history
When adding a new course if the initial instructor entered into
the add course form has the same user ID as a user in the course
non-student users, sets, and achievements are being copied from,
this user gets assigned to sets and achievements twice, causing
an error.

This skips assigning the initial user to the original sets they
may have been assigned to and will always assign the initial user
to all sets and achievements, so no error occurs.
  • Loading branch information
somiaj committed Nov 14, 2024
1 parent c37af2b commit e183ba6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/WeBWorK/Utils/CourseManagement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ sub addCourse {
}
if ($options{copyNonStudents}) {
foreach my $userTriple (@users) {
my $user_id = $userTriple->[0]{user_id};
my $user_id = $userTriple->[0]{user_id};
next if $user_id eq $initialUser->[0]{user_id}; # Skip, will be assigned to all sets below.
my @user_sets = $db0->listUserSets($user_id);
assignSetsToUsers($db, $ce, \@user_sets, [$user_id]);
}
Expand All @@ -425,7 +426,8 @@ sub addCourse {
}
if ($options{copyNonStudents}) {
foreach my $userTriple (@users) {
my $user_id = $userTriple->[0]{user_id};
my $user_id = $userTriple->[0]{user_id};
next if $user_id eq $initialUser->[0]{user_id}; # Skip, was assigned to all achievements above.
my @user_achievements = $db0->listUserAchievements($user_id);
for my $achievement_id (@user_achievements) {
my $userAchievement = $db->newUserAchievement();
Expand Down

0 comments on commit e183ba6

Please sign in to comment.