[LON-CAPA-cvs] cvs: loncom /html/adm/helper newslot.helper /interface slotrequest.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 24 Apr 2006 23:23:18 -0000
albertel Mon Apr 24 19:23:18 2006 EDT
Modified files:
/loncom/interface slotrequest.pm
/loncom/html/adm/helper newslot.helper
Log:
- adding more slot validation to the creation interfaces
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.57 loncom/interface/slotrequest.pm:1.58
--- loncom/interface/slotrequest.pm:1.57 Mon Apr 10 03:37:16 2006
+++ loncom/interface/slotrequest.pm Mon Apr 24 19:23:02 2006
@@ -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 @@
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('.');
Index: loncom/html/adm/helper/newslot.helper
diff -u loncom/html/adm/helper/newslot.helper:1.14 loncom/html/adm/helper/newslot.helper:1.15
--- loncom/html/adm/helper/newslot.helper:1.14 Tue Mar 7 11:29:14 2006
+++ loncom/html/adm/helper/newslot.helper Mon Apr 24 19:23:18 2006
@@ -64,6 +64,12 @@
<defaultvalue>
return &{$helper->{DATA}{origslot}}('endtime');
</defaultvalue>
+ <validator>
+ if ($val < $helper->{'VARS'}{'starttime'}) {
+ return 'End time must be later than the start time.';
+ }
+ return undef;
+ </validator>
</date>
<message>
<br />Type:
@@ -96,6 +102,12 @@
<defaultvalue>
return &{$helper->{DATA}{origslot}}('startreserve','anytime');
</defaultvalue>
+ <validator>
+ if (defined($val) && $val > $helper->{'VARS'}{'starttime'}) {
+ return 'Reservation time must come before the slot has started.';
+ }
+ return undef;
+ </validator>
</date>
<message>
</p><p>Maxium number of students allowed in this slot:<br />
@@ -128,6 +140,12 @@
if (ref($default)) { return $default->[1]; }
return 'anytime';
</defaultvalue>
+ <validator>
+ if (defined($val) && $val < $helper->{'VARS'}{'startunique'}) {
+ return 'End time must be later than the start time.';
+ }
+ return undef;
+ </validator>
</date>
</condition>
<condition>