--- loncom/interface/slotrequest.pm 2005/11/21 22:16:24 1.36 +++ loncom/interface/slotrequest.pm 2006/02/03 17:07:20 1.39 @@ -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.36 2005/11/21 22:16:24 albertel Exp $ +# $Id: slotrequest.pm,v 1.39 2006/02/03 17:07:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -275,7 +275,17 @@ sub release_slot { && defined($env{'form.symb'})) { $symb = $env{'form.symb'}; } + my %slot=&Apache::lonnet::get_slot($slot_name); + my $description=&get_description($env{'form.slotname'},\%slot); + if ($mgr ne 'F') { + if ($slot{$slot_name}{'starttime'} < time) { + $r->print("

Not allowed to release Reservation: $description, as it has already ended.

"); + $r->print('

'. + &mt('Return to last resource').'

'); + return 0; + } + } # get parameter string, check for existance, rebuild string with the slot my @slots = split(/:/,&Apache::lonnet::EXT("resource.0.availablestudent", $symb,$udom,$uname)); @@ -302,7 +312,6 @@ sub release_slot { '0_availablestudent', 1, $new_param, 'string', $uname,$udom); - my %slot=&Apache::lonnet::get_slot($slot_name); my $description=&get_description($env{'form.slotname'},\%slot); $r->print("

Released Reservation: $description

"); if ($mgr eq 'F') { @@ -325,6 +334,8 @@ sub delete_slot { my ($cnum,$cdom)=&get_course(); my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, "^$slot_name\0"); + my ($tmp) = %consumed; + if ($tmp =~ /error: 2/) { undef(%consumed); } if (%slot && !%consumed) { $slot{'type'} = 'deleted'; @@ -626,7 +637,7 @@ sub show_table { 'endtime' => 'End Time', 'startreserve' => 'Time students can start reserving', 'secret' => 'Secret Word', - 'maxspace' => 'Maxium # of students', + 'maxspace' => 'Maximum # of students', 'ip' => 'IP or DNS restrictions', 'symb' => 'Resource slot is restricted to.', 'uniqueperiod' => 'Period of time slot is unique', @@ -732,13 +743,17 @@ sub show_table { my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, "^$slot\0"); my $ids; - foreach my $entry (sort(keys(%consumed))) { - my (undef,$id)=split("\0",$entry); - my ($uname,$udom) = split('@',$consumed{$entry}{'name'}); - my $name = &Apache::loncommon::plainname($uname,$udom); - $ids.= ''.$name.&remove_link($slot,$entry,$uname,$udom, - $consumed{$entry}{'symb'}) - .'
'; + + my ($tmp)=%consumed; + if ($tmp !~ /^error: /) { + foreach my $entry (sort(keys(%consumed))) { + my (undef,$id)=split("\0",$entry); + my ($uname,$udom) = split('@',$consumed{$entry}{'name'}); + my $name = &Apache::loncommon::plainname($uname,$udom); + $ids.= ''.$name.&remove_link($slot,$entry,$uname,$udom, + $consumed{$entry}{'symb'}) + .'
'; + } } my $start=($slots{$slot}->{'starttime'}? @@ -1151,8 +1166,9 @@ sub handler { } elsif ($env{'form.command'} eq 'get') { &get_slot($r,$symb); } elsif ($env{'form.command'} eq 'change') { - &release_slot($r,$symb,$env{'form.releaseslot'},1); - &get_slot($r,$symb); + if (&release_slot($r,$symb,$env{'form.releaseslot'},1)) { + &get_slot($r,$symb); + } } else { $r->print("

Unknown command: ".$env{'form.command'}."

"); }