--- loncom/interface/loncreatecourse.pm 2017/11/17 01:02:28 1.158.2.3.2.2 +++ loncom/interface/loncreatecourse.pm 2020/07/17 23:28:21 1.158.2.3.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network # Create a course # -# $Id: loncreatecourse.pm,v 1.158.2.3.2.2 2017/11/17 01:02:28 raeburn Exp $ +# $Id: loncreatecourse.pm,v 1.158.2.3.2.3 2020/07/17 23:28:21 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); @@ -183,6 +182,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", 'mssg' => "Messaging", @@ -246,6 +249,8 @@ 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'); } my $js = < @@ -395,6 +400,7 @@ END .''.$lt{'navi'} .''); } + my $tinyurlhelp=&Apache::loncommon::help_open_topic('Clone_Tiny_URLs'); $r->print('
('.$lt{'stco'}.')' .&Apache::lonhtmlcommon::row_closure(1) .&Apache::lonhtmlcommon::end_pick_box() @@ -426,6 +432,17 @@ END .'' .' ' .&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title($tinyurlhelp.$lt{'dpl'}) + .'
' + .'
' + .'' + .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_headline() .''.$lt{'asov'}.'' .&Apache::lonhtmlcommon::row_closure(1) @@ -636,6 +653,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'}, @@ -702,12 +720,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 @@ -852,7 +878,7 @@ sub process_batchfile { my $uname = $env{'user.name'}; my $udom = $env{'user.domain'}; my $dir = &LONCAPA::tempdir().'addcourse'; - my ($result,$logmsg); + 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, @@ -866,9 +892,10 @@ sub process_batchfile { if ((defined($filename)) && (defined($batchdir))) { my @requests = ($filename); my %courseids = (); - ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses( - \@requests,\%courseids,'web',$defdom, - $uname,$udom); + ($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref) = + &LONCAPA::batchcreatecourse::create_courses( + \@requests,\%courseids,'web',$defdom, + $uname,$udom); if (keys(%courseids) > 0) { if (!-e "$batchdir/processed") { mkdir("$batchdir/processed", 0755); @@ -883,6 +910,9 @@ sub process_batchfile { unlink("$batchdir/pending/$filename"); } } + if ($clonemsg) { + $clonemsg = '

'.$clonemsg.'

'."\n"; + } } } else { $result = '

'.&mt('Could not open attributes file.').'
'.&mt('No courses created.').'

'; @@ -899,7 +929,7 @@ sub process_batchfile { } $r->print(&Apache::loncommon::start_page('Create a New Course, Community or Placement Test'). &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'). - $logmsg.$result.'
'. + $logmsg.$clonemsg.$result.'
'. &mt('Creation options menu').''. &Apache::loncommon::end_page()); } @@ -1436,7 +1466,9 @@ sub handler { my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js); my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests'); $r->print($start_page.$crumbs."\n".'
'. - &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'
'. + &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}, + $env{'user.name'},$env{'user.domain'}). + ''. &Apache::loncommon::end_page()); } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) { &Apache::lonhtmlcommon::add_breadcrumb