--- loncom/interface/slotrequest.pm 2006/04/24 23:23:02 1.58
+++ loncom/interface/slotrequest.pm 2006/05/18 20:53:24 1.62
@@ -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.58 2006/04/24 23:23:02 albertel Exp $
+# $Id: slotrequest.pm,v 1.62 2006/05/18 20:53:24 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,7 +41,8 @@ sub fail {
my ($r,$code)=@_;
if ($code eq 'not_valid') {
$r->print('
'.&mt('Unable to understand what resource you wanted to sign up for.').'
');
-
+ } elsif ($code eq 'not_available') {
+ $r->print(''.&mt('No slots are available.').'
');
} elsif ($code eq 'not_allowed') {
$r->print(''.&mt('Not allowed to sign up or change reservations at this time.').'
');
} else {
@@ -243,10 +244,22 @@ sub make_reservation {
my $value=&Apache::lonnet::EXT("resource.0.availablestudent",$symb,
$env{'user.domain'},$env{'user.name'});
&Apache::lonxml::debug("value is $value
");
- if (&network_error($value)) {
+
+ my $use_slots = &Apache::lonnet::EXT("resource.0.useslots");
+ &Apache::lonxml::debug("use_slots is $use_slots
");
+
+ if (&network_error($value) || &network_error($use_slots)) {
return 'error: Unable to determine current status';
}
+ my $parm_symb = $symb;
+ my $parm_level = 1;
+ if ($use_slots eq 'map') {
+ my ($map) = &Apache::lonnet::decode_symb($symb);
+ $parm_symb = &Apache::lonnet::symbread($map);
+ $parm_level = 2;
+ }
+
foreach my $other_slot (split(/:/, $value)) {
if ($other_slot eq $slot_name) {
my %consumed=&Apache::lonnet::dump('slot_reservations', $cdom,
@@ -286,7 +299,7 @@ sub make_reservation {
my %reservation=('name' => $env{'user.name'}.':'.$env{'user.domain'},
'timestamp' => time,
- 'symb' => $symb);
+ 'symb' => $parm_symb);
my $success=&Apache::lonnet::newput('slot_reservations',
{"$slot_name\0$wanted" =>
@@ -300,7 +313,8 @@ sub make_reservation {
}
my $result=&Apache::lonparmset::storeparm_by_symb($symb,
'0_availablestudent',
- 1, $new_value, 'string',
+ $parm_level, $new_value,
+ 'string',
$env{'user.name'},
$env{'user.domain'});
&Apache::lonxml::debug("hrrm $result");
@@ -471,11 +485,22 @@ sub release_reservation {
}
}
+ my $use_slots = &Apache::lonnet::EXT("resource.0.useslots");
+ &Apache::lonxml::debug("use_slots is $use_slots
");
+
+ if (&network_error($use_slots)) {
+ return (0,'error: Unable to determine current status');
+ }
+
+ my $parm_level = 1;
+ if ($use_slots eq 'map') {
+ $parm_level = 2;
+ }
# store new parameter string
my $result=&Apache::lonparmset::storeparm_by_symb($symb,
'0_availablestudent',
- 1, $new_param, 'string',
- $uname,$udom);
+ $parm_level, $new_param,
+ 'string', $uname, $udom);
my $msg;
if ($mgr eq 'F') {
@@ -1122,7 +1147,7 @@ sub show_table {
if (exists($show{'proctor'})) {
$rowspan=2;
@proctors= map {
- my ($uname,$udom)=split(/@/,$_);
+ my ($uname,$udom)=split(/:/,$_);
my $fullname=$name_cache{$_};
if (!defined($fullname)) {
$fullname = &Apache::loncommon::plainname($uname,$udom);
@@ -1526,10 +1551,14 @@ sub handler {
}
} else {
my $symb=&Apache::lonnet::unescape($env{'form.symb'});
+ if (!defined($symb)) {
+ &fail($r,'not_valid');
+ return OK;
+ }
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb);
my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb);
- if ($useslots ne 'resource') {
- &fail($r,'not_valid');
+ if ($useslots ne 'resource' && $useslots ne 'map') {
+ &fail($r,'not_available');
return OK;
}
$env{'request.symb'}=$symb;