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

www lon-capa-cvs@mail.lon-capa.org
Sat, 04 Mar 2006 22:17:37 -0000


www		Sat Mar  4 17:17:37 2006 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Bug #4084: Warning in case of dates outside of course enrollment range
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.276 loncom/interface/lonparmset.pm:1.277
--- loncom/interface/lonparmset.pm:1.276	Thu Feb  9 17:11:54 2006
+++ loncom/interface/lonparmset.pm	Sat Mar  4 17:17:36 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.276 2006/02/09 22:11:54 raeburn Exp $
+# $Id: lonparmset.pm,v 1.277 2006/03/04 22:17:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -293,6 +293,25 @@
 }
 
 ##################################################
+
+sub date_sanity_info {
+   my $checkdate=shift;
+   unless ($checkdate) { return ''; }
+   my $result='';
+   my $crsprefix='course.'.$env{'request.course.id'}.'.';
+   if ($env{$crsprefix.'default_enrollment_end_date'}) {
+      if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
+         $result.='<br />'.&mt('After course enrollment end!');
+      }
+   }
+   if ($env{$crsprefix.'default_enrollment_start_date'}) {
+      if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
+         $result.='<br />'.&mt('Before course enrollment start!');
+      }
+   }
+   return $result;
+}
+##################################################
 ##################################################
 #
 # Store a parameter by ID
@@ -516,7 +535,7 @@
             }
             $result=~s/\s+$//;
         } elsif (&isdateparm($type)) {
-            $result = localtime($value);
+            $result = localtime($value).&date_sanity_info($value);
         } else {
             $result = $value;
         }
@@ -2560,7 +2579,8 @@
 							      $jskey,
 						      $$resourcedata{$thiskey},
 							      '',1,'','',$hour,$min,$sec).
-'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
+'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
+&date_sanity_info($$resourcedata{$thiskey})
 			  );
 	    } elsif ($thistype eq 'string_yesno') {
 		my $showval;