[LON-CAPA-cvs] cvs: loncom /automation Autocreate.pl
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 01 Jun 2005 18:26:22 -0000
raeburn Wed Jun 1 14:26:22 2005 EDT
Modified files:
/loncom/automation Autocreate.pl
Log:
More detailed logging. Pass back more information in list of created courses. Allow creation of full range of roles in a course.
Index: loncom/automation/Autocreate.pl
diff -u loncom/automation/Autocreate.pl:1.2 loncom/automation/Autocreate.pl:1.3
--- loncom/automation/Autocreate.pl:1.2 Thu Apr 7 02:56:21 2005
+++ loncom/automation/Autocreate.pl Wed Jun 1 14:26:20 2005
@@ -66,11 +66,11 @@
my @requests = grep(!/^\.\.?$/,readdir(DIR));
closedir(DIR);
my %courseids = ();
- my $cccflag = 0;
- unless ($env{'allowed.ccc'}) {
- $env{'allowed.ccc'} = 'F';
- $cccflag = 1;
- }
+ my @permissions = ('ccc','cin','cta','cep','ccr','cst');
+ my %permissionflags = ();
+ &set_permissions(\%permissionflags,\@permissions);
+ $ENV{'user.name'} = $dcname;
+ $ENV{'user.domain'} = $dcdom;
my $wwwid=getpwnam('www');
if ($wwwid!=$<) {
my $emailto=$$perlvarref{'lonAdmEMail'};
@@ -94,7 +94,9 @@
exit;
}
- my ($output,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(\@requests,\%courseids,'auto',$defdom,$dcname,$dcdom);
+ print $fh "Sending to batch - auto,$defdom,$dcname,$dcdom ".join(":",@requests)."\n";
+ my ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(\@requests,\%courseids,'auto',$defdom,$dcname,$dcdom);
+ print $fh "$result && $logmsg\n";
# Copy requests from pending directory to processed directory and unlink.
foreach my $request (@requests) {
@@ -102,6 +104,9 @@
open(FILE,"<$batchdir/pending/$request");
my @buffer = <FILE>;
close(FILE);
+ if (!-e "$batchdir/processed") {
+ mkdir("$batchdir/processed", 0755);
+ }
open(FILE,">$batchdir/processed/$request");
print FILE @buffer;
close(FILE);
@@ -111,13 +116,18 @@
}
}
+ my $output;
foreach my $key (sort keys %courseids) {
- print $fh "created course: $key\n";
+ print $fh "created course: $key - $courseids{$key}\n";
+ my $newcourse = &Apache::lonnet::escape($key.':'.$courseids{$key});
+ $output .= $newcourse.':';
}
+ $output =~ s/:$//;
+ print $output;
- if ($cccflag) {
- delete($env{'allowed.ccc'});
- }
+ &unset_permissions(\%permissionflags);
+ delete($ENV{'user.name'});
+ delete($ENV{'user.domain'});
print $fh "-- ".localtime(time)." Autocreation messages end\n*******************\n\n";
close($fh);
@@ -139,3 +149,20 @@
}
return $activedc;
}
+
+sub set_permissions {
+ my ($permissionflags,$permissions) = @_;
+ foreach my $allowtype (@{$permissions}) {
+ unless($ENV{"allowed.$allowtype"}) {
+ $ENV{"allowed.$allowtype"} = 'F';
+ $permissionflags{$allowtype} = 1;
+ }
+ }
+}
+
+sub unset_permissions {
+ my ($permissionflags) = @_;
+ foreach my $allowtype (keys %{$permissionflags}) {
+ delete($ENV{"allowed.$allowtype"});
+ }
+}