--- loncom/automation/Autocreate.pl 2011/03/07 02:10:40 1.19 +++ loncom/automation/Autocreate.pl 2020/07/01 20:09:03 1.22 @@ -2,7 +2,7 @@ # # Automated Course Creation script # -# $Id: Autocreate.pl,v 1.19 2011/03/07 02:10:40 raeburn Exp $ +# $Id: Autocreate.pl,v 1.22 2020/07/01 20:09:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -165,7 +165,7 @@ sub process_xml { my ($fh,$dom,$dcname,$dcdom) = @_; - &set_dc_env($dcname.$dcdom,$dom); + &set_dc_env($dcname,$dcdom,$dom); # Initialize language handler &Apache::lonlocal::get_language_handle(); @@ -175,7 +175,8 @@ sub process_xml { closedir(DIR); my %courseids = (); print $fh "Sending to batch - auto,$dom,$dcname,$dcdom ".join(":",@requests)."\n"; - my ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(\@requests,\%courseids,'auto',$dom,$dcname,$dcdom); + my ($result,$logmsg,$clonemsg,$keysmsg,$codesref,$instcodesref) = + &LONCAPA::batchcreatecourse::create_courses(\@requests,\%courseids,'auto',$dom,$dcname,$dcdom); my $outcome; if ($result ne '') { $outcome = $result."\n"; @@ -183,6 +184,12 @@ sub process_xml { if ($logmsg ne '') { $outcome .= $logmsg."\n"; } + if ($keysmsg ne '') { + $outcome .= $keysmsg."\n"; + } + if ($clonemsg ne '') { + $outcome .= $clonemsg."\n"; + } print $fh $outcome; my $output; @@ -210,6 +217,22 @@ sub process_xml { } $output =~ s/:$//; &unset_dc_env(); + if (ref($instcodesref) eq 'HASH') { + if (keys(%{$instcodesref}) > 0) { + &Apache::lonnet::devalidate_cache_new('instcats',$dom); + if (&Apache::lonnet::shared_institution($dom)) { + my %servers = &Apache::lonnet::internet_dom_servers($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:'.$dom]); + } + } + } + } + } return $output; } @@ -247,7 +270,7 @@ sub set_dc_env { $env{'user.home'} = &Apache::lonnet::homeserver($dcname,$dcdom); if ($defdom ne '') { $env{'request.role.domain'} = $defdom; - } + } return; }