');
$r->print('
@@ -1081,7 +1111,7 @@ sub show_table {
my $unique;
if (ref($slots{$slot}{'uniqueperiod'})) {
- $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','.
+ $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).', '.
localtime($slots{$slot}{'uniqueperiod'}[1]);
}
@@ -1122,7 +1152,7 @@ sub show_table {
if (exists($show{'proctor'})) {
$rowspan=2;
@proctors= map {
- my ($uname,$udom)=split(/@/,$_);
+ my ($uname,$udom)=split(/:/,$_);
my $fullname=$name_cache{$_};
if (!defined($fullname)) {
$fullname = &Apache::loncommon::plainname($uname,$udom);
@@ -1139,7 +1169,7 @@ sub show_table {
EDITLINK
my $delete=(<<"DELETELINK");
-Delete
+Delete
DELETELINK
my $remove_all=&remove_link($slot,'remove all').'
';
@@ -1187,9 +1217,13 @@ DELETELINK
if (exists($show{'allowedusers'})) {
$colspan++;$r->print("$allowedusers | \n");
}
+ if (exists($show{'uniqueperiod'})) {
+ $colspan++;$r->print("$unique | \n");
+ }
if (exists($show{'scheduled'})) {
- $colspan++;$r->print("$remove_all $ids | \n\n");
+ $colspan++;$r->print("$remove_all $ids | \n");
}
+ $r->print("\n");
if (exists($show{'proctor'})) {
$r->print(<
@@ -1198,7 +1232,7 @@ DELETELINK
STUFF
}
}
- $r->print('
');
+ $r->print('');
}
sub upload_start {
@@ -1420,22 +1454,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('.');
@@ -1498,11 +1559,15 @@ sub handler {
&csv_upload_map($r);
}
} else {
- my $symb=&Apache::lonnet::unescape($env{'form.symb'});
+ my $symb=&unescape($env{'form.symb'});
+ if (!defined($symb)) {
+ &fail($r,'not_valid');
+ return OK;
+ }
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb);
my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb);
- if ($useslots ne 'resource') {
- &fail($r,'not_valid');
+ if ($useslots ne 'resource' && $useslots ne 'map') {
+ &fail($r,'not_available');
return OK;
}
$env{'request.symb'}=$symb;