--- loncom/interface/slotrequest.pm 2006/04/24 23:23:02 1.58
+++ loncom/interface/slotrequest.pm 2006/05/30 12:46:09 1.63
@@ -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.63 2006/05/30 12:46:09 www 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");
@@ -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') {
@@ -738,7 +765,7 @@ sub show_choices {
$command='get';
}
}
- my $escsymb=&Apache::lonnet::escape($symb);
+ my $escsymb=&escape($symb);
$form=<
@@ -837,11 +864,11 @@ sub remove_link {
undef($udom);
}
- $slotname = &Apache::lonnet::escape($slotname);
- $entry = &Apache::lonnet::escape($entry);
- $uname = &Apache::lonnet::escape($uname);
- $udom = &Apache::lonnet::escape($udom);
- $symb = &Apache::lonnet::escape($symb);
+ $slotname = &escape($slotname);
+ $entry = &escape($entry);
+ $uname = &escape($uname);
+ $udom = &escape($udom);
+ $symb = &escape($symb);
return <<"END_LINK";