[LON-CAPA-cvs] cvs: modules /raeburn FIE_usage.pl
raeburn
lon-capa-cvs@mail.lon-capa.org
Fri, 26 May 2006 15:04:41 -0000
raeburn Fri May 26 11:04:41 2006 EDT
Modified files:
/modules/raeburn FIE_usage.pl
Log:
Can filter based on default enrollment start date. Course included in statistics gathering if start date falls within window defined by startopen and startclose dates.
Index: modules/raeburn/FIE_usage.pl
diff -u modules/raeburn/FIE_usage.pl:1.7 modules/raeburn/FIE_usage.pl:1.8
--- modules/raeburn/FIE_usage.pl:1.7 Fri May 26 10:12:46 2006
+++ modules/raeburn/FIE_usage.pl Fri May 26 11:04:40 2006
@@ -211,7 +211,14 @@
my ($cdom,$cnum) = split(/_/,$key);
my %courseenv = &Apache::lonnet::dump('environment',$cdom,$cnum);
my $startenroll = $courseenv{'default_enrollment_start_date'};
- if (($config{'startenroll'} >= $startenroll) && ($startenroll)) {
+ if ($config{'startopen'}) {
+ $config{'startopen'} = &process_date($config{'startopen'});
+ }
+ if ($config{'startclose'}) {
+ $config{'startclose'} = &process_date($config{'startclose'});
+ }
+ if ((($startenroll >= $config{'startopen'}) && ($startenroll)) &&
+ ((($startenroll <= $config{'startclose'}) || !$config{'startclose'}) && ($startenroll))) {
my $code = $courseenv{'coursecode'};
if (!defined($code)) {
$code = 'none';
@@ -672,7 +679,7 @@
$sem = $1;
} else {
$sem = $cparms{$cid}{'coursecode'};
- }
+ }
open(FILE,">fie-data-$sem-$cid.txt");
print FILE "total items = $crsitems{$cid}\n";
foreach my $key (sort(keys(%{$cparms{$cid}}))) {
@@ -1117,3 +1124,50 @@
}
}
+
+sub process_date {
+ my $timestr = shift;
+ my $timestamp = '';
+ if ($timestr !~ /\-/) {
+ $timestamp = '';
+ } else {
+ my @entries = split/\-/,$timestr;
+ for (my $j=0; $j<@entries; $j++) {
+ if ( length($entries[$j]) > 1 ) {
+ $entries[$j] =~ s/^0//;
+ }
+ $entries[$j] =~ s/\D//g;
+ if ($entries[$j] < 0) {
+ $entries[$j] = 0;
+ }
+ }
+ if ($entries[1] > 0) {
+ $entries[1] = $entries[1] - 1;
+ }
+ if ($entries[2] > 31) {
+ $entries[2] = 31;
+ }
+ if ($entries[1] > 11) {
+ $entries[1] = 11;
+ }
+ if ($entries[2] == 31) {
+ if (($entries[1] == 3) || ($entries[1] == 5) ||
+ ($entries[1] == 8) || ($entries[1] == 10)) {
+ $entries[2] = 30;
+ }
+ }
+ if ($entries[1] == 1) {
+ if ($entries[2] > 29) {
+ $entries[2] = 29;
+ }
+ if ($entries[2] == 29) {
+ if ($entries[0]%4) {
+ $entries[2] = 28;
+ }
+ }
+ }
+ $timestamp = timelocal(0,0,0,$entries[2],$entries[1],$entries[0]);
+ }
+ return $timestamp;
+}
+