version 1.35, 2005/11/21 21:20:06
|
version 1.42, 2006/02/03 18:53:08
|
Line 47 sub fail {
|
Line 47 sub fail {
|
$r->print('<p>'.&mt('Failed.').'</p>'); |
$r->print('<p>'.&mt('Failed.').'</p>'); |
} |
} |
|
|
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&return_link($r); |
&mt('Return to last resource').'</a></p>'); |
|
&end_page($r); |
&end_page($r); |
} |
} |
|
|
Line 89 sub get_reservation_ids {
|
Line 88 sub get_reservation_ids {
|
|
|
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
"^$slot_name\0"); |
"^$slot_name\0"); |
|
if (&network_error(%consumed)) { |
|
return 'error: Unable to determine current status'; |
|
} |
my ($tmp)=%consumed; |
my ($tmp)=%consumed; |
if ($tmp=~/^error: 2 / ) { |
if ($tmp=~/^error: 2 / ) { |
return 0; |
return 0; |
Line 124 sub check_for_reservation {
|
Line 125 sub check_for_reservation {
|
my ($cnum,$cdom)=&get_course(); |
my ($cnum,$cdom)=&get_course(); |
my %slots=&Apache::lonnet::get('slots', [@slots], $cdom, $cnum); |
my %slots=&Apache::lonnet::get('slots', [@slots], $cdom, $cnum); |
|
|
|
if (&network_error($student) || &network_error($course) || |
|
&network_error(%slots)) { |
|
return 'error: Unable to determine current status'; |
|
} |
foreach my $slot_name (@slots) { |
foreach my $slot_name (@slots) { |
next if (!defined($slots{$slot_name}) || |
next if (!defined($slots{$slot_name}) || |
!ref($slots{$slot_name})); |
!ref($slots{$slot_name})); |
Line 148 sub check_for_conflict {
|
Line 153 sub check_for_conflict {
|
my @slots = (split(/:/,$student), split(/:/, $course)); |
my @slots = (split(/:/,$student), split(/:/, $course)); |
my ($cnum,$cdom)=&get_course(); |
my ($cnum,$cdom)=&get_course(); |
my %slots=&Apache::lonnet::get('slots', [@slots], $cdom, $cnum); |
my %slots=&Apache::lonnet::get('slots', [@slots], $cdom, $cnum); |
|
|
|
if (&network_error($student) || &network_error($course) || |
|
&network_error(%slots)) { |
|
return 'error: Unable to determine current status'; |
|
} |
foreach my $slot_name (@slots) { |
foreach my $slot_name (@slots) { |
next if (!defined($slots{$slot_name}) || |
next if (!defined($slots{$slot_name}) || |
!ref($slots{$slot_name})); |
!ref($slots{$slot_name})); |
Line 163 sub check_for_conflict {
|
Line 173 sub check_for_conflict {
|
|
|
} |
} |
|
|
|
sub network_error { |
|
my ($result) = @_; |
|
if ($result =~ /^(con_lost|no_such_host|error: [^2])/) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
sub make_reservation { |
sub make_reservation { |
my ($slot_name,$slot,$symb)=@_; |
my ($slot_name,$slot,$symb)=@_; |
|
|
Line 171 sub make_reservation {
|
Line 189 sub make_reservation {
|
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb, |
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb, |
$env{'user.domain'},$env{'user.name'}); |
$env{'user.domain'},$env{'user.name'}); |
&Apache::lonxml::debug("value is $value<br />"); |
&Apache::lonxml::debug("value is $value<br />"); |
|
if (&network_error($value)) { |
|
return 'error: Unable to determine current status'; |
|
} |
|
|
foreach my $other_slot (split(/:/, $value)) { |
foreach my $other_slot (split(/:/, $value)) { |
if ($other_slot eq $slot_name) { |
if ($other_slot eq $slot_name) { |
my %consumed=&Apache::lonnet::dump('slot_reservations', $cdom, |
my %consumed=&Apache::lonnet::dump('slot_reservations', $cdom, |
$cnum, "^$slot_name\0"); |
$cnum, "^$slot_name\0"); |
|
if (&network_error($value)) { |
|
return 'error: Unable to determine current status'; |
|
} |
my $me=$env{'user.name'}.'@'.$env{'user.domain'}; |
my $me=$env{'user.name'}.'@'.$env{'user.domain'}; |
foreach my $key (keys(%consumed)) { |
foreach my $key (keys(%consumed)) { |
if ($consumed{$key}->{'name'} eq $me) { |
if ($consumed{$key}->{'name'} eq $me) { |
Line 190 sub make_reservation {
|
Line 214 sub make_reservation {
|
if (!defined($max)) { $max=99999; } |
if (!defined($max)) { $max=99999; } |
|
|
my (@ids)=&get_reservation_ids($slot_name); |
my (@ids)=&get_reservation_ids($slot_name); |
|
if (&network_error(@ids)) { |
|
return 'error: Unable to determine current status'; |
|
} |
my $last=0; |
my $last=0; |
foreach my $id (@ids) { |
foreach my $id (@ids) { |
my $num=(split('\0',$id))[1]; |
my $num=(split('\0',$id))[1]; |
Line 275 sub release_slot {
|
Line 301 sub release_slot {
|
&& defined($env{'form.symb'})) { |
&& defined($env{'form.symb'})) { |
$symb = $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("<p>Not allowed to release Reservation: $description, as it has already ended.</p>"); |
|
&return_link($r); |
|
return 0; |
|
} |
|
} |
# get parameter string, check for existance, rebuild string with the slot |
# get parameter string, check for existance, rebuild string with the slot |
my @slots = split(/:/,&Apache::lonnet::EXT("resource.0.availablestudent", |
my @slots = split(/:/,&Apache::lonnet::EXT("resource.0.availablestudent", |
$symb,$udom,$uname)); |
$symb,$udom,$uname)); |
Line 302 sub release_slot {
|
Line 337 sub release_slot {
|
'0_availablestudent', |
'0_availablestudent', |
1, $new_param, 'string', |
1, $new_param, 'string', |
$uname,$udom); |
$uname,$udom); |
my %slot=&Apache::lonnet::get_slot($slot_name); |
|
my $description=&get_description($env{'form.slotname'},\%slot); |
my $description=&get_description($env{'form.slotname'},\%slot); |
$r->print("<p>Released Reservation: $description</p>"); |
$r->print("<p>Released Reservation: $description</p>"); |
if ($mgr eq 'F') { |
if ($mgr eq 'F') { |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
&mt('Return to slot list').'</a></p>'); |
&mt('Return to slot list').'</a></p>'); |
} |
} |
if (!$inhibit_return_link) { |
if (!$inhibit_return_link) { &return_link($r); } |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
} |
|
return 1; |
return 1; |
} |
} |
|
|
Line 325 sub delete_slot {
|
Line 356 sub delete_slot {
|
my ($cnum,$cdom)=&get_course(); |
my ($cnum,$cdom)=&get_course(); |
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
"^$slot_name\0"); |
"^$slot_name\0"); |
|
my ($tmp) = %consumed; |
|
if ($tmp =~ /error: 2/) { undef(%consumed); } |
|
|
if (%slot && !%consumed) { |
if (%slot && !%consumed) { |
$slot{'type'} = 'deleted'; |
$slot{'type'} = 'deleted'; |
Line 344 sub delete_slot {
|
Line 377 sub delete_slot {
|
} |
} |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
$r->print('<p><a href="/adm/slotrequest?command=showslots">'. |
&mt('Return to slot list').'</a></p>'); |
&mt('Return to slot list').'</a></p>'); |
|
&return_link($r); |
|
} |
|
|
|
sub return_link { |
|
my ($r) = @_; |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&mt('Return to last resource').'</a></p>'); |
&mt('Return to last resource').'</a></p>'); |
} |
} |
Line 352 sub get_slot {
|
Line 390 sub get_slot {
|
my ($r,$symb)=@_; |
my ($r,$symb)=@_; |
|
|
my $slot_name=&check_for_conflict($symb,$env{'form.slotname'}); |
my $slot_name=&check_for_conflict($symb,$env{'form.slotname'}); |
|
|
|
if ($slot_name =~ /^error: (.*)/) { |
|
$r->print("<p>An error occured while attempting to make a reservation. ($1)</p>"); |
|
&return_link($r); |
|
return; |
|
} |
if ($slot_name) { |
if ($slot_name) { |
my %slot=&Apache::lonnet::get_slot($slot_name); |
my %slot=&Apache::lonnet::get_slot($slot_name); |
my $description1=&get_description($slot_name,\%slot); |
my $description1=&get_description($slot_name,\%slot); |
Line 372 STUFF
|
Line 416 STUFF
|
STUFF |
STUFF |
$r->print(' your reservation from <b>'.$description1.'</b> to <b>'. |
$r->print(' your reservation from <b>'.$description1.'</b> to <b>'. |
$description2. |
$description2. |
'</b> <br />or <a href="/adm/flip?postdata=return:">'. |
'</b> <br />or </p>'); |
&mt('Return to last resource').'</a></p>'); |
&return_link($r); |
$r->print(<<STUFF); |
$r->print(<<STUFF); |
</form> |
</form> |
STUFF |
STUFF |
} else { |
} else { |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
&return_link($r); |
&mt('Return to last resource').'</a></p>'); |
|
} |
} |
return; |
return; |
} |
} |
Line 388 STUFF
|
Line 431 STUFF
|
\%slot,$symb); |
\%slot,$symb); |
my $description=&get_description($env{'form.slotname'},\%slot); |
my $description=&get_description($env{'form.slotname'},\%slot); |
if (defined($reserved)) { |
if (defined($reserved)) { |
if ($reserved > -1) { |
if ($slot_name =~ /^error: (.*)/) { |
|
$r->print("<p>An error occured while attempting to make a reservation. ($1)</p>"); |
|
} elsif ($reserved > -1) { |
$r->print("<p>Success: $description</p>"); |
$r->print("<p>Success: $description</p>"); |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
return; |
|
} elsif ($reserved < 0) { |
} elsif ($reserved < 0) { |
$r->print("<p>Already reserved: $description</p>"); |
$r->print("<p>Already reserved: $description</p>"); |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
|
return; |
|
} |
} |
|
&return_link($r); |
|
return; |
} |
} |
|
|
my %lt=('request'=>"Availibility list", |
my %lt=('request'=>"Availibility list", |
Line 425 or
|
Line 466 or
|
</p> |
</p> |
or |
or |
STUFF |
STUFF |
$r->print('<p><a href="/adm/flip?postdata=return:">'. |
|
&mt('Return to last resource').'</a></p>'); |
&return_link($r); |
return; |
return; |
} |
} |
|
|
Line 626 sub show_table {
|
Line 667 sub show_table {
|
'endtime' => 'End Time', |
'endtime' => 'End Time', |
'startreserve' => 'Time students can start reserving', |
'startreserve' => 'Time students can start reserving', |
'secret' => 'Secret Word', |
'secret' => 'Secret Word', |
'maxspace' => 'Maxium # of students', |
'maxspace' => 'Maximum # of students', |
'ip' => 'IP or DNS restrictions', |
'ip' => 'IP or DNS restrictions', |
'symb' => 'Resource slot is restricted to.', |
'symb' => 'Resource slot is restricted to.', |
'uniqueperiod' => 'Period of time slot is unique', |
'uniqueperiod' => 'Period of time slot is unique', |
Line 732 sub show_table {
|
Line 773 sub show_table {
|
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, |
"^$slot\0"); |
"^$slot\0"); |
my $ids; |
my $ids; |
foreach my $entry (sort(keys(%consumed))) { |
|
my (undef,$id)=split("\0",$entry); |
my ($tmp)=%consumed; |
my ($uname,$udom) = split('@',$consumed{$entry}{'name'}); |
if ($tmp !~ /^error: /) { |
my $name = &Apache::loncommon::plainname($uname,$udom); |
foreach my $entry (sort(keys(%consumed))) { |
$ids.= '<nobr>'.$name.&remove_link($slot,$entry,$uname,$udom, |
my (undef,$id)=split("\0",$entry); |
$consumed{$entry}{'symb'}) |
my ($uname,$udom) = split('@',$consumed{$entry}{'name'}); |
.'</nobr><br />'; |
my $name = &Apache::loncommon::plainname($uname,$udom); |
|
$ids.= '<nobr>'.$name.&remove_link($slot,$entry,$uname,$udom, |
|
$consumed{$entry}{'symb'}) |
|
.'</nobr><br />'; |
|
} |
} |
} |
|
|
my $start=($slots{$slot}->{'starttime'}? |
my $start=($slots{$slot}->{'starttime'}? |
Line 1129 sub handler {
|
Line 1174 sub handler {
|
} else { |
} else { |
my $symb=&Apache::lonnet::unescape($env{'form.symb'}); |
my $symb=&Apache::lonnet::unescape($env{'form.symb'}); |
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb); |
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb); |
if ($res !~ /\.task$/) { |
my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb); |
|
if ($useslots ne 'resource') { |
&fail($r,'not_valid'); |
&fail($r,'not_valid'); |
return OK; |
return OK; |
} |
} |
$env{'request.symb'}=$symb; |
$env{'request.symb'}=$symb; |
my ($status) = &Apache::lonhomework::check_task_access('0'); |
my $type = ($res =~ /\.task$/) ? 'Task' |
|
: 'problem'; |
|
my ($status) = &Apache::lonhomework::check_slot_access('0',$type); |
if ($status eq 'CAN_ANSWER' || |
if ($status eq 'CAN_ANSWER' || |
$status eq 'NEEDS_CHECKIN' || |
$status eq 'NEEDS_CHECKIN' || |
$status eq 'WAITING_FOR_GRADE') { |
$status eq 'WAITING_FOR_GRADE') { |
Line 1148 sub handler {
|
Line 1196 sub handler {
|
} elsif ($env{'form.command'} eq 'get') { |
} elsif ($env{'form.command'} eq 'get') { |
&get_slot($r,$symb); |
&get_slot($r,$symb); |
} elsif ($env{'form.command'} eq 'change') { |
} elsif ($env{'form.command'} eq 'change') { |
&release_slot($r,$symb,$env{'form.releaseslot'},1); |
if (&release_slot($r,$symb,$env{'form.releaseslot'},1)) { |
&get_slot($r,$symb); |
&get_slot($r,$symb); |
|
} |
} else { |
} else { |
$r->print("<p>Unknown command: ".$env{'form.command'}."</p>"); |
$r->print("<p>Unknown command: ".$env{'form.command'}."</p>"); |
} |
} |