--- loncom/interface/slotrequest.pm 2005/10/07 20:00:20 1.20 +++ loncom/interface/slotrequest.pm 2005/10/14 19:30:36 1.21 @@ -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.20 2005/10/07 20:00:20 albertel Exp $ +# $Id: slotrequest.pm,v 1.21 2005/10/14 19:30:36 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -466,22 +466,43 @@ sub show_table { '); } + 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.'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; @@ -501,16 +522,19 @@ sub show_table { $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','. localtime($slots{$slot}{'uniqueperiod'}[1]); } - my @proctors = map { my ($uname,$udom)=split(/@/,$_); - my $fullname=&Apache::loncommon::plainname($uname,$udom); - $fullname=~s/\s/ /g; + 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=(< @@ -521,7 +545,7 @@ sub show_table { EDITFORM $r->print(< - $edit + $edit $slot $slots{$slot}->{'type'} $description @@ -529,9 +553,11 @@ EDITFORM $end $slots{$slot}->{'maxspace'} $ids - $proctors $unique + + $proctors + STUFF } $r->print('');