Skip to content

Commit

Permalink
Merge pull request openwebwork#2290 from Alex-Jordan/copy-course
Browse files Browse the repository at this point in the history
be able to copy more things from a course when adding a new course
  • Loading branch information
drgrice1 authored Feb 12, 2024
2 parents c6ffeee + c6dbba5 commit 8cc8a86
Show file tree
Hide file tree
Showing 7 changed files with 309 additions and 124 deletions.
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 @@ -694,13 +694,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

0 comments on commit 8cc8a86

Please sign in to comment.