version 1.158.2.3.2.3, 2020/07/17 23:28:21
|
version 1.158.2.5, 2019/07/26 17:27:44
|
Line 80 use Apache::loncommon;
|
Line 80 use Apache::loncommon;
|
use Apache::londocs; |
use Apache::londocs; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonuserutils; |
use Apache::lonuserutils; |
|
use Apache::lonclonecourse; |
use LONCAPA::batchcreatecourse; |
use LONCAPA::batchcreatecourse; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
|
my $registered_flush; |
|
my $registered_instcats; |
|
my $modified_dom; |
|
|
# ===================================================== Phase one: fill-in form |
# ===================================================== Phase one: fill-in form |
|
|
sub print_course_creation_page { |
sub print_course_creation_page { |
Line 182 function validate(formname) {
|
Line 187 function validate(formname) {
|
'ncd' => "Do not clone date parameters", |
'ncd' => "Do not clone date parameters", |
'prd' => 'Clone date parameters as-is', |
'prd' => 'Clone date parameters as-is', |
'shd' => 'Shift date parameters by number of days', |
'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", |
'assp' => "Assessment Parameters", |
'oaas' => "Open all assessments", |
'oaas' => "Open all assessments", |
'mssg' => "Messaging", |
'mssg' => "Messaging", |
Line 249 function validate(formname) {
|
Line 250 function validate(formname) {
|
$lt{'cc'} = &mt('(will be assigned Coordinator role)'); |
$lt{'cc'} = &mt('(will be assigned Coordinator role)'); |
$lt{'cgrs'} = &mt('Community Group Settings'); |
$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{'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 = <<END; |
my $js = <<END; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 400 END
|
Line 399 END
|
.'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'} |
.'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'} |
.'</label>'); |
.'</label>'); |
} |
} |
my $tinyurlhelp=&Apache::loncommon::help_open_topic('Clone_Tiny_URLs'); |
|
$r->print('<br />('.$lt{'stco'}.')' |
$r->print('<br />('.$lt{'stco'}.')' |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::end_pick_box() |
.&Apache::lonhtmlcommon::end_pick_box() |
Line 432 END
|
Line 430 END
|
.'</label>' |
.'</label>' |
.' <input type="text" size="5" name="dateshift" value="365" />' |
.' <input type="text" size="5" name="dateshift" value="365" />' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title($tinyurlhelp.$lt{'dpl'}) |
|
.'<label>' |
|
.'<input type="radio" name="tinyurls" value="delete" /> '.$lt{'nsl'} |
|
.'</label><br />' |
|
.'<label>' |
|
.'<input type="radio" name="tinyurls" value="transfer" /> '.$lt{'tsl'} |
|
.'</label><br />' |
|
.'<label>' |
|
.'<input type="radio" name="tinyurls" value="create" checked="checked" /> '.$lt{'csl'} |
|
.'</label>' |
|
.&Apache::lonhtmlcommon::row_closure() |
|
.&Apache::lonhtmlcommon::row_headline() |
.&Apache::lonhtmlcommon::row_headline() |
.'<span class="LC_info">'.$lt{'asov'}.'</span>' |
.'<span class="LC_info">'.$lt{'asov'}.'</span>' |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::row_closure(1) |
Line 653 sub create_course {
|
Line 640 sub create_course {
|
clonedomain => $env{'form.clonedomain'}, |
clonedomain => $env{'form.clonedomain'}, |
datemode => $env{'form.datemode'}, |
datemode => $env{'form.datemode'}, |
dateshift => $env{'form.dateshift'}, |
dateshift => $env{'form.dateshift'}, |
tinyurls => $env{'form.tinyurls'}, |
|
crsid => $env{'form.crsid'}, |
crsid => $env{'form.crsid'}, |
curruser => $env{'user.name'}.':'.$env{'user.domain'}, |
curruser => $env{'user.name'}.':'.$env{'user.domain'}, |
crssections => $env{'form.crssections'}, |
crssections => $env{'form.crssections'}, |
Line 720 sub create_course {
|
Line 706 sub create_course {
|
return; |
return; |
} |
} |
my ($courseid,$crsudom,$crsunum,$code); |
my ($courseid,$crsudom,$crsunum,$code); |
my ($success,$output,$clonemsgref) = |
my ($success,$output) = |
&Apache::loncommon::construct_course($args,\$logmsg,\$courseid, |
&Apache::loncommon::construct_course($args,\$logmsg,\$courseid, |
\$crsudom,\$crsunum, |
\$crsudom,\$crsunum, |
$env{'user.domain'}, |
$env{'user.domain'}, |
$env{'user.name'},'dc_create',undef,undef,\$code); |
$env{'user.name'},'dc_create',undef,undef,\$code); |
$r->print($output); |
$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}}).'<br />'."\n"); |
|
} |
|
} |
|
} |
|
if ($success) { |
if ($success) { |
# |
# |
# Make the requested user a course coordinator or group coordinator |
# Make the requested user a course coordinator or group coordinator |
Line 757 sub create_course {
|
Line 735 sub create_course {
|
'<p>'.&mt('Course identifier to share with students: [_1]',$code).'</p>' |
'<p>'.&mt('Course identifier to share with students: [_1]',$code).'</p>' |
); |
); |
} |
} |
# Flush the course logs so reverse user roles immediately updated |
if ($env{'form.crscode'} ne '') { |
$r->register_cleanup(\&Apache::lonnet::flushcourselogs); |
&Apache::lonnet::devalidate_cache_new('instcats',$crsudom); |
|
} |
|
®ister_cleanups($r,$crsudom,$env{'form.crscode'}); |
$r->print('<p>'.&mt('Roles will be active at next login').'.</p>'); |
$r->print('<p>'.&mt('Roles will be active at next login').'.</p>'); |
} |
} |
$r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'. |
$r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'. |
Line 878 sub process_batchfile {
|
Line 858 sub process_batchfile {
|
my $uname = $env{'user.name'}; |
my $uname = $env{'user.name'}; |
my $udom = $env{'user.domain'}; |
my $udom = $env{'user.domain'}; |
my $dir = &LONCAPA::tempdir().'addcourse'; |
my $dir = &LONCAPA::tempdir().'addcourse'; |
my ($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref |
my ($result,$logmsg,$keysmsg,$codesref,$instcodesref); |
if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) { |
if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) { |
my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef, |
my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef, |
'batchupload',undef,undef, |
'batchupload',undef,undef, |
undef,undef,$defdom); |
undef,undef,$defdom); |
if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\_$udom\E)/pending/([^/]+)$}) { |
if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\E_\Q$udom\E)/pending/([^/]+)$}) { |
my ($batchdir,$filename) = ($1,$2); |
my ($batchdir,$filename) = ($1,$2); |
if (-e "$batchfilepath") { |
if (-e "$batchfilepath") { |
if (open(FILE,"<",$batchfilepath)) { |
if (open(FILE,"<",$batchfilepath)) { |
Line 892 sub process_batchfile {
|
Line 872 sub process_batchfile {
|
if ((defined($filename)) && (defined($batchdir))) { |
if ((defined($filename)) && (defined($batchdir))) { |
my @requests = ($filename); |
my @requests = ($filename); |
my %courseids = (); |
my %courseids = (); |
($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref) = |
($result,$logmsg,$keysmsg,$codesref,$instcodesref) = |
&LONCAPA::batchcreatecourse::create_courses( |
&LONCAPA::batchcreatecourse::create_courses( |
\@requests,\%courseids,'web',$defdom, |
\@requests,\%courseids,'web',$defdom, |
$uname,$udom); |
$uname,$udom); |
Line 909 sub process_batchfile {
|
Line 889 sub process_batchfile {
|
if (-e "$batchdir/processed/$filename") { |
if (-e "$batchdir/processed/$filename") { |
unlink("$batchdir/pending/$filename"); |
unlink("$batchdir/pending/$filename"); |
} |
} |
} |
my $updatecats; |
if ($clonemsg) { |
if ((ref($instcodesref) eq 'HASH') && (keys(%{$instcodesref}) > 0)) { |
$clonemsg = '<p class="LC_info">'.$clonemsg.'</p>'."\n"; |
&Apache::lonnet::devalidate_cache_new('instcats',$defdom); |
|
$updatecats = 1; |
|
} |
|
®ister_cleanups($r,$defdom,$updatecats); |
|
|
} |
} |
} |
} |
} else { |
} else { |
Line 929 sub process_batchfile {
|
Line 913 sub process_batchfile {
|
} |
} |
$r->print(&Apache::loncommon::start_page('Create a New Course, Community or Placement Test'). |
$r->print(&Apache::loncommon::start_page('Create a New Course, Community or Placement Test'). |
&Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'). |
&Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses'). |
$logmsg.$clonemsg.$result.'<br /><a href="/adm/createcourse">'. |
$logmsg.$result.'<br /><a href="/adm/createcourse">'. |
&mt('Creation options menu').'</a>'. |
&mt('Creation options menu').'</a>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} |
} |
Line 1319 sub get_permission {
|
Line 1303 sub get_permission {
|
return ($allowed,\%permission); |
return ($allowed,\%permission); |
} |
} |
|
|
|
sub register_cleanups { |
|
my ($r,$cdom,$updatecats) = @_; |
|
# Flush the course logs so reverse user roles immediately updated |
|
unless ($registered_flush) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]); |
|
$registered_flush=1; |
|
} |
|
# Update cache of self-cataloging courses on institution's server(s). |
|
if ($updatecats) { |
|
if (&Apache::lonnet::shared_institution($cdom)) { |
|
unless ($registered_instcats) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]); |
|
$registered_instcats=1; |
|
$modified_dom = $cdom; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub devalidate_remote_instcats { |
|
if ($modified_dom ne '') { |
|
my %servers = &Apache::lonnet::internet_dom_servers($modified_dom); |
|
my %thismachine; |
|
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
|
if (keys(%servers)) { |
|
foreach my $server (keys(%servers)) { |
|
next if ($thismachine{$server}); |
|
&Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]); |
|
} |
|
} |
|
$modified_dom = ''; |
|
} |
|
return; |
|
} |
|
|
# ===================================================================== Handler |
# ===================================================================== Handler |
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
Line 1329 sub handler {
|
Line 1351 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
|
$registered_flush = 0; |
|
$registered_instcats = 0; |
|
$modified_dom = ''; |
|
|
my ($allowed,$permission) = &get_permission($env{'request.role.domain'}); |
my ($allowed,$permission) = &get_permission($env{'request.role.domain'}); |
if ($allowed) { |
if ($allowed) { |
my $show_all_choices = 0; |
my $show_all_choices = 0; |
Line 1466 sub handler {
|
Line 1492 sub handler {
|
my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js); |
my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Requests',undef,'Course_Requests'); |
$r->print($start_page.$crumbs."\n".'<div>'. |
$r->print($start_page.$crumbs."\n".'<div>'. |
&Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}, |
&Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'. |
$env{'user.name'},$env{'user.domain'}). |
|
'</div>'. |
|
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) { |
} elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |