Show: '.&Apache::loncommon::multiple_select_form('show',\@sel,6,\%fields,\@order).
+');
+ $r->print('');
+ $r->print(' '.&mt('Show').' | '.&mt('Open').' |
---|
'.&Apache::loncommon::multiple_select_form('show',\@show,6,\%show_fields,\@show_order).
+ ' | '.&Apache::loncommon::select_form($when,'when',%when_fields).
' |
');
+ $r->print(' ');
+ $r->print('');
my $linkstart='
+ $r->print('
| ');
- foreach my $which (@order) {
- if ($which ne 'proctor' && exists($sel{$which})) {
- $r->print(''.$linkstart.$which.'">'.$fields{$which}.' | ');
+ foreach my $which (@show_order) {
+ if ($which ne 'proctor' && exists($show{$which})) {
+ $r->print(''.$linkstart.$which.'">'.$show_fields{$which}.' | ');
}
}
$r->print('Scheduled Students | ');
@@ -539,6 +600,7 @@ sub show_table {
return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'};
};
foreach my $slot (sort $slotsort (keys(%slots))) {
+ if (!&to_show($when,$slots{$slot})) { next; }
if (defined($slots{$slot}->{'type'})
&& $slots{$slot}->{'type'} ne 'schedulable_student') {
#next;
@@ -574,7 +636,7 @@ sub show_table {
my @proctors;
my $rowspan=1;
my $colspan=1;
- if (exists($sel{'proctor'})) {
+ if (exists($show{'proctor'})) {
$rowspan=2;
@proctors= map {
my ($uname,$udom)=split(/@/,$_);
@@ -596,43 +658,46 @@ sub show_table {
EDITFORM
+ my $edit=(<Edit
+EDITLINK
$r->print("\n$edit | \n");
- if (exists($sel{'name'})) {
+ if (exists($show{'name'})) {
$colspan++;$r->print("$slot | ");
}
- if (exists($sel{'type'})) {
+ if (exists($show{'type'})) {
$colspan++;$r->print("$slots{$slot}->{'type'} | \n");
}
- if (exists($sel{'description'})) {
+ if (exists($show{'description'})) {
$colspan++;$r->print("$description | \n");
}
- if (exists($sel{'starttime'})) {
+ if (exists($show{'starttime'})) {
$colspan++;$r->print("$start | \n");
}
- if (exists($sel{'endtime'})) {
+ if (exists($show{'endtime'})) {
$colspan++;$r->print("$end | \n");
}
- if (exists($sel{'startreserve'})) {
+ if (exists($show{'startreserve'})) {
$colspan++;$r->print("$start_reserve | \n");
}
- if (exists($sel{'secret'})) {
+ if (exists($show{'secret'})) {
$colspan++;$r->print("$slots{$slot}{'secret'} | \n");
}
- if (exists($sel{'maxspace'})) {
+ if (exists($show{'maxspace'})) {
$colspan++;$r->print("$slots{$slot}{'maxspace'} | \n");
}
- if (exists($sel{'ip'})) {
+ if (exists($show{'ip'})) {
$colspan++;$r->print("$slots{$slot}{'ip'} | \n");
}
- if (exists($sel{'symb'})) {
+ if (exists($show{'symb'})) {
$colspan++;$r->print("$title | \n");
}
- if (exists($sel{'uniqueperiod'})) {
+ if (exists($show{'uniqueperiod'})) {
$colspan++;$r->print("$unique | \n");
}
$colspan++;$r->print("$ids | \n \n");
- if (exists($sel{'proctor'})) {
+ if (exists($show{'proctor'})) {
$r->print(<
$proctors |
@@ -825,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");
}
@@ -863,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 '';
}
@@ -872,6 +957,13 @@ sub csv_upload_assign {
sub handler {
my $r=shift;
+ &Apache::loncommon::content_type($r,'text/html');
+ &Apache::loncommon::no_cache($r);
+ if ($r->header_only()) {
+ $r->send_http_header();
+ return OK;
+ }
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});
|