--- loncom/interface/slotrequest.pm 2006/04/10 07:37:16 1.57 +++ loncom/interface/slotrequest.pm 2006/04/24 23:23:02 1.58 @@ -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.57 2006/04/10 07:37:16 albertel Exp $ +# $Id: slotrequest.pm,v 1.58 2006/04/24 23:23:02 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1420,22 +1420,49 @@ sub csv_upload_assign { if ($entries{$fields{'endtime'}}) { $slot{'endtime'}=&UnixDate($entries{$fields{'endtime'}},"%s"); } + + # start/endtime must be defined and greater than zero + if (!$slot{'starttime'}) { + push(@errors,"$name not created -- Invalid start time"); + next; + } + if (!$slot{'endtime'}) { + push(@errors,"$name not created -- Invalid end time"); + next; + } + if ($slot{'starttime'} > $slot{'endtime'}) { + push(@errors,"$name not created -- Slot starts after it ends"); + next; + } + if ($entries{$fields{'startreserve'}}) { $slot{'startreserve'}= &UnixDate($entries{$fields{'startreserve'}},"%s"); } + if (defined($slot{'startreserve'}) + && $slot{'startreserve'} > $slot{'starttime'}) { + push(@errors,"$name not created -- Slot's reservation start time is after the slot's start time."); + next; + } + foreach my $key ('ip','proctor','description','maxspace', 'secret','symb') { if ($entries{$fields{$key}}) { $slot{$key}=$entries{$fields{$key}}; } } + if ($entries{$fields{'uniqueperiod'}}) { my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}}); my @times=(&UnixDate($start,"%s"), &UnixDate($end,"%s")); $slot{'uniqueperiod'}=\@times; } + if (defined($slot{'uniqueperiod'}) + && $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; + } &Apache::lonnet::cput('slots',{$name=>\%slot},$cdom,$cname); $r->print('.');