--- loncom/interface/slotrequest.pm 2007/04/10 23:26:49 1.74 +++ loncom/interface/slotrequest.pm 2007/04/10 23:28:20 1.75 @@ -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.74 2007/04/10 23:26:49 albertel Exp $ +# $Id: slotrequest.pm,v 1.75 2007/04/10 23:28:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -548,7 +548,7 @@ sub return_link { } sub get_slot { - my ($r,$symb)=@_; + my ($r,$symb,$conflictable_slot,$inhibit_return_link)=@_; my %slot=&Apache::lonnet::get_slot($env{'form.slotname'}); my $slot_name=&check_for_conflict($symb,$env{'form.slotname'},\%slot); @@ -556,9 +556,9 @@ sub get_slot { if ($slot_name =~ /^error: (.*)/) { $r->print("

An error occured while attempting to make a reservation. ($1)

"); &return_link($r); - return; + return 0; } - if ($slot_name) { + if ($slot_name && $slot_name ne $conflictable_slot) { my %slot=&Apache::lonnet::get_slot($slot_name); my $description1=&get_description($slot_name,\%slot); %slot=&Apache::lonnet::get_slot($env{'form.slotname'}); @@ -586,28 +586,35 @@ STUFF } else { &return_link($r); } - return; + return 0; } my $reserved=&make_reservation($env{'form.slotname'}, \%slot,$symb); my $description=&get_description($env{'form.slotname'},\%slot); if (defined($reserved)) { + my $retvalue = 0; if ($slot_name =~ /^error: (.*)/) { $r->print("

An error occured while attempting to make a reservation. ($1)

"); } elsif ($reserved > -1) { $r->print("

Success: $description

"); + $retvalue = 1; } elsif ($reserved < 0) { $r->print("

Already reserved: $description

"); } - &return_link($r); - return; + if (!$inhibit_return_link) { &return_link($r); } + return 1; } my %lt=('request'=>"Availibility list", 'try' =>'Try again'); %lt=&Apache::lonlocal::texthash(%lt); + my $extra_input; + if ($conflictable_slot) { + $extra_input=''; + } + $r->print(< Failed to reserve a spot for $description.

@@ -615,7 +622,8 @@ STUFF - + + $extra_input ?

@@ -629,8 +637,8 @@ or or STUFF - &return_link($r); - return; + if (!$inhibit_return_link) { &return_link($r); } + return 0; } sub allowed_slot { @@ -1624,8 +1632,8 @@ sub handler { } elsif ($env{'form.command'} eq 'get') { &get_slot($r,$symb); } elsif ($env{'form.command'} eq 'change') { - if (&release_slot($r,$symb,$env{'form.releaseslot'},1)) { - &get_slot($r,$symb); + if (&get_slot($r,$symb,$env{'form.releaseslot'},1)) { + &release_slot($r,$symb,$env{'form.releaseslot'}); } } else { $r->print("

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

");