[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonprintout.pm

raeburn raeburn at source.lon-capa.org
Mon Jan 20 01:09:58 EST 2014


raeburn		Mon Jan 20 06:09:58 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonprintout.pm 
  Log:
  - For 2.11
    - Backport 1.637, 1.638
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.627.2.8 loncom/interface/lonprintout.pm:1.627.2.9
--- loncom/interface/lonprintout.pm:1.627.2.8	Wed Aug 28 14:31:54 2013
+++ loncom/interface/lonprintout.pm	Mon Jan 20 06:09:58 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.627.2.8 2013/08/28 14:31:54 raeburn Exp $
+# $Id: lonprintout.pm,v 1.627.2.9 2014/01/20 06:09:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -27,7 +27,6 @@
 #
 package Apache::lonprintout;
 use strict;
-use POSIX;
 use Apache::Constants qw(:common :http);
 use Apache::lonxml;
 use Apache::lonnet;
@@ -47,7 +46,6 @@
 
 use HTTP::Response;
 use LONCAPA::map();
-use POSIX qw(ctime);
 use Apache::lonlocal;
 use Carp;
 use LONCAPA;
@@ -494,7 +492,7 @@
 #
 # @return ($open, $close) 
 #
-# @note If open/close dates are not defined they will be retunred as undef
+# @note If open/close dates are not defined they will be returned as undef
 # @note It is possible for there to be no overlap in which case -1,-1 
 #       will be returned.
 # @note The algorithm used is to take the latest open date and the earliest end date.
@@ -524,7 +522,7 @@
 
     # If no overlap...both are -1 as promised.
 
-    if (defined($earliest_close) && defined($latest_open)
+    if (($earliest_close ne '') && ($latest_open ne '')
 	 && ($earliest_close < $latest_open)) {
 	$latest_open  = -1;
 	$earliest_close = -1;
@@ -572,11 +570,14 @@
 #
 # @return (opendate, closedate)
 #
-# @note If open/close dates are not defined they will be retunred as undef
+# @note If open/close dates are not defined they will be returned as undef
 # @note It is possible for there to be no overlap in which case -1,-1 
 #       will be returned.
 # @note The algorithm used is to take the latest open date and the earliest end date.
-#
+#       For consistency with &printable() in lonnavmaps.pm determination of start
+#       date for printing checks printstartdate param first, then, if not set,
+#       opendate param, then, if not set, contentopen param.
+
 
 sub get_print_dates {
     my $res = shift;
@@ -595,7 +596,18 @@
 	foreach my $part (@parts) {
 	    my $partopen  = $res->parmval('printstartdate', $part);
 	    my $partclose = $res->parmval('printenddate',  $part);
-
+            if (!$partopen) {
+                $partopen = $res->parmval('opendate',$part);
+            }
+            if (!$partopen) {
+                $partopen = $res->parmval('contentopen',$part);
+            }
+            if ($partopen) {
+                push(@open_dates, $partopen);
+            }
+            if ($partclose) {
+                push(@close_dates, $partclose);
+            }
 	    push(@open_dates, $partopen);
 	    push(@close_dates, $partclose);
 	}
@@ -603,13 +615,6 @@
 
     ($open_date, $close_date)  = &compute_open_window(\@open_dates, \@close_dates);
 
-    if ($open_date) {
-	$open_date  = POSIX::strftime('%D', localtime($open_date));
-    }
-    if ($close_date) {
-	$close_date = POSIX::strftime('%D', localtime($close_date));
-    }
-
     return ($open_date, $close_date);
 }
 
@@ -4062,7 +4067,7 @@
 		&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
 	    my $navmap = Apache::lonnavmaps::navmap->new();
 	    my $res   = $navmap->getBySymb($symb);
-	    $res_printable  = $res->resprintable() | $userCanPrint; #printability in course context
+	    $res_printable  = $res->resprintable() || $userCanPrint; #printability in course context
 	    ($res_printstartdate, $res_printenddate) = 	&get_print_dates($res);
 	    ($course_open, $course_close) = &course_print_dates($res);
 	    ($map_open, $map_close)       = &map_print_dates($res);
@@ -4667,12 +4672,33 @@
     # Generate the first state, to select which resources get printed.
     Apache::lonhelper::state->new("START", "Select Printing Options:");
     if (!$res_printable) {
-	$paramHash = Apache::lonhelper::getParamHash();
-	$paramHash->{MESSAGE_TEXT} =
-            '<p class="LC_info">'
-           .&mt('Printing for current resource is only possible between [_1] and [_2]',
-                $res_printstartdate, $res_printenddate).'</p>';
-	Apache::lonhelper::message->new();
+        my $now = time;
+        my $shownprintstart = &Apache::lonlocal::locallocaltime($res_printstartdate);
+        my $shownprintend = &Apache::lonlocal::locallocaltime($res_printenddate);
+        my $noprintmsg;
+        if (($res_printenddate) && ($res_printenddate < $now)) {
+                $noprintmsg = &mt('Printing for current resource no longer available (ended: [_1])',
+                                  $shownprintend);
+        } else {
+            if (($res_printstartdate) && ($res_printstartdate > $now)) {
+                if (($res_printenddate) && ($res_printenddate > $now) && ($res_printenddate > $res_printstartdate)) {
+                    $noprintmsg = &mt('Printing for current resource is only possible between [_1] and [_2]',
+                                  $shownprintstart,$shownprintend);
+                } elsif (!$res_printenddate) {
+                    $noprintmsg = &mt('Printing for current resource will only be possible starting [_1]',
+                                      $shownprintstart);
+                } else {
+                    $noprintmsg = &mt('Printing for current resource is unavailable');
+                }
+            }
+        }
+
+        if ($noprintmsg) {
+            $paramHash = Apache::lonhelper::getParamHash();
+            $paramHash->{MESSAGE_TEXT} =
+                '<p class="LC_info">'.$noprintmsg.'</p>';
+            Apache::lonhelper::message->new();
+        }
     }
     $paramHash = Apache::lonhelper::getParamHash();
     $paramHash = Apache::lonhelper::getParamHash();




More information about the LON-CAPA-cvs mailing list