--- loncom/interface/slotrequest.pm 2005/09/13 07:31:08 1.15 +++ loncom/interface/slotrequest.pm 2005/10/14 20:00:34 1.22 @@ -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.15 2005/09/13 07:31:08 albertel Exp $ +# $Id: slotrequest.pm,v 1.22 2005/10/14 20:00:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -58,7 +58,6 @@ sub start_page { $r->print($html.''. &mt('Request another Worktime').''); $r->print(&Apache::loncommon::bodytag('Requesting another Worktime')); - $r->print('

'.$env{'form.command'}.'

'); } sub end_page { @@ -453,33 +452,58 @@ STUFF } sub show_table { - my ($r,$symb,$mgr)=@_; + my ($r,$mgr)=@_; my ($cnum,$cdom)=&get_course(); my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); + if ( (keys(%slots))[0] =~ /^error: 2 /) { + undef(%slots); + } my $available; if ($mgr eq 'F') { $r->print('
-
'); } + my $linkstart=' - Slot name - Type - Description - Start Time - End Time - Max space - Scheduled Students - Proctors - Unique Period + + '.$linkstart.'name" >Slot name + '.$linkstart.'type" >Type + '.$linkstart.'description">Description + '.$linkstart.'starttime" >Start Time + '.$linkstart.'endtime" >End Time + '.$linkstart.'secret" >Secret + '.$linkstart.'maxspace" >Max space + Scheduled Students + '.$linkstart.'unique" >Unique Period '); - foreach my $slot (sort - { return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'} } - (keys(%slots))) { + my %name_cache; + my $slotsort = sub { + if ($env{'form.order'}=~/^(type|name|description|endtime|maxspace)$/) { + if (lc($slots{$a}->{$env{'form.order'}}) + ne lc($slots{$b}->{$env{'form.order'}})) { + return (lc($slots{$a}->{$env{'form.order'}}) + cmp lc($slots{$b}->{$env{'form.order'}})); + } + } elsif ($env{'form.order'} eq 'unique') { + + if ($slots{$a}->{'uniqueperiod'}[0] + ne $slots{$b}->{'uniqueperiod'}[0]) { + return ($slots{$a}->{'uniqueperiod'}[0] + cmp $slots{$b}->{'uniqueperiod'}[0]); + } + if ($slots{$a}->{'uniqueperiod'}[1] + ne $slots{$b}->{'uniqueperiod'}[1]) { + return ($slots{$a}->{'uniqueperiod'}[1] + cmp $slots{$b}->{'uniqueperiod'}[1]); + } + } + return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'}; + }; + foreach my $slot (sort $slotsort (keys(%slots))) { if (defined($slots{$slot}->{'type'}) && $slots{$slot}->{'type'} ne 'schedulable_student') { #next; @@ -499,26 +523,50 @@ sub show_table { $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','. localtime($slots{$slot}{'uniqueperiod'}[1]); } - + my @proctors = map { + my ($uname,$udom)=split(/@/,$_); + my $fullname=$name_cache{$_}; + if (!defined($fullname)) { + &Apache::lonnet::logthis("Gettign $uname $udom"); + $fullname = &Apache::loncommon::plainname($uname,$udom); + $fullname =~s/\s/ /g; + $name_cache{$_} = $fullname; + } + &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); + } (split(/\s*,\s*/,$slots{$slot}->{'proctor'})); + + my $proctors=join(', ',@proctors); + + my $edit=(< + + + + +EDITFORM $r->print(< + $edit $slot $slots{$slot}->{'type'} $description $start $end + $slots{$slot}->{'secret'} $slots{$slot}->{'maxspace'} $ids - $slots{$slot}->{'proctor'} $unique + + $proctors + STUFF } $r->print(''); } sub upload_start { - my ($r,$symb)=@_; + my ($r)=@_; $r->print(&Apache::grades::checkforfile_js()); my $result.='
'."\n"; $result.=' '. @@ -529,7 +577,6 @@ sub upload_start { my $ignore=&mt('Ignore First Line'); $result.=< - $upfile_select
@@ -542,7 +589,7 @@ ENDUPFORM } sub csvuploadmap_header { - my ($r,$symb,$datatoken,$distotal)= @_; + my ($r,$datatoken,$distotal)= @_; my $javascript; if ($env{'form.upfile_associate'} eq 'reverse') { $javascript=&csvupload_javascript_reverse_associate(); @@ -566,7 +613,6 @@ to this page if the data selected is ins -