--- loncom/interface/loncreatecourse.pm 2020/05/22 19:57:57 1.158.2.6
+++ loncom/interface/loncreatecourse.pm 2021/08/31 17:23:27 1.176
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.158.2.6 2020/05/22 19:57:57 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.176 2021/08/31 17:23:27 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -80,7 +80,6 @@ use Apache::loncommon;
use Apache::londocs;
use Apache::lonlocal;
use Apache::lonuserutils;
-use Apache::lonclonecourse;
use LONCAPA::batchcreatecourse;
use LONCAPA qw(:DEFAULT :match);
@@ -95,6 +94,8 @@ sub print_course_creation_page {
my $crstype = 'Community';
if ($env{'form.phase'} eq 'courseone') {
$crstype = 'Course';
+ } elsif ($env{'form.phase'} eq 'placementone') {
+ $crstype = 'Placement';
}
my $defdom=$env{'request.role.domain'};
my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom);
@@ -108,7 +109,8 @@ sub print_course_creation_page {
$course_home .= qq{>$server $host_servers{$server}};
}
$course_home .= "\n\n";
- my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
+ my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
+ my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain',undef,undef,undef,$trusted,$untrusted);
my $cloneform=&Apache::loncommon::select_dom_form
($env{'request.role.domain'},'clonedomain').
&Apache::loncommon::selectcourse_link
@@ -122,7 +124,7 @@ sub print_course_creation_page {
$endtime,'create_defaultdates');
my $openallfrom =
&Apache::lonhtmlcommon::date_setter('ccrs','openallfrom',$starttime);
- if ($crstype eq 'Course') {
+ if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
$enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
$endtime,'create_enrolldates');
($krbdef,$krbdefdom) =
@@ -189,6 +191,10 @@ function validate(formname) {
'ncd' => "Do not clone date parameters",
'prd' => 'Clone date parameters as-is',
'shd' => 'Shift date parameters by number of days',
+ 'dpl' => 'URL shortcuts (for deep linking)',
+ 'nsl' => 'Do not clone URL shortcuts',
+ 'tsl' => 'Transfer URL shortcuts from existing course to new course',
+ 'csl' => 'Create new URL shortcuts in new course',
'assp' => "Assessment Parameters",
'oaas' => "Open all assessments",
'sta' => "starting from:",
@@ -222,6 +228,7 @@ function validate(formname) {
'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
'opco' => 'Open Course',
'opcm' => 'Open Community',
+ 'oppt' => 'Open Placement Test',
);
$lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than course','','');
$lt{'toin'} = &mt('to interface with institutional data, e.g., [_1]fs13glg231[_2] for [_3]Fall 2013 Geology 231[_4]','','','','');
@@ -253,6 +260,20 @@ function validate(formname) {
$lt{'cc'} = &mt('(will be assigned Coordinator role)');
$lt{'cgrs'} = &mt('Community Group Settings');
$lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files');
+ $lt{'tsl'} = &mt('Transfer URL shortcuts from existing community to new community');
+ $lt{'csl'} = &mt('Create new URL shortcuts in new community');
+ } elsif ($crstype eq 'Placement') {
+ $lt{'cinf'} = &mt('Placement Test Information');
+ $lt{'ctit'} = &mt('Placement Test Title');
+ $lt{'chsr'} = &mt('Placement Test Home Server');
+ $lt{'cidn'} = &mt('Placement Test ID/Number');
+ $lt{'crco'} = &mt('Placement Test Content');
+ $lt{'cncr'} = &mt('Completely new placement test');
+ $lt{'cecr'} = &mt('Clone an existing placement test');
+ $lt{'sacr'} = &mt('Do NOT generate as standard placement test');
+ $lt{'stco'} = &mt('standard placement tests only');
+ $lt{'navi'} = &mt('Placement Test Contents');
+ $lt{'cid'} = &mt('Placement Test ID');
}
my $js = <
@@ -285,6 +306,7 @@ END
my %titles = &Apache::lonlocal::texthash(
courseone => 'Create a New Course',
groupone => 'Create a New Community',
+ placementone=> 'Create a New Placement Test',
);
my $start_page =
&Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
@@ -329,14 +351,16 @@ END
.''
.&Apache::lonhtmlcommon::row_closure()
);
- if ($crstype eq 'Course') {
+ if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
$r->print(&Apache::lonhtmlcommon::row_headline()
.'
'.$lt{'iinf'}.'
'
- .$lt{'stat'}.' '
- .&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]; textbook courses: [_3]).',
- $domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'},$domdefaults{'textbookcredits'})
- .&Apache::lonhtmlcommon::row_closure()
-
+ .$lt{'stat'});
+ if ($crstype eq 'Course') {
+ $r->print(' '
+ .&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]; textbook courses: [_3]).',
+ $domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'},$domdefaults{'textbookcredits'}));
+ }
+ $r->print(&Apache::lonhtmlcommon::row_closure()
.&Apache::lonhtmlcommon::row_title($lt{'ccod'})
.''
.' ('.$lt{'toin'}.')'
@@ -352,7 +376,8 @@ END
.' ('.$lt{'cscs'}.')'
.&Apache::lonhtmlcommon::row_closure()
);
- if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
+ if (($crstype eq 'Course') && ($domdefaults{'officialcredits'} ||
+ $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) {
$r->print(&Apache::lonhtmlcommon::row_title($lt{'ccre'})
.''
.' ('.$lt{'cred'}.')'
@@ -363,9 +388,13 @@ END
.''
.''.&mt('Yes').(' 'x2)
.''.&mt('No')
- .'
+ .''
.&Apache::lonhtmlcommon::row_closure()
- );
+ );
+ }
+ my $blankchk;
+ if ($crstype eq 'Placement') {
+ $blankchk = ' checked="checked"';
}
# Table: New Course / Clone Course
$r->print(&Apache::lonhtmlcommon::row_headline()
@@ -391,15 +420,14 @@ END
.&Apache::lonhtmlcommon::row_closure()
.&Apache::lonhtmlcommon::row_title($lt{'fres'})
.''
- .' ');
+ .''.$lt{'blnk'}
+ .'');
if ($crstype eq 'Community') {
- $r->print('
'
+ );
}
$r->print(''.
$end_page);
@@ -609,6 +657,8 @@ sub create_course {
$crstype='Course';
$enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
$enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
+ } elsif ($env{'form.phase'} eq 'placementtwo') {
+ $crstype='Placement';
}
$startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
$endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
@@ -653,6 +703,7 @@ sub create_course {
clonedomain => $env{'form.clonedomain'},
datemode => $env{'form.datemode'},
dateshift => $env{'form.dateshift'},
+ tinyurls => $env{'form.tinyurls'},
crsid => $env{'form.crsid'},
curruser => $env{'user.name'}.':'.$env{'user.domain'},
crssections => $env{'form.crssections'},
@@ -720,12 +771,20 @@ sub create_course {
return;
}
my ($courseid,$crsudom,$crsunum,$code);
- my ($success,$output) =
+ my ($success,$output,$clonemsgref) =
&Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
\$crsudom,\$crsunum,
$env{'user.domain'},
$env{'user.name'},'dc_create',undef,undef,\$code);
$r->print($output);
+ if (ref($clonemsgref) eq 'ARRAY') {
+ my $user_lh = &Apache::loncommon::user_lang($env{'user.name'},$env{'user.domain'});
+ foreach my $item (@{$clonemsgref}) {
+ if (ref($item) eq 'HASH') {
+ $r->print(&mt($item->{mt},@{$item->{args}}).' '."\n");
+ }
+ }
+ }
if ($success) {
#
# Make the requested user a course coordinator or group coordinator
@@ -763,7 +822,7 @@ sub create_course {
sub print_intro_page {
my ($r,$show_all_choices,$cancreate,$permission) = @_;
my $start_page =
- &Apache::loncommon::start_page('Create a New Course or Community');
+ &Apache::loncommon::start_page('Create a New Course, Community or Placement Test');
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
my $end_page =
&Apache::loncommon::end_page();
@@ -795,12 +854,20 @@ sub print_intro_page {
linktitle => 'Create a new collaborative community by completing an online form.'
},
{
- linktext => 'Create courses/communities by uploading an attributes file',
+ linktext => 'Create a single placement test',
+ url => '/adm/createcourse?phase=placementone',
+ permission => $permission->{'create'} && $cancreate->{'Placement'},
+ #help => '',
+ icon => 'crsnew.png',
+ linktitle => 'Create a new placement test by completing an online form.'
+ },
+ {
+ linktext => 'Create courses/communities/placement tests by uploading an attributes file',
url => '/adm/createcourse?phase=batchone',
permission => $permission->{'create'},
help => 'Batch_Creation',
icon => 'uplcrs.png',
- linktitle => 'Upload an attributes file containing specifications for one or more courses or communities in XML format.'
+ linktitle => 'Upload an attributes file containing specifications for one or more courses, communities or placement tests in XML format.'
},
]
},
@@ -812,7 +879,7 @@ sub print_intro_page {
permission => $show_all_choices,
#help => '',
icon => 'rcrs.png',
- linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'
+ linktitle => 'Display course, community creation and placement test requests submitted by authorized users, held pending approval by a Domain Coordinator.'
},
{
linktext => 'View pending official course requests',
@@ -833,7 +900,7 @@ sub print_intro_page {
permission => $show_all_choices,
#help => '',
icon => 'document-properties.png',
- linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.'
+ linktitle => 'Display information about when, how and by whom courses, communities and placement tests were created in this domain.'
},
]
},
@@ -850,18 +917,18 @@ sub print_intro_page {
sub upload_batchfile {
my $r = shift;
my $start_page =
- &Apache::loncommon::start_page('Create a New Course or Community');
- my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
+ &Apache::loncommon::start_page('Create a New Course, Community, or Placement Test');
+ my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community/Placement Test Attributes File','Create_Course',undef,'Create_Courses');
my $end_page =
&Apache::loncommon::end_page();
$r->print($start_page.$crumbs);
- $r->print('
'.&mt('Upload a courses or communities attributes file').'
');
+ $r->print('
'.&mt('Upload a courses, communities or placement tests attributes file').'
');
$r->print('');
+ 'value="'.&mt('Create Courses/Communities/Placement Tests').'" />');
$r->print($end_page);
return;
}
@@ -872,7 +939,7 @@ sub process_batchfile {
my $uname = $env{'user.name'};
my $udom = $env{'user.domain'};
my $dir = &LONCAPA::tempdir().'addcourse';
- my ($result,$logmsg,$keysmsg,$codesref,$instcodesref);
+ my ($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref);
if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) {
my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
'batchupload',undef,undef,
@@ -886,7 +953,7 @@ sub process_batchfile {
if ((defined($filename)) && (defined($batchdir))) {
my @requests = ($filename);
my %courseids = ();
- ($result,$logmsg,$keysmsg,$codesref,$instcodesref) =
+ ($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref) =
&LONCAPA::batchcreatecourse::create_courses(
\@requests,\%courseids,'web',$defdom,
$uname,$udom);
@@ -907,9 +974,11 @@ sub process_batchfile {
if ((ref($instcodesref) eq 'HASH') && (keys(%{$instcodesref}) > 0)) {
&Apache::lonnet::devalidate_cache_new('instcats',$defdom);
$updatecats = 1;
- }
+ }
®ister_cleanups($r,$defdom,$updatecats);
-
+ }
+ if ($clonemsg) {
+ $clonemsg = '