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

raeburn raeburn at source.lon-capa.org
Sat May 21 17:13:58 EDT 2016


raeburn		Sat May 21 21:13:58 2016 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm 
  Log:
  - Display error message when creating slotadeom an upoaded slot definitions
    file upload if date/time format invalid. 
  
  
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.131 loncom/interface/slotrequest.pm:1.132
--- loncom/interface/slotrequest.pm:1.131	Mon Oct  5 02:35:45 2015
+++ loncom/interface/slotrequest.pm	Sat May 21 21:13:58 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for requesting to have slots added to a students record
 #
-# $Id: slotrequest.pm,v 1.131 2015/10/05 02:35:45 raeburn Exp $
+# $Id: slotrequest.pm,v 1.132 2016/05/21 21:13:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3035,8 +3035,12 @@
 	}
 
 	if ($entries{$fields{'startreserve'}}) {
-	    $slot{'startreserve'}=
-		&UnixDate($entries{$fields{'startreserve'}},"%s");
+            my $date = &UnixDate($entries{$fields{'startreserve'}},"%s");
+            if ($date eq '') {
+                push(@errors,"$name -- No reservation start time set for slot -- value provided had invalid format");
+            } else {
+                $slot{'startreserve'} = $date;
+            }
 	}
 	if (defined($slot{'startreserve'})
 	    && $slot{'startreserve'} > $slot{'starttime'}) {
@@ -3045,8 +3049,12 @@
 	}
 
         if ($entries{$fields{'endreserve'}}) {
-            $slot{'endreserve'}=
-                &UnixDate($entries{$fields{'endreserve'}},"%s");
+            my $date = &UnixDate($entries{$fields{'endreserve'}},"%s");
+            if ($date eq '') {
+                push(@errors,"$name -- No reservation end time set for slot -- value provided had invalid format");
+            } else {
+                $slot{'endreserve'} = $date;
+            }
         }
         if (defined($slot{'endreserve'})
             && $slot{'endreserve'} > $slot{'starttime'}) {
@@ -3111,12 +3119,14 @@
             }
         }
 	if ($entries{$fields{'uniqueperiod'}}) {
-	    my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}});
-	    my @times=(&UnixDate($start,"%s"),
-		       &UnixDate($end,"%s"));
-	    $slot{'uniqueperiod'}=\@times;
+            my ($start,$end)= map { &UnixDate($_,"%s"); } split(',',$entries{$fields{'uniqueperiod'}});
+            if (($start ne '') && ($end ne '')) {
+                $slot{'uniqueperiod'}=[$start,$end];
+            } else {
+                push(@errors,"$name -- Slot's unique period ignored -- one or both of the comma separated values for start and end had an invalid format");
+            }
 	}
-	if (defined($slot{'uniqueperiod'})
+	if (ref($slot{'uniqueperiod'}) eq 'ARRAY' 
 	    && $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) {
 	    push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time.");
 	    next;




More information about the LON-CAPA-cvs mailing list