[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm

foxr foxr@source.lon-capa.org
Sun, 22 May 2011 14:55:30 -0000


foxr		Sun May 22 14:55:30 2011 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Added tests for resource printability.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.459 loncom/interface/lonnavmaps.pm:1.460
--- loncom/interface/lonnavmaps.pm:1.459	Wed May 18 11:26:44 2011
+++ loncom/interface/lonnavmaps.pm	Sun May 22 14:55:30 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.459 2011/05/18 11:26:44 foxr Exp $
+# $Id: lonnavmaps.pm,v 1.460 2011/05/22 14:55:30 foxr Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2414,7 +2414,6 @@
         }
     }
     my $result = $self->parmval_real($what, $symb, $recurse);
-    my $dumper = Data::Dumper->new([$result]);
     $self->{PARM_CACHE}->{$hashkey} = $result;
     if (wantarray) {
         return @{$result};
@@ -3999,10 +3998,8 @@
 
     # Get the print open/close dates for the resource.
 
-    my $start = $self->parmval("printopendate", $part);
-    my $end   = $self->parmval("printclosedate", $part);
-    my $dumper = Data::Dumper->new([$self, $part, $start, $end]);
-    &Apache::lonnet::logthis("Start for " . $dumper->Dump);
+    my $start = $self->parmval("prinstartdate", $part);
+    my $end   = $self->parmval("printenddate", $part);
 
     #  The following cases apply:
     #  - No dates set: Printable.
@@ -4011,16 +4008,28 @@
     #  - both defined: printable if start <= now <= end
     #
     my $now  = time();
+    &Apache::lonnet::logthis("now: $now, Opens at $start Closes at $end");
 
     my $startok = 1;
     my $endok   = 1;
 
-    if ($start ne '') {
+    if ((defined $start) && ($start ne '')) {
+	&Apache::lonnet::logthis("checking start time.");
 	$startok = $start <= $now;
+	if (!$startok) {
+	    &Apache::lonnet::logthis("Start date is after now");
+	}
     }
-    if ($end  ne '') {
+    if ((defined $end) && ($end != '')) {
+	&Apache::lonnet::logthis("checkin end time");
 	$endok = $end >= $now;
+	if (!$endok) {
+	    &Apache::lonnet::logthis("End date is prior to now");
+	}
     }
+    if (!($startok && $endok)) {
+	&Apache::lonnet::logthis("Resource not printable due to open/close date");
+   }
     return $startok && $endok;
 }
 
@@ -4029,15 +4038,24 @@
 
     # get parts...or realize there are no parts.
 
-    my $parts = $self->parts();
-    if ($parts == 0) {
+    my $partsref = $self->parts();
+    my @parts    = @$partsref;
+
+    if ((!defined(@parts)) || (scalar(@parts) == 0)) {
+	&Apache::lonnet::logthis("resprintable - no parts trying part 0");
 	return $self->printable(0);
     } else {
-	foreach my $part  (@$parts) {
-	    if (!$self->printable($part)) { return 0; }
+	&Apache::lonnet::logthis("resprintable - have " . scalar(@parts) . "  parts require all to be good");
+	foreach my $part  (@parts) {
+	    if (!$self->printable($part)) { 
+		&Apache::lonnet::logthis("resprintable - one of the parts failed date check");
+		return 0; 
+	    }
 	}
+	&Apache::lonnet::logthis("resprintable - All parts passed date check");
 	return 1;
     }
+    &Apache::lonnet::logthis("resprintable - should not have gotten here?");
 }
 
 sub acc {