--- loncom/interface/slotrequest.pm 2005/11/14 23:21:55 1.30 +++ loncom/interface/slotrequest.pm 2005/11/18 16:26:47 1.31 @@ -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.30 2005/11/14 23:21:55 albertel Exp $ +# $Id: slotrequest.pm,v 1.31 2005/11/18 16:26:47 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -658,6 +658,9 @@ sub show_table { EDITFORM + my $edit=(<Edit +EDITLINK $r->print("\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 ''; }