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

be able to copy more things from a course when adding a new course #2290

Merged
merged 10 commits into from
Feb 12, 2024
5 changes: 3 additions & 2 deletions bin/addcourse
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ if ($users) {
}

my %optional_arguments;
if ($templates_from ne "") {
$optional_arguments{templatesFrom} = $templates_from;
if ($templates_from) {
$optional_arguments{copyFrom} = $templates_from;
$optional_arguments{copyTemplatesHtml} = 1;
}

eval {
Expand Down
14 changes: 9 additions & 5 deletions conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,17 @@ $courseFiles{logs}{activity_log} = '';
# Site defaults (Usually overridden in localOverrides.conf)
################################################################################

# The default_templates_course is used by default to create a new course.
# The contents of the templates directory are copied from this course
# to the new course being created.
$siteDefaults{default_templates_course} ="modelCourse";
# The default_copy_from_course is used by default when creating a new course.
# Its templates folder, html folder, course.conf file, and simple.conf file
# might be copied into a new course. This course might not be a true course;
# it might only have a directory structure and no presense in the database.
# If it is a real course, then also its title, institution, non-student users,
# achievements, and sets can be copied.
$siteDefaults{default_copy_from_course} ="modelCourse";

# Provide a list of model courses which are not real courses, but from which
# the templates for a new course can be copied.
# the templates for a new course can be copied. This list helps exclude such
# non-real courses when that is appopriate.
$modelCoursesForCopy = [ "modelCourse" ];

################################################################################
Expand Down
34 changes: 15 additions & 19 deletions lib/WeBWorK/ContentGenerator/CourseAdmin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,18 @@ sub do_add_course ($c) {
my $db = $c->db;
my $authz = $c->authz;

my $add_courseID = trim_spaces($c->param('new_courseID')) || '';
my $add_courseTitle = trim_spaces($c->param('add_courseTitle')) || '';
my $add_courseInstitution = trim_spaces($c->param('add_courseInstitution')) || '';
my $add_courseID = trim_spaces($c->param('new_courseID')) // '';
my $add_courseTitle = trim_spaces($c->param('add_courseTitle')) // '';
my $add_courseInstitution = trim_spaces($c->param('add_courseInstitution')) // '';

my $add_admin_users = trim_spaces($c->param('add_admin_users')) || '';
my $add_initial_userID = trim_spaces($c->param('add_initial_userID')) // '';
my $add_initial_password = trim_spaces($c->param('add_initial_password')) // '';
my $add_initial_confirmPassword = trim_spaces($c->param('add_initial_confirmPassword')) // '';
my $add_initial_firstName = trim_spaces($c->param('add_initial_firstName')) // '';
my $add_initial_lastName = trim_spaces($c->param('add_initial_lastName')) // '';
my $add_initial_email = trim_spaces($c->param('add_initial_email')) // '';

my $add_initial_userID = trim_spaces($c->param('add_initial_userID')) || '';
my $add_initial_password = trim_spaces($c->param('add_initial_password')) || '';
my $add_initial_confirmPassword = trim_spaces($c->param('add_initial_confirmPassword')) || '';
my $add_initial_firstName = trim_spaces($c->param('add_initial_firstName')) || '';
my $add_initial_lastName = trim_spaces($c->param('add_initial_lastName')) || '';
my $add_initial_email = trim_spaces($c->param('add_initial_email')) || '';

my $add_templates_course = trim_spaces($c->param('add_templates_course')) || '';
my $add_config_file = trim_spaces($c->param('add_config_file')) || '';
my $copy_from_course = trim_spaces($c->param('copy_from_course')) // '';

my $add_dbLayout = trim_spaces($c->param('add_dbLayout')) || '';

Expand All @@ -319,7 +316,7 @@ sub do_add_course ($c) {
my @users;

# copy users from current (admin) course if desired
if ($add_admin_users ne '') {
if ($c->param('add_admin_users')) {
for my $userID ($db->listUsers) {
if ($userID eq $add_initial_userID) {
$c->addbadmessage($c->maketext(
Expand Down Expand Up @@ -365,11 +362,10 @@ sub do_add_course ($c) {

# Include any optional arguments, including a template course and the course title and course institution.
my %optional_arguments;
if ($add_templates_course ne '') {
$optional_arguments{templatesFrom} = $add_templates_course;
}
if ($add_config_file ne '') {
$optional_arguments{copySimpleConfig} = $add_config_file;
if ($copy_from_course ne '') {
%optional_arguments = map { $_ => 1 } $c->param('copy_component');
$optional_arguments{copyFrom} = $copy_from_course;
$optional_arguments{copyConfig} = $c->param('copy_config_file');
}
if ($add_courseTitle ne '') {
$optional_arguments{courseTitle} = $add_courseTitle;
Expand Down
Loading
Loading