Skip to content

Commit 7367f11

Browse files
committed
remove non_native table check from new course add features
1 parent 4d80939 commit 7367f11

File tree

1 file changed

+24
-36
lines changed

1 file changed

+24
-36
lines changed

lib/WeBWorK/Utils/CourseManagement.pm

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,10 @@ sub addCourse {
336336
if ($db0 && $options{copyNonStudents}) {
337337
my @non_student_ids =
338338
map {@$_} ($db0->listPermissionLevelsWhere({ permission => { not_like => '0' } }, 'user_id'));
339-
my %original_users = map { $_->[0]{user_id} => 1 } (@users);
339+
my %user_args = map { $_->[0]{user_id} => 1 } (@users);
340340

341341
for my $user_id (@non_student_ids) {
342-
next if $original_users{$user_id};
342+
next if $user_args{$user_id};
343343
my @User = $db0->getUsersWhere({ user_id => $user_id });
344344
my @Password = $db0->getPasswordsWhere({ user_id => $user_id });
345345
my @PermissionLevel = $db0->getPermissionLevelsWhere({ user_id => $user_id });
@@ -360,54 +360,42 @@ sub addCourse {
360360

361361
# add sets
362362
if ($db0 && $options{copySets}) {
363-
if ($ce->{dbLayouts}{$dbLayoutName}{set}{params}{non_native}) {
364-
debug("not adding sets to the course database: 'set' table is non-native.\n");
365-
} else {
366-
my @set_ids = $db0->listGlobalSets;
367-
for my $set_id (@set_ids) {
368-
eval { $db->addGlobalSet($db0->getGlobalSet($set_id)) };
369-
warn $@ if $@;
363+
my @set_ids = $db0->listGlobalSets;
364+
for my $set_id (@set_ids) {
365+
eval { $db->addGlobalSet($db0->getGlobalSet($set_id)) };
366+
warn $@ if $@;
370367

371-
my @Problem = $db0->getGlobalProblemsWhere({ set_id => $set_id });
372-
for my $problem (@Problem) {
373-
eval { $db->addGlobalProblem($problem) };
374-
warn $@ if $@;
375-
}
368+
my @Problem = $db0->getGlobalProblemsWhere({ set_id => $set_id });
369+
for my $problem (@Problem) {
370+
eval { $db->addGlobalProblem($problem) };
371+
warn $@ if $@;
372+
}
376373

377-
my @Location = $db0->getGlobalSetLocationsWhere({ set_id => $set_id });
378-
for my $location (@Location) {
379-
eval { $db->addGlobalSetLocation($location) };
380-
warn $@ if $@;
381-
}
374+
my @Location = $db0->getGlobalSetLocationsWhere({ set_id => $set_id });
375+
for my $location (@Location) {
376+
eval { $db->addGlobalSetLocation($location) };
377+
warn $@ if $@;
382378
}
383379
}
384380
}
385381

386382
# add achievements
387383
if ($db0 && $options{copyAchievements}) {
388-
if ($ce->{dbLayouts}{$dbLayoutName}{achievement}{params}{non_native}) {
389-
debug("not adding achievements to the course database: 'achievement' table is non-native.\n");
390-
} else {
391-
my @achievement_ids = $db0->listAchievements;
392-
for my $achievement_id (@achievement_ids) {
393-
eval { $db->addAchievement($db0->getAchievement($achievement_id)) };
394-
warn $@ if $@;
395-
}
384+
my @achievement_ids = $db0->listAchievements;
385+
for my $achievement_id (@achievement_ids) {
386+
eval { $db->addAchievement($db0->getAchievement($achievement_id)) };
387+
warn $@ if $@;
396388
}
397389
}
398390

399391
# copy title and/or institution if requested
400-
if ($db0 && ($options{copyTitle} || $options{copyInstitution})) {
401-
if ($ce->{dbLayouts}{$dbLayoutName}{setting}{params}{non_native}) {
402-
debug("not copying settings to the course database: 'setting' table is non-native.\n");
392+
for my $setting ('Title', 'Institution') {
393+
if ($db0 && $options{"copy$setting"}) {
394+
$db->setSettingValue("course$setting", $db0->getSettingValue("course$setting"))
395+
if ($options{"copy$setting"});
403396
} else {
404-
$db->setSettingValue('courseTitle', $db0->getSettingValue('courseTitle')) if ($options{copyTitle});
405-
$db->setSettingValue('courseInstitution', $db0->getSettingValue('{courseInstitution'))
406-
if ($options{copyInstitution});
397+
$db->setSettingValue("course$setting", $options{"course$setting"}) if (exists $options{"course$setting"});
407398
}
408-
} else {
409-
$db->setSettingValue('courseTitle', $options{courseTitle}) if (exists $options{courseTitle});
410-
$db->setSettingValue('courseInstitution', $options{courseInstitution}) if (exists $options{courseInstitution});
411399
}
412400

413401
##### step 4: write course.conf file #####

0 commit comments

Comments
 (0)