--- loncom/interface/slotrequest.pm 2008/12/11 14:55:15 1.84 +++ loncom/interface/slotrequest.pm 2008/12/21 04:14:39 1.85 @@ -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.84 2008/12/11 14:55:15 bisitz Exp $ +# $Id: slotrequest.pm,v 1.85 2008/12/21 04:14:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -165,6 +165,9 @@ sub check_for_reservation { sub get_consumed_uniqueperiods { my ($slots) = @_; my $navmap=Apache::lonnavmaps::navmap->new; + if (!defined($navmap)) { + return 'error: Unable to determine current status'; + } my @problems = $navmap->retrieveResources(undef, sub { $_[0]->is_problem() },1,0); my %used_slots; @@ -214,9 +217,13 @@ sub check_for_conflict { if (!ref($consumed_uniqueperiods)) { $consumed_uniqueperiods = &get_consumed_uniqueperiods($slots); - if (&Apache::lonnet::error(%$consumed_uniqueperiods)) { - return 'error: Unable to determine current status'; - } + if (ref($consumed_uniqueperiods) eq 'HASH') { + if (&Apache::lonnet::error(%$consumed_uniqueperiods)) { + return 'error: Unable to determine current status'; + } + } else { + return 'error: Unable to determine current status'; + } } my ($new_uniq_start,$new_uniq_end) = @{$new_slot->{'uniqueperiod'}}; @@ -229,7 +236,6 @@ sub check_for_conflict { } } return undef; - } sub make_reservation { @@ -413,7 +419,11 @@ sub release_all_slot { my ($result,$msg) = &release_reservation($slot_name,$uname,$udom, $consumed{$entry}{'symb'},$mgr); - $r->print("

$msg

"); + if (!$result) { + $r->print('

'.&mt($msg).'

'); + } else { + $r->print("

$msg

"); + } $r->rflush(); } $r->print('

'. @@ -439,7 +449,11 @@ sub release_slot { my ($result,$msg) = &release_reservation($slot_name,$uname,$udom,$symb,$mgr); - $r->print("

$msg

"); + if (!$result) { + $r->print('

'.&mt($msg).'

'); + } else { + $r->print("

$msg

"); + } if ($mgr eq 'F') { $r->print('

'. @@ -464,6 +478,9 @@ sub release_reservation { # if the reservation symb is for a map get a resource in that map # to check slot parameters on my $navmap=Apache::lonnavmaps::navmap->new; + if (!defined($navmap)) { + return (0,'error: Unable to determine current status'); + } my $passed_resource = $navmap->getBySymb($symb); if ($passed_resource->is_map()) { my ($a_resource) = @@ -737,7 +754,9 @@ sub allowed_slot { my $conflict = &check_for_conflict($symb,$slot_name,$slot,$slots, $consumed_uniqueperiods); - if ($conflict) { + if ($conflict =~ /^error: /) { + return 0; + } else { if ($slots->{$conflict}{'starttime'} < time) { return 0; } @@ -763,10 +782,29 @@ sub show_choices { my ($cnum,$cdom)=&get_course(); my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); my $consumed_uniqueperiods = &get_consumed_uniqueperiods(\%slots); + if (ref($consumed_uniqueperiods) eq 'HASH') { + if (&Apache::lonnet::error(%$consumed_uniqueperiods)) { + $r->print(''. + &mt('An error occurred determining slot availability'). + ''); + return; + } + } elsif ($consumed_uniqueperiods =~ /^error: /) { + $r->print(''. + &mt('An error occurred determining slot availability'). + ''); + return; + } my $available; - $r->print(''); &Apache::lonxml::debug("Checking Slots"); my @got_slots=&check_for_reservation($symb,'allslots'); + if ($got_slots[0] =~ /^error: /) { + $r->print(''. + &mt('An error occurred determining slot availability'). + ''); + return; + } + $r->print('
'); foreach my $slot (sort { return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'} } (keys(%slots))) { @@ -791,10 +829,16 @@ sub show_choices { my $conflict = &check_for_conflict($symb,$slot,$slots{$slot}, \%slots, $consumed_uniqueperiods); - if ($conflict) { - $text=&mt('Change Reservation'); - $command='get'; - } + if ($conflict) { + if ($conflict =~ /^error: /) { + $r->print(''); + } else { + $text=&mt('Change Reservation'); + $command='get'; + } + } } my $escsymb=&escape($symb); $form=<
' + .&mt('Slot: [_1] has unknown status.',$description) + .'