Skip to content

Commit

Permalink
Stop adding a "contact" user to the admin course when creating a course.
Browse files Browse the repository at this point in the history
There is no need for this. These users are not used for anything and
have no real purpose.  Furthermore, the users are just clutter in the
admin course accounts manager.

There are also issues that can be caused by these users existing.  One
issue occurs if you create a course with an initial user, then delete
that course, then later create a course with the same course id but with
a different initial user.  Then if you delete the second course it dies
with the error "Incorrect number of contacts for the course courseID".
  • Loading branch information
drgrice1 committed Aug 16, 2024
1 parent 629f1c9 commit 4e972e9
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions lib/WeBWorK/ContentGenerator/CourseAdmin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -422,47 +422,6 @@ sub do_add_course ($c) {
$add_initial_email,
)
);
# Add contact to admin course as student?
# FIXME -- should we do this?
if ($add_initial_userID =~ /\S/) {
my $composite_id = "${add_initial_userID}_${add_courseID}"; # student id includes school name and contact
my $User = $db->newUser(
user_id => $composite_id, # student id includes school name and contact
first_name => $add_initial_firstName,
last_name => $add_initial_lastName,
student_id => $add_initial_userID,
email_address => $add_initial_email,
status => 'C',
);
my $Password = $db->newPassword(
user_id => $composite_id,
password => cryptPassword($add_initial_password),
);
my $PermissionLevel = $db->newPermissionLevel(
user_id => $composite_id,
permission => '0',
);
# add contact to admin course as student
# or if this contact and course already exist in a dropped status
# change the student's status to enrolled
if (my $oldUser = $db->getUser($composite_id)) {
push(
@$output,
$c->tag(
'div',
class => 'alert alert-danger p-1 mb-2',
$c->maketext('Replacing old data for [_1]: status: [_2]', $composite_id, $oldUser->status)
)
);
$db->deleteUser($composite_id);
}
eval { $db->addUser($User) };
warn $@ if $@;
eval { $db->addPassword($Password) };
warn $@ if $@;
eval { $db->addPermissionLevel($PermissionLevel) };
warn $@ if $@;
}
push(
@$output,
$c->tag(
Expand Down Expand Up @@ -885,19 +844,6 @@ sub do_delete_course ($c) {
$c->tag('div', class => 'font-monospace', $error))->join('')
);
} else {
# Mark the contact person in the admin course as dropped.
# Find the contact person for the course by searching the admin classlist.
my @contacts = grep {/_$delete_courseID$/} $db->listUsers;
if (@contacts) {
die "Incorrect number of contacts for the course $delete_courseID: " . join(' ', @contacts)
if @contacts != 1;

# Mark the contact person as dropped.
my $User = $db->getUser($contacts[0]);
$User->status(($ce->status_name_to_abbrevs('Drop'))[0]);
$db->putUser($User);
}

writeLog($ce, 'hosted_courses', join("\t", "\tDeleted", '', '', $delete_courseID));

return $c->c(
Expand Down Expand Up @@ -1117,21 +1063,6 @@ sub do_archive_course ($c) {
)
);
} else {
# Mark the contact person in the admin course as dropped.
# Find the contact person for the course by searching the admin classlist.
my @contacts = grep {/_$archive_courseID$/} $db->listUsers;
if (@contacts) {
die "Incorrect number of contacts for the course $archive_courseID" . join(' ', @contacts)
if @contacts != 1;
my $composite_id = $contacts[0];

my $User = $db->getUser($composite_id);
my $status_name = 'Drop';
my $status_value = ($ce->status_name_to_abbrevs($status_name))[0];
$User->status($status_value);
$db->putUser($User);
}

push(
@$output,
$c->tag(
Expand Down

0 comments on commit 4e972e9

Please sign in to comment.