[LON-CAPA-cvs] cvs: modules /albertel course_info.pl
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 19 Jan 2006 14:04:59 -0000
albertel Thu Jan 19 09:04:59 2006 EDT
Modified files:
/modules/albertel course_info.pl
Log:
- takes a year argument
Index: modules/albertel/course_info.pl
diff -u modules/albertel/course_info.pl:1.5 modules/albertel/course_info.pl:1.6
--- modules/albertel/course_info.pl:1.5 Tue Jan 17 16:10:55 2006
+++ modules/albertel/course_info.pl Thu Jan 19 09:04:57 2006
@@ -1,5 +1,5 @@
use strict;
-use Apache2::compat;
+#use Apache2::compat;
use strict;
use lib '/home/httpd/lib/perl';
use IO::File;
@@ -8,6 +8,13 @@
use Apache::loncoursedata;
use LONCAPA::Configuration;
use GDBM_File;
+use Date::Manip;
+use Getopt::Long;
+
+my $year;
+my $result = GetOptions ("year=i" => \$year,);
+
+
my $perlvar = LONCAPA::Configuration::read_conf('loncapa.conf');
@@ -19,7 +26,7 @@
my @domains = &Apache::lonnet::current_machine_domains();
my @hostids = &Apache::lonnet::current_machine_ids();
foreach my $dom (sort(@domains)) {
- &logfile("output/$dom.info");
+ &logfile("output/$year/$year.$dom.info");
&log("\n\n$dom\n");
&increaselog();
my %courses =
@@ -31,6 +38,13 @@
return &creation_date($acdom,$acnum) <=>
&creation_date($bcdom,$bcnum)
} keys(%courses)) {
+ my ($cdom,$cnum) = split('_',$key);
+ if (&creation_date($cdom,$cnum) < &UnixDate("$year","%s")) {
+ next;
+ }
+ if (&creation_date($cdom,$cnum) > &UnixDate($year+1,"%s")) {
+ next;
+ }
&course_stats($key);
&log("-"x50);
}
@@ -261,7 +275,16 @@
sub logfile {
my ($name) = @_;
if ($logfile) { $logfile->close; }
+ my (@dirs) = split(/\//,$name);
+ my $now=shift(@dirs);
+ while (@dirs) {
+ if (!-e $now) {
+ if (!mkdir($now,0770)) { die("Couldn't make dir $now\n"); }
+ }
+ $now = join('/',$now,shift(@dirs));
+ }
$logfile = new IO::File ">$name";
+ if (!$logfile) { die("Can't create $name\n"); }
}
sub log {