--- loncom/interface/slotrequest.pm 2006/04/24 23:23:02 1.58
+++ loncom/interface/slotrequest.pm 2006/06/16 19:49:00 1.64
@@ -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.64 2006/06/16 19:49:00 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,12 +36,15 @@ use Apache::lonlocal;
use Apache::lonnet;
use Apache::lonnavmaps();
use Date::Manip;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
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 +246,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 +301,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 +315,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");
@@ -369,13 +385,13 @@ sub remove_registration_confirmation {
'no' => 'No',);
$r->print(<<"END_CONFIRM");
$msg
-
-
@@ -471,11 +487,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') {
@@ -544,7 +571,7 @@ sub get_slot {
$r->print("Already have a reservation: $description1
");
if ($slot_name ne $env{'form.slotname'}) {
$r->print(<
+