--- loncom/interface/slotrequest.pm 2005/10/07 19:44:06 1.19 +++ loncom/interface/slotrequest.pm 2005/11/02 22:46:12 1.28 @@ -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.19 2005/10/07 19:44:06 albertel Exp $ +# $Id: slotrequest.pm,v 1.28 2005/11/02 22:46:12 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -53,11 +53,10 @@ sub fail { } sub start_page { - my ($r)=@_; + my ($r,$title)=@_; my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.''. - &mt('Request another Worktime').''); - $r->print(&Apache::loncommon::bodytag('Requesting another Worktime')); + $r->print($html.''.&mt($title).''); + $r->print(&Apache::loncommon::bodytag($title)); } sub end_page { @@ -465,23 +464,53 @@ sub show_table { '); + $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.'startreserve">Time Students Can Start Reserving + '.$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|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 'name') { + if (lc($a) cmp lc($b)) { + return lc($a) cmp lc($b); + } + } 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; @@ -494,34 +523,55 @@ sub show_table { my (undef,$id)=split("\0",$entry); $ids.= $id.'-> '.$consumed{$entry}->{'name'}.'
'; } - my $start=localtime($slots{$slot}->{'starttime'}); - my $end=localtime($slots{$slot}->{'endtime'}); + my $start=($slots{$slot}->{'starttime'}? + &Apache::lonlocal::locallocaltime($slots{$slot}->{'starttime'}):''); + my $end=($slots{$slot}->{'endtime'}? + &Apache::lonlocal::locallocaltime($slots{$slot}->{'endtime'}):''); + my $start_reserve=($slots{$slot}->{'startreserve'}? + &Apache::lonlocal::locallocaltime($slots{$slot}->{'startreserve'}):''); + my $unique; if (ref($slots{$slot}{'uniqueperiod'})) { $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); + } (sort(split(/\s*,\s*/,$slots{$slot}->{'proctor'}))); + + my $proctors=join(', ',@proctors); my $edit=(< - - +
+
EDITFORM $r->print(< - $edit + $edit $slot $slots{$slot}->{'type'} $description $start $end + $start_reserve + $slots{$slot}->{'secret'} $slots{$slot}->{'maxspace'} $ids - $slots{$slot}->{'proctor'} $unique + + $proctors + STUFF } $r->print(''); @@ -725,6 +775,10 @@ sub csv_upload_assign { if ($entries{$fields{'endtime'}}) { $slot{'endtime'}=&UnixDate($entries{$fields{'endtime'}},"%s"); } + if ($entries{$fields{'startreserve'}}) { + $slot{'startreserve'}= + &UnixDate($entries{$fields{'startreserve'}},"%s"); + } foreach my $key ('ip','proctor','description','maxspace', 'secret','symb') { if ($entries{$fields{$key}}) { @@ -753,9 +807,15 @@ sub handler { my $r=shift; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); - &start_page($r); + my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}); my $mgr=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}); + my $title='Requesting Another Worktime'; + if ($env{'form.command'} =~ /^(showslots|uploadstart|csvuploadmap|csvuploadassign)$/ && $vgr eq 'F') { + $title = 'Managing Slots'; + } + &start_page($r,$title); + if ($env{'form.command'} eq 'showslots' && $vgr eq 'F') { &show_table($r,$mgr); } elsif ($env{'form.command'} eq 'uploadstart' && $mgr eq 'F') { @@ -773,8 +833,6 @@ sub handler { } &csv_upload_map($r); } - } elsif ($env{'form.command'} eq 'editslot' && $mgr eq 'F') { - &show_slot_edit($r); } else { my $symb=&Apache::lonnet::unescape($env{'form.symb'}); my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb);