Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when copying sets from a new course and adding an instructor, assign … #2513

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/WeBWorK/ContentGenerator/CourseAdmin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,11 @@ sub do_add_course ($c) {

eval {
addCourse(
courseID => $add_courseID,
ce => $ce2,
courseOptions => \%courseOptions,
users => \@users,
courseID => $add_courseID,
ce => $ce2,
courseOptions => \%courseOptions,
users => \@users,
initial_userID => $add_initial_userID,
%optional_arguments,
);
};
Expand Down
11 changes: 10 additions & 1 deletion lib/WeBWorK/Utils/CourseManagement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ boolean options:
=cut

sub addCourse {
my (%options) = @_;
my (%options) = (initial_userID => '', @_);

for my $key (keys(%options)) {
my $value = '####UNDEF###';
Expand All @@ -217,6 +217,8 @@ sub addCourse {

debug \@users;

my ($initialUser) = grep { $_->[0]{user_id} eq $options{initial_userID} } @users;

# get the database layout out of the options hash
my $dbLayoutName = $courseOptions{dbLayoutName};

Expand Down Expand Up @@ -405,6 +407,7 @@ sub addCourse {
assignSetsToUsers($db, $ce, \@user_sets, [$user_id]);
}
}
assignSetsToUsers($db, $ce, \@set_ids, [ $initialUser->[0]{user_id} ]) if $initialUser;
}

# add achievements
Expand All @@ -413,6 +416,12 @@ sub addCourse {
for my $achievement_id (@achievement_ids) {
eval { $db->addAchievement($db0->getAchievement($achievement_id)) };
warn $@ if $@;
if ($initialUser) {
my $userAchievement = $db->newUserAchievement();
$userAchievement->user_id($initialUser->[0]{user_id});
$userAchievement->achievement_id($achievement_id);
$db->addUserAchievement($userAchievement);
}
}
if ($options{copyNonStudents}) {
foreach my $userTriple (@users) {
Expand Down