Skip to content

Commit c18608b

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

File tree

1 file changed

+24
-37
lines changed

1 file changed

+24
-37
lines changed

lib/WeBWorK/Utils/CourseManagement.pm

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ sub listArchivedCourses {
162162
copyTitle => boolean
163163
copyInstitution => boolean
164164
165-
166165
Create a new course with ID $courseID.
167166
168167
$ce is a WeBWorK::CourseEnvironment object that describes the new course's
@@ -336,10 +335,10 @@ sub addCourse {
336335
if ($db0 && $options{copyNonStudents}) {
337336
my @non_student_ids =
338337
map {@$_} ($db0->listPermissionLevelsWhere({ permission => { not_like => '0' } }, 'user_id'));
339-
my %original_users = map { $_->[0]{user_id} => 1 } (@users);
338+
my %user_args = map { $_->[0]{user_id} => 1 } (@users);
340339

341340
for my $user_id (@non_student_ids) {
342-
next if $original_users{$user_id};
341+
next if $user_args{$user_id};
343342
my @User = $db0->getUsersWhere({ user_id => $user_id });
344343
my @Password = $db0->getPasswordsWhere({ user_id => $user_id });
345344
my @PermissionLevel = $db0->getPermissionLevelsWhere({ user_id => $user_id });
@@ -360,54 +359,42 @@ sub addCourse {
360359

361360
# add sets
362361
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 $@;
362+
my @set_ids = $db0->listGlobalSets;
363+
for my $set_id (@set_ids) {
364+
eval { $db->addGlobalSet($db0->getGlobalSet($set_id)) };
365+
warn $@ if $@;
370366

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

377-
my @Location = $db0->getGlobalSetLocationsWhere({ set_id => $set_id });
378-
for my $location (@Location) {
379-
eval { $db->addGlobalSetLocation($location) };
380-
warn $@ if $@;
381-
}
373+
my @Location = $db0->getGlobalSetLocationsWhere({ set_id => $set_id });
374+
for my $location (@Location) {
375+
eval { $db->addGlobalSetLocation($location) };
376+
warn $@ if $@;
382377
}
383378
}
384379
}
385380

386381
# add achievements
387382
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-
}
383+
my @achievement_ids = $db0->listAchievements;
384+
for my $achievement_id (@achievement_ids) {
385+
eval { $db->addAchievement($db0->getAchievement($achievement_id)) };
386+
warn $@ if $@;
396387
}
397388
}
398389

399390
# 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");
391+
for my $setting ('Title', 'Institution') {
392+
if ($db0 && $options{"copy$setting"}) {
393+
$db->setSettingValue("course$setting", $db0->getSettingValue("course$setting"))
394+
if ($options{"copy$setting"});
403395
} else {
404-
$db->setSettingValue('courseTitle', $db0->getSettingValue('courseTitle')) if ($options{copyTitle});
405-
$db->setSettingValue('courseInstitution', $db0->getSettingValue('{courseInstitution'))
406-
if ($options{copyInstitution});
396+
$db->setSettingValue("course$setting", $options{"course$setting"}) if (exists $options{"course$setting"});
407397
}
408-
} else {
409-
$db->setSettingValue('courseTitle', $options{courseTitle}) if (exists $options{courseTitle});
410-
$db->setSettingValue('courseInstitution', $options{courseInstitution}) if (exists $options{courseInstitution});
411398
}
412399

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

0 commit comments

Comments
 (0)