--- loncom/interface/slotrequest.pm 2006/02/26 19:40:14 1.48 +++ loncom/interface/slotrequest.pm 2006/03/07 16:15:48 1.49 @@ -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.48 2006/02/26 19:40:14 albertel Exp $ +# $Id: slotrequest.pm,v 1.49 2006/03/07 16:15:48 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -529,23 +529,41 @@ STUFF sub allowed_slot { my ($slot_name,$slot,$symb,$slots,$consumed_uniqueperiods)=@_; + #already started if ($slot->{'starttime'} < time) { # all open slot to be schedulable #return 0; } &Apache::lonxml::debug("$slot_name starttime good"); + #already ended if ($slot->{'endtime'} < time) { return 0; } &Apache::lonxml::debug("$slot_name endtime good"); + # not allowed to pick this one if (defined($slot->{'type'}) && $slot->{'type'} ne 'schedulable_student') { return 0; } &Apache::lonxml::debug("$slot_name type good"); + + # its for a different set of users + if (defined($slot->{'allowedsection'})) { + + return 0; + } + &Apache::lonxml::debug("$slot_name type good"); + + # its for a different set of users + if (defined($slot->{'allowedusers'})) { + + return 0; + } + &Apache::lonxml::debug("$slot_name type good"); + # not allowed for this resource if (defined($slot->{'symb'}) && $slot->{'symb'} ne $symb) { @@ -738,22 +756,25 @@ sub show_table { &Apache::grades::reset_perm(); my %show_fields=&Apache::lonlocal::texthash( - 'name' => 'Slot Name', - 'description' => 'Description', - 'type' => 'Type', - 'starttime' => 'Start time', - 'endtime' => 'End Time', - 'startreserve' => 'Time students can start reserving', - 'secret' => 'Secret Word', - 'maxspace' => 'Maximum # of students', - 'ip' => 'IP or DNS restrictions', - 'symb' => 'Resource slot is restricted to.', - 'uniqueperiod' => 'Period of time slot is unique', - 'scheduled' => 'Scheduled Students', - 'proctor' => 'List of proctors'); + 'name' => 'Slot Name', + 'description' => 'Description', + 'type' => 'Type', + 'starttime' => 'Start time', + 'endtime' => 'End Time', + 'startreserve' => 'Time students can start reserving', + 'secret' => 'Secret Word', + 'maxspace' => 'Maximum # of students', + 'ip' => 'IP or DNS restrictions', + 'symb' => 'Resource slot is restricted to.', + 'allowedsections' => 'Sections slot is restricted to.', + 'allowedusers' => 'Users slot is restricted to.', + 'uniqueperiod' => 'Period of time slot is unique', + 'scheduled' => 'Scheduled Students', + 'proctor' => 'List of proctors'); my @show_order=('name','description','type','starttime','endtime', - 'startreserve','secret','maxspace','ip','symb', - 'uniqueperiod','scheduled','proctor'); + 'startreserve','secret','maxspace','ip','symb', + 'allowedsections','allowedusers','uniqueperiod', + 'scheduled','proctor'); my @show = (exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show') : keys(%show_fields); @@ -832,7 +853,7 @@ sub show_table { my %name_cache; my $slotsort = sub { - if ($env{'form.order'}=~/^(type|description|endtime|startreserve|maxspace|ip|symb)$/) { + if ($env{'form.order'}=~/^(type|description|endtime|startreserve|maxspace|ip|symb|allowedsections|allowedusers)$/) { if (lc($slots{$a}->{$env{'form.order'}}) ne lc($slots{$b}->{$env{'form.order'}})) { return (lc($slots{$a}->{$env{'form.order'}}) @@ -911,6 +932,28 @@ sub show_table { $title=''.$title.''; } + my $allowedsections; + if (exists($show{'allowedsections'})) { + $allowedsections = + join(', ',sort(split(/\s*,\s*/, + $slots{$slot}->{'allowedsections'}))); + } + + my @allowedusers; + if (exists($show{'allowedusers'})) { + @allowedusers= map { + my ($uname,$udom)=split(/:/,$_); + my $fullname=$name_cache{$_}; + if (!defined($fullname)) { + $fullname = &Apache::loncommon::plainname($uname,$udom); + $fullname =~s/\s/ /g; + $name_cache{$_} = $fullname; + } + &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); + } (sort(split(/\s*,\s*/,$slots{$slot}->{'allowedusers'}))); + } + my $allowedusers=join(', ',@allowedusers); + my @proctors; my $rowspan=1; my $colspan=1; @@ -920,7 +963,6 @@ sub show_table { my ($uname,$udom)=split(/@/,$_); my $fullname=$name_cache{$_}; if (!defined($fullname)) { - &Apache::lonnet::logthis("Gettign $uname $udom"); $fullname = &Apache::loncommon::plainname($uname,$udom); $fullname =~s/\s/ /g; $name_cache{$_} = $fullname; @@ -970,8 +1012,11 @@ DELETELINK if (exists($show{'symb'})) { $colspan++;$r->print("$title\n"); } - if (exists($show{'uniqueperiod'})) { - $colspan++;$r->print("$unique\n"); + if (exists($show{'allowedsections'})) { + $colspan++;$r->print("$allowedsections\n"); + } + if (exists($show{'allowedusers'})) { + $colspan++;$r->print("$allowedusers\n"); } if (exists($show{'scheduled'})) { $colspan++;$r->print("$ids\n\n"); @@ -1156,7 +1201,10 @@ sub csvupload_fields { ['maxspace','Maximum number of reservations'], ['symb','Resource Restriction'], ['uniqueperiod','Date range of slot exclusion'], - ['secret','Secret word proctor uses to validate']); + ['secret','Secret word proctor uses to validate'], + ['allowedsections','Sections slot is restricted to'], + ['allowedusers','Users slot is restricted to'], + ); } sub csv_upload_assign {