--- loncom/interface/loncreatecourse.pm 2020/07/17 23:28:21 1.158.2.3.2.3 +++ loncom/interface/loncreatecourse.pm 2020/05/22 21:52:14 1.158.2.3.4.1 @@ -1,7 +1,7 @@ # The LearningOnline Network # Create a course # -# $Id: loncreatecourse.pm,v 1.158.2.3.2.3 2020/07/17 23:28:21 raeburn Exp $ +# $Id: loncreatecourse.pm,v 1.158.2.3.4.1 2020/05/22 21:52:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -80,8 +80,9 @@ use Apache::loncommon; use Apache::londocs; use Apache::lonlocal; use Apache::lonuserutils; +use Apache::lonclonecourse; use LONCAPA::batchcreatecourse; -use LONCAPA qw(:DEFAULT :match); +use LONCAPA; # ===================================================== Phase one: fill-in form @@ -98,7 +99,7 @@ sub print_course_creation_page { foreach my $server (sort(keys(%host_servers))) { $course_home .= qq{}; } @@ -115,6 +116,8 @@ sub print_course_creation_page { my $endtime = time+(6*30*24*60*60); # 6 months from now, approx my $access_table = &Apache::lonuserutils::date_setting_table($starttime, $endtime,'create_defaultdates'); + my $openallfrom = + &Apache::lonhtmlcommon::date_setter('ccrs','openallfrom',$starttime); if ($crstype eq 'Course') { $enroll_table = &Apache::lonuserutils::date_setting_table($starttime, $endtime,'create_enrolldates'); @@ -182,12 +185,9 @@ 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:", 'mssg' => "Messaging", 'scpf' => "Set course policy feedback to Course Coordinator", 'scfc' => "Set resource content feedback to Course Coordinator", @@ -249,11 +249,11 @@ 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 = < +// $coursebrowserjs END @@ -290,7 +292,7 @@ END 'Create_Courses'); $r->print($start_page.$crumbs); - $r->print('
' + $r->print('
' .&Apache::lonhtmlcommon::start_pick_box() .&Apache::lonhtmlcommon::row_headline() @@ -357,6 +359,7 @@ END .'' .''.&mt('Yes').(' 'x2) .''.&mt('No') + .'' .&Apache::lonhtmlcommon::row_closure() ); } @@ -400,12 +403,11 @@ 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() - .' ' + .' ' # Clone Course: .'' @@ -432,17 +434,6 @@ 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) @@ -466,7 +457,10 @@ END .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title($lt{'oaas'}) - .'' + .'' + .''.(' 'x2) + .''.', ' + .$lt{'sta'}.' '.$openallfrom.'' .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_headline() @@ -580,7 +574,8 @@ END

-' + +

' ); } elsif ($crstype eq 'Community') { $r->print(' @@ -602,7 +597,7 @@ sub create_course { my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'}); my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'}); my $crstype = 'Community'; - my ($enrollstart,$enrollend,$startaccess,$endaccess); + my ($enrollstart,$enrollend,$startaccess,$endaccess,$openallfrom); my %domdefaults = &Apache::lonnet::get_domain_defaults($env{'request.role.domain'}); @@ -613,6 +608,7 @@ sub create_course { } $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess'); $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess'); + $openallfrom = &Apache::lonhtmlcommon::get_date_from_form('openallfrom'); my $autharg; my $authtype; @@ -653,7 +649,6 @@ 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'}, @@ -679,6 +674,7 @@ sub create_course { disresdis => $env{'form.disresdis'}, disablechat => $env{'form.disablechat'}, openall => $env{'form.openall'}, + openallfrom => $openallfrom, firstres => $env{'form.firstres'} }; @@ -720,20 +716,12 @@ sub create_course { return; } my ($courseid,$crsudom,$crsunum,$code); - my ($success,$output,$clonemsgref) = + my ($success,$output) = &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 @@ -874,64 +862,43 @@ sub upload_batchfile { sub process_batchfile { my $r = shift; + my $start_page = + &Apache::loncommon::start_page('Create a New Course or Community'); + my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'); + my $end_page = + &Apache::loncommon::end_page(); my $defdom=$env{'request.role.domain'}; - my $uname = $env{'user.name'}; - my $udom = $env{'user.domain'}; - my $dir = &LONCAPA::tempdir().'addcourse'; - 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, - undef,undef,$defdom); - if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\_$udom\E)/pending/([^/]+)$}) { - my ($batchdir,$filename) = ($1,$2); - if (-e "$batchfilepath") { - if (open(FILE,"<",$batchfilepath)) { - my @buffer = ; + my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef, + 'batchupload',undef,undef, + undef,undef,$defdom); + my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-); + my ($result,$logmsg); + if (-e "$batchfilepath") { + open(FILE,"<$batchfilepath"); + my @buffer = ; + close(FILE); + if ((defined($filename)) && (defined($batchdir))) { + my @requests = ($filename); + my %courseids = (); + ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses( + \@requests,\%courseids,'web',$defdom, + $env{'user.name'},$env{'user.domain'}); + if ($result) { + if (!-e "$batchdir/processed") { + mkdir("$batchdir/processed", 0755); + open(FILE,">$batchdir/processed/$filename"); + print FILE @buffer; close(FILE); - if ((defined($filename)) && (defined($batchdir))) { - my @requests = ($filename); - my %courseids = (); - ($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); - } - if (-d "$batchdir/processed") { - if (open(FILE,">","$batchdir/processed/$filename")) { - print FILE @buffer; - close(FILE); - } - } - if (-e "$batchdir/processed/$filename") { - unlink("$batchdir/pending/$filename"); - } - } - if ($clonemsg) { - $clonemsg = '

'.$clonemsg.'

'."\n"; - } + if (-e "$batchdir/processed/$filename") { + unlink("$batchdir/pending/$filename"); } - } else { - $result = '

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

'; } - } else { - $result = '

'.&mt('No uploaded attributes file found.').'
'.&mt('No courses created.').'

'; } - } else { - $result = '

'.&mt('Invalid path to attributes file.').'
'.&mt('No courses created.').'

'; } - } else { - $result = '

'.&mt("Your username, domain, and/or your current role's domain are missing or contain invalid characters."). - '
'.&mt('No courses created.').'

'; } - $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.$clonemsg.$result.'
'. - &mt('Creation options menu').''. - &Apache::loncommon::end_page()); + $r->print($start_page.$crumbs.$logmsg.$result.'
'. + &mt('Creation options menu').''.$end_page); + } sub courserequestbrowser_javascript { @@ -1466,9 +1433,7 @@ 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'}, - $env{'user.name'},$env{'user.domain'}). - '
'. + &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'
'. &Apache::loncommon::end_page()); } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) { &Apache::lonhtmlcommon::add_breadcrumb