\n$edit | \n");
if (exists($show{'name'})) {
@@ -887,16 +890,34 @@ sub csv_upload_assign {
my $cname=$env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my $countdone=0;
+ my @errors;
foreach my $slot (@slotdata) {
my %slot;
my %entries=&Apache::loncommon::record_sep($slot);
my $domain;
my $name=$entries{$fields{'name'}};
+ if ($name=~/^\s*$/) {
+ push(@errors,"Did not create slot with no name");
+ next;
+ }
+ if ($name=~/\s/) {
+ push(@errors,"$name not created -- Name must not contain spaces");
+ next;
+ }
+ if ($name=~/\W/) {
+ push(@errors,"$name not created -- Name must contain only letters, numbers and _");
+ next;
+ }
if ($entries{$fields{'type'}}) {
$slot{'type'}=$entries{$fields{'type'}};
} else {
$slot{'type'}='preassigned';
}
+ if ($slot{'type'} ne 'preassigned' &&
+ $slot{'type'} ne 'schedulable_student') {
+ push(@errors,"$name not created -- invalid type ($slot{'type'}) must be either preassigned or schedulable_student");
+ next;
+ }
if ($entries{$fields{'starttime'}}) {
$slot{'starttime'}=&UnixDate($entries{$fields{'starttime'}},"%s");
}
@@ -925,8 +946,10 @@ sub csv_upload_assign {
$r->rflush();
$countdone++;
}
- $r->print("
Created $countdone slots\n");
- $r->print("
\n");
+ $r->print("Created $countdone slots\n
");
+ foreach my $error (@errors) {
+ $r->print("$error\n
");
+ }
&show_table($r,$mgr);
return '';
}