--- loncom/interface/slotrequest.pm 2005/08/09 15:38:13 1.7 +++ loncom/interface/slotrequest.pm 2005/08/15 19:54:26 1.8 @@ -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.7 2005/08/09 15:38:13 albertel Exp $ +# $Id: slotrequest.pm,v 1.8 2005/08/15 19:54:26 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,9 +38,14 @@ use Apache::lonnet; sub fail { my ($r,$code)=@_; if ($code eq 'not_valid') { - $r->print('

'.&mt('Unable to understand what resource you wanted to sign up for.').'

'.$env{'form.symb'}); + $r->print('

'.&mt('Unable to understand what resource you wanted to sign up for.').'

'); + } elsif ($code eq 'not_allowed') { + $r->print('

'.&mt('Not allowed to sign up or change reservations at this time.').'

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

'.&mt('Failed.').'

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

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

'); &end_page($r); @@ -486,6 +491,7 @@ STUFF sub handler { my $r=shift; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); &start_page($r); my $symb=&Apache::lonnet::unescape($env{'form.symb'}); my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb); @@ -493,8 +499,16 @@ sub handler { &fail($r,'not_valid'); return OK; } - - if ($env{'form.command'} eq 'showslots') { + $env{'request.symb'}=$symb; + my ($status) = &Apache::lonhomework::check_task_access('0'); + if ($status eq 'CAN_ANSWER' || + $status eq 'NEEDS_CHECKIN' || + $status eq 'WAITING_FOR_GRADE') { + &fail($r,'not_allowed'); + return OK; + } + my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}); + if ($env{'form.command'} eq 'showslots' && $vgr eq 'F') { &show_table($r,$symb); } elsif ($env{'form.requestattempt'}) { &show_choices($r,$symb); @@ -505,7 +519,13 @@ sub handler { } elsif ($env{'form.command'} eq 'change') { &release_slot($r,$symb,$env{'form.releaseslot'},1); &get_slot($r,$symb); + } else { + $r->print("

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

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

1'.$symb.'

'); + $r->print('

2'.&Apache::lonnet::symbread().'

'); + $r->print(&check_for_reservation($symb)); + $r->print( &Apache::lonhomework::check_task_access('0')); &end_page($r); return OK; }