--- loncom/interface/slotrequest.pm 2015/09/27 14:21:48 1.129
+++ loncom/interface/slotrequest.pm 2018/07/02 20:34:52 1.139
@@ -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.129 2015/09/27 14:21:48 raeburn Exp $
+# $Id: slotrequest.pm,v 1.139 2018/07/02 20:34:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -465,7 +465,7 @@ sub get_consumed_uniqueperiods {
return 'error: Unable to determine current status';
}
my @problems = $navmap->retrieveResources(undef,
- sub { $_[0]->is_problem() },1,0);
+ sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0);
my %used_slots;
foreach my $problem (@problems) {
my $symb = $problem->symb();
@@ -805,7 +805,7 @@ sub release_reservation {
if ($passed_resource->is_map()) {
my ($a_resource) =
$navmap->retrieveResources($passed_resource,
- sub {$_[0]->is_problem()},0,1);
+ sub {$_[0]->is_problem() || $_[0]->is_tool() },0,1);
$symb = $a_resource->symb();
}
} else {
@@ -841,10 +841,10 @@ sub release_reservation {
action => 'release',
context => $env{'form.context'},
);
- &Apache::lonnet::write_log('slotreservationslog',\%storehash,
- 1,$uname,$udom,$cnum,$cdom);
- &Apache::lonnet::write_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
- 1,$uname,$udom,$uname,$udom);
+ &Apache::lonnet::write_log('course','slotreservationslog',
+ \%storehash,1,$uname,$udom,$cnum,$cdom);
+ &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',
+ \%storehash,1,$uname,$udom,$uname,$udom);
}
}
@@ -938,9 +938,15 @@ sub get_slot {
if ($slot_name && $slot_name ne $conflictable_slot) {
my %slot=&Apache::lonnet::get_slot($slot_name);
my $description1=&get_description($slot_name,\%slot);
+ my $slottype1=$slot{'type'};
%slot=&Apache::lonnet::get_slot($env{'form.slotname'});
my $description2=&get_description($env{'form.slotname'},\%slot);
- if ($slot_name ne $env{'form.slotname'}) {
+ if ($slottype1 eq 'preassigned') {
+ $r->print('
'.&mt('You already have a reservation: "[_1]", assigned by your instructor.',
+ $description1).'
'.
+ ''.&mt('Your instructor must unassign it before you can make a new reservation.').
+ '
');
+ } elsif ($slot_name ne $env{'form.slotname'}) {
$r->print(<
@@ -1114,14 +1120,25 @@ sub allowed_slot {
# not allowed for this resource
if (defined($slot->{'symb'})) {
my $exclude = 1;
- my ($slotmap,$slotid,$sloturl) = &Apache::lonnet::decode_symb($slot->{'symb'});
- if ($sloturl=~/\.(page|sequence)$/) {
- my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
- if (($map ne '') && ($map eq $slotmap)) {
+ my @symbs;
+ if ($slot->{'symb'} =~ /,/) {
+ @symbs = split(/\s*,\s*/,$slot->{'symb'});
+ } else {
+ @symbs = ($slot->{'symb'});
+ }
+ my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
+ foreach my $reqsymb (@symbs) {
+ next if ($reqsymb eq '');
+ my ($slotmap,$slotid,$sloturl) = &Apache::lonnet::decode_symb($reqsymb);
+ if ($sloturl=~/\.(page|sequence)$/) {
+ if (($map ne '') && ($map eq $sloturl)) {
+ $exclude = 0;
+ last;
+ }
+ } elsif ($reqsymb eq $symb) {
$exclude = 0;
+ last;
}
- } elsif ($slot->{'symb'} eq $symb) {
- $exclude = 0;
}
if ($exclude) {
unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) {
@@ -1478,12 +1495,13 @@ sub show_table {
'secret' => 'Secret Word',
'space' => '# of students/max',
'ip' => 'IP or DNS restrictions',
- 'symb' => 'Resource/Map slot is restricted to.',
+ 'symb' => 'Resource(s)/Map(s) 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');
+ 'proctor' => 'List of proctors',
+ 'iptied' => 'Unique IP each student',);
if ($crstype eq 'Community') {
$show_fields{'startreserve'} = &mt('Time members can start reserving');
$show_fields{'endreserve'} = &mt('Time members can no longer reserve');
@@ -1491,7 +1509,7 @@ sub show_table {
}
my @show_order=('name','description','type','starttime','endtime',
'startreserve','endreserve','reservationmsg','secret','space',
- 'ip','symb','allowedsections','allowedusers','uniqueperiod',
+ 'ip','iptied','symb','allowedsections','allowedusers','uniqueperiod',
'scheduled','proctor');
my @show =
(exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
@@ -1590,15 +1608,16 @@ sub show_table {
$r->print('');
$r->print('');
my $linkstart=''.$show_fields{$which}.'');
+ $tableheader .= ''.$linkstart.$which.'">'.$show_fields{$which}.' | ';
}
}
- $r->print(&Apache::loncommon::end_data_table_header_row());
+ $tableheader .= &Apache::loncommon::end_data_table_header_row();
+ my $shownheader = 0;
my %name_cache;
my $slotsort = sub {
@@ -1693,13 +1712,21 @@ sub show_table {
localtime($slots{$slot}{'uniqueperiod'}[1]);
}
- my $title;
+ my @titles;
if (exists($slots{$slot}{'symb'})) {
- my (undef,undef,$res)=
- &Apache::lonnet::decode_symb($slots{$slot}{'symb'});
- $res = &Apache::lonnet::clutter($res);
- $title = &Apache::lonnet::gettitle($slots{$slot}{'symb'});
- $title=''.$title.'';
+ my @symbs;
+ if ($slots{$slot}{'symb'} =~ /,/) {
+ @symbs = split(/\s*,\s*/,$slots{$slot}{'symb'});
+ } else {
+ @symbs = ($slots{$slot}{'symb'});
+ }
+ foreach my $reqsymb (@symbs) {
+ my (undef,undef,$res) =
+ &Apache::lonnet::decode_symb($reqsymb);
+ $res = &Apache::lonnet::clutter($res);
+ my $title = &Apache::lonnet::gettitle($reqsymb);
+ push(@titles,''.$title.'');
+ }
}
my $allowedsections;
@@ -1747,30 +1774,39 @@ sub show_table {
delete => 'Delete',
slotlog => 'History',
);
- my $edit=(<<"EDITLINK");
+ my ($edit,$delete,$showlog,$remove_all);
+ if ($mgr) {
+ $edit=(<<"EDITLINK");
$lt{'edit'}
EDITLINK
- my $delete=(<<"DELETELINK");
+ $delete=(<<"DELETELINK");
$lt{'delete'}
DELETELINK
- my $showlog=(<<"LOGLINK");
+ $remove_all=&remove_link($slot,'remove all').'
';
+
+ if ($ids eq '') {
+ undef($remove_all);
+ } else {
+ undef($delete);
+ }
+ }
+
+ $showlog=(<<"LOGLINK");
$lt{'slotlog'}
LOGLINK
- my $remove_all=&remove_link($slot,'remove all').'
';
-
- if ($ids eq '') {
- undef($remove_all);
- } else {
- undef($delete);
- }
if ($slots{$slot}{'type'} ne 'schedulable_student') {
undef($showlog);
undef($remove_all);
}
+ unless ($shownheader) {
+ $r->print($tableheader);
+ $shownheader = 1;
+ }
+
my $row_start=&Apache::loncommon::start_data_table_row();
my $row_end=&Apache::loncommon::end_data_table_row();
$r->print($row_start.
@@ -1815,8 +1851,18 @@ LOGLINK
if (exists($show{'ip'})) {
$colspan++;$r->print("$slots{$slot}{'ip'} | \n");
}
+ if (exists($show{'iptied'})) {
+ $colspan++;
+ if ($slots{$slot}{'iptied'} eq 'yes') {
+ $r->print(''.&mt('Yes')." | \n");
+ } elsif ($slots{$slot}{'iptied'} eq 'answer') {
+ $r->print(''.&mt('Yes, including post-answer date')." | \n");
+ } else {
+ $r->print(''.&mt('No')." | \n");
+ }
+ }
if (exists($show{'symb'})) {
- $colspan++;$r->print("$title | \n");
+ $colspan++;$r->print("".join(' ',@titles)." | \n");
}
if (exists($show{'allowedsections'})) {
$colspan++;$r->print("$allowedsections | \n");
@@ -1839,12 +1885,18 @@ $row_end
STUFF
}
}
- $r->print(&Apache::loncommon::end_data_table().'');
+ if ($shownheader) {
+ $r->print(&Apache::loncommon::end_data_table());
+ } else {
+ $r->print(''.&mt('No slots meet the criteria for display').'
');
+ }
+ $r->print('');
return;
}
sub manage_reservations {
my ($r,$crstype,$slots,$consumed_uniqueperiods,$allavailable) = @_;
+ my ($cnum,$cdom)=&get_course();
my $navmap = Apache::lonnavmaps::navmap->new();
$r->print(''
.&mt('Instructors may use a reservation system to place restrictions on when and where assignments can be worked on.')
@@ -1876,9 +1928,107 @@ sub manage_reservations {
'');
return;
}
- my (%parent,%shownparent,%container,%container_title,%contents);
- my ($depth,$count,$reservable,$lastcontainer,$rownum,$shown) = (0,0,0,0,0,0);
- my @backgrounds = ("LC_odd_row","LC_even_row");
+ my (%output,%slotinfo,%statusbymap,%repsymbs,%shownmaps);
+ my @possibles = $navmap->retrieveResources(undef,
+ sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0);
+
+ foreach my $resource (@possibles) {
+ my ($useslots) = $resource->slot_control();
+ next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i));
+ my $symb = $resource->symb();
+ my ($slot_status,$date,$slot_name) = $resource->check_for_slot('0');
+ my ($msg,$get_choices,$slotdescription);
+ my $status = $resource->simpleStatus('0');
+ my ($msg,$get_choices,$slotdescription);
+ if ($slot_name ne '') {
+ my %slot=&Apache::lonnet::get_slot($slot_name);
+ $slotdescription=&get_description($slot_name,\%slot);
+ }
+ if ($slot_status == $resource->NOT_IN_A_SLOT) {
+ $msg=&mt('No current reservation.');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->NEEDS_CHECKIN) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.'
'.
+ &mt('Access requires proctor validation.');
+ } elsif ($slot_status == $resource->WAITING_FOR_GRADE) {
+ $msg=&mt('Submitted and currently in grading queue.');
+ } elsif ($slot_status == $resource->CORRECT) {
+ $msg=&mt('Problem is unavailable.');
+ } elsif ($slot_status == $resource->RESERVED) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.'
'.
+ &mt('Problem is currently available.');
+ } elsif ($slot_status == $resource->RESERVED_LOCATION) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.'
'.
+ &mt('Problem is available at a different location.');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->RESERVED_LATER) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.'
'.
+ &mt('Problem will be available later.');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->RESERVABLE) {
+ $msg=&mt('Reservation needed');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->RESERVABLE_LATER) {
+ $msg=&mt('Reservation needed: will be reservable later.');
+ } elsif ($slot_status == $resource->NOTRESERVABLE) {
+ $msg=&mt('Reservation needed: none available.');
+ } elsif ($slot_status == $resource->UNKNOWN) {
+ $msg=&mt('Unable to determine status due to network problems.');
+ } else {
+ if ($status != $resource->OPEN) {
+ $msg = &Apache::lonnavmaps::getDescription($resource,'0');
+ }
+ }
+ $output{$symb}{'msg'} = $msg;
+ if (($status == $resource->OPEN) && ($get_choices)) {
+ $output{$symb}{'hasaction'} = 1;
+ }
+ my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($symb);
+ $mapurl = &Apache::lonnet::clutter($mapurl);
+ unless ($mapurl =~ /default\.sequence$/) {
+ $shownmaps{$mapurl} = 1;
+ my $map = $navmap->getResourceByUrl($mapurl);
+ if (ref($map)) {
+ my @pcs = split(/,/,$map->map_hierarchy());
+ shift(@pcs);
+ shift(@pcs);
+ if (@pcs) {
+ map { $shownmaps{$navmap->getByMapPc($_)->src()} = 1; } reverse(@pcs);
+ }
+ }
+ }
+ if (($useslots eq 'map_map') || ($useslots eq 'map')) {
+ if ($slot_status ne '') {
+ if (ref($statusbymap{$mapurl}{$slot_status}) eq 'ARRAY') {
+ push(@{$statusbymap{$mapurl}{$slot_status}},$symb);
+ } else {
+ $statusbymap{$mapurl}{$slot_status} = [$symb];
+ }
+ }
+ }
+ }
+
+ foreach my $mapurl (keys(%statusbymap)) {
+ if (ref($statusbymap{$mapurl}) eq 'HASH') {
+ if (keys(%{$statusbymap{$mapurl}}) == 1) {
+ my @values = values(%{$statusbymap{$mapurl}});
+ my $repsymb = $values[0][0];
+ if (ref($output{$repsymb}) eq 'HASH') {
+ $output{$mapurl}{'msg'} = $output{$repsymb}{'msg'};
+ $output{$mapurl}{'hasaction'} = $output{$repsymb}{'hasaction'};
+ }
+ $repsymbs{$mapurl} = $repsymb;
+ }
+ }
+ }
+
+ my (%parent,%container,%container_title);
+ my ($depth,$count,$reservable,$currcontainer,$rownum,$mapnum,$shown) = (0,0,0,0,0,0,0);
+ my @backgrounds = ("LC_even_row","LC_odd_row");
my $numcolors = scalar(@backgrounds);
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif");
my $slotheader = '
'.
@@ -1886,254 +2036,125 @@ sub manage_reservations {
'
'.
''."\n";
my $shownheader = 0;
+ my $currmap;
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
- my (@ordered,%output,$mapitem,$got_map_slot,$currmapoutput,$mapnum);
- $mapnum = 0;
- $shown = 0;
while (my $resource = $it->next()) {
if ($resource == $it->BEGIN_MAP()) {
$depth++;
- $parent{$depth} = $lastcontainer;
- }
- if ($resource == $it->END_MAP()) {
- $depth--;
- $lastcontainer = $parent{$depth};
- my %allstatuses;
- foreach my $symb (@ordered) {
- if (ref($output{$symb}) eq 'HASH') {
- if (($output{$symb}{'type'} eq 'map_map') || ($output{$symb}{'type'} eq 'map')) {
- if ($output{$symb}{'slotstatus'} ne '') {
- if (ref($allstatuses{$output{$symb}{'slotstatus'}}) eq 'ARRAY') {
- push(@{$allstatuses{$output{$symb}{'slotstatus'}}},$symb);
+ $parent{$depth} = $currcontainer;
+ if (ref($container{$currcontainer})) {
+ my $currmapres = $container{$currcontainer};
+ my $currmaptitle = $container_title{$currcontainer};
+ $currmap = $currmapres->src();
+ my $currmaptype = 'sequence';
+ if ($currmapres->is_page()) {
+ $currmaptype = 'page';
+ }
+ if ($shownmaps{$currmap}) {
+ $mapnum ++;
+ $rownum ++;
+ $shown ++;
+ if (!$shownheader) {
+ $r->print($slotheader);
+ $shownheader = 1;
+ }
+ my $bgcolor = $backgrounds[$shown % $numcolors];
+ my ($spacers,$icon);
+ my $row = '';
+ if (ref($statusbymap{$currmap}) eq 'HASH') {
+ my ($spacers,$icon) = &show_map_row($depth-1,$location,$currmaptype,$currmaptitle);
+ my $arrowstate = 'open';
+ if (keys(%{$statusbymap{$currmap}}) == 1) {
+ $arrowstate = 'closed';
+ }
+ $row .= ''.$spacers.''.
+ $icon.(' ' x6).' | '."\n";
+ if (ref($output{$currmap}) eq 'HASH') {
+ my $formnum = $mapnum.'_'.$reservable+1;
+ my $class = 'LC_slotmaptext_'.$mapnum;
+ if ($output{$currmap}{'hasaction'}) {
+ $row .= ''.
+ $output{$currmap}{'msg'}.
+ ' | '.
+ &slot_chooser($repsymbs{$currmap},$class,$formnum,
+ $allavailable,$slots,$consumed_uniqueperiods).
+ ' | ';
} else {
- $allstatuses{$output{$symb}{'slotstatus'}} = [$symb];
+ $row .= ''.
+ $output{$currmap}{'msg'}.
+ ' | ';
}
+ $row .= '
'."\n";
+ } else {
+ $row .= ' | '."\n";
}
- }
- }
- }
- if (keys(%allstatuses) == 1) {
- $got_map_slot = 1;
- my $repsymb;
- my @values = values(%allstatuses);
- if (ref($values[0]) eq 'ARRAY') {
- if (ref($output{$values[0][0]}) eq 'HASH') {
- $repsymb = $values[0][0];
- }
- }
- if (($mapitem) && ($repsymb)) {
- my $formnum = $mapnum.'_'.$output{$repsymb}{'reservable'};
- my $class = 'LC_slotmaptext_'.$mapnum;
- if ($output{$repsymb}{'hasaction'}) {
- $mapitem .= ''.
- $output{$repsymb}{'msg'}.
- ' | '.
- &slot_chooser($repsymb,$class,$formnum,$allavailable,$slots,
- $consumed_uniqueperiods).
- ' | ';
-
} else {
- $mapitem .= ''.
- $output{$repsymb}{'msg'}.
- ' | ';
+ my ($spacers,$icon) = &show_map_row($depth,$location,$currmaptype,$currmaptitle);
+ $row .= ''.$spacers.$icon.(' ' x6).' | | '."\n";
}
- }
- my $counter = 0;
- foreach my $symb (@ordered) {
- if (ref($output{$symb}) eq 'HASH') {
- $counter ++;
- my $bgcolor = $backgrounds[($output{$symb}{'shown'} + $counter) % $numcolors];
- $currmapoutput .= $output{$symb}{'header'}.
- ''.
- $output{$symb}{'info'}.
- $output{$symb}{'data'}.'
'."\n";
- }
- }
- } else {
- my $counter = 0;
- foreach my $symb (@ordered) {
- if (ref($output{$symb}) eq 'HASH') {
- $counter ++;
- my $bgcolor = $backgrounds[($output{$symb}{'shown'} + $counter) % $numcolors];
- $currmapoutput .= $output{$symb}{'header'}.
- ''.
- $output{$symb}{'info'}.
- $output{$symb}{'data'}.'
'."\n";
- $shown ++;
- }
- }
- }
- if ($mapitem) {
- if ($got_map_slot) {
- $mapitem =~ s{(print($row);
}
}
- $r->print($mapitem.$currmapoutput);
- @ordered=();
- undef(%output);
- $currmapoutput = '';
- $got_map_slot = '';
- $mapitem = '';
- }
- if (ref($resource)) {
+ } elsif ($resource == $it->END_MAP()) {
+ $depth--;
+ $currcontainer = $parent{$depth};
+ } elsif (ref($resource)) {
my $symb = $resource->symb();
- $contents{$lastcontainer} ++;
- next if (!$resource->is_problem() && !$resource->is_sequence() &&
- !$resource->is_page());
+ next if (!$resource->is_problem() && !$resource->is_tool() &&
+ !$resource->is_sequence() && !$resource->is_page());
$count ++;
if (($resource->is_sequence()) || ($resource->is_page())) {
- $lastcontainer = $count;
- $container{$lastcontainer} = $resource;
- $container_title{$lastcontainer} = $resource->compTitle();
- }
- if ($resource->is_problem()) {
- my ($useslots) = $resource->slot_control();
- next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i));
- push(@ordered,$symb);
- $output{$symb}{type} = $useslots;
- my ($msg,$get_choices,$slotdescription);
- my $title = $resource->compTitle();
- my $status = $resource->simpleStatus('0');
- my ($slot_status,$date,$slot_name) = $resource->check_for_slot('0');
-
- $output{$symb}{'slotstatus'} = $slot_status;
- $output{$symb}{'slotname'} = $slot_name;
- if ($slot_name ne '') {
- my %slot=&Apache::lonnet::get_slot($slot_name);
- $slotdescription=&get_description($slot_name,\%slot);
- }
- if ($slot_status == $resource->NOT_IN_A_SLOT) {
- $msg=&mt('No current reservation.');
- $get_choices = 1;
- } elsif ($slot_status == $resource->NEEDS_CHECKIN) {
- $msg=''.&mt('Reserved:').
- ' '.$slotdescription.'
'.
- &mt('Access requires proctor validation.');
- } elsif ($slot_status == $resource->WAITING_FOR_GRADE) {
- $msg=&mt('Submitted and currently in grading queue.');
- } elsif ($slot_status == $resource->CORRECT) {
- $msg=&mt('Problem is unavailable.');
- } elsif ($slot_status == $resource->RESERVED) {
- $msg=''.&mt('Reserved:').
- ' '.$slotdescription.'
'.
- &mt('Problem is currently available.');
- } elsif ($slot_status == $resource->RESERVED_LOCATION) {
- $msg=''.&mt('Reserved:').
- ' '.$slotdescription.'
'.
- &mt('Problem is available at a different location.');
- $get_choices = 1;
- } elsif ($slot_status == $resource->RESERVED_LATER) {
- $msg=''.&mt('Reserved:').
- ' '.$slotdescription.'
'.
- &mt('Problem will be available later.');
- $get_choices = 1;
- } elsif ($slot_status == $resource->RESERVABLE) {
- $msg=&mt('Reservation needed');
- $get_choices = 1;
- } elsif ($slot_status == $resource->RESERVABLE_LATER) {
- $msg=&mt('Reservation needed: will be reservable later.');
- } elsif ($slot_status == $resource->NOTRESERVABLE) {
- $msg=&mt('Reservation needed: none available.');
- } elsif ($slot_status == $resource->UNKNOWN) {
- $msg=&mt('Unable to determine status due to network problems.');
- } else {
- if ($status != $resource->OPEN) {
- $msg = &Apache::lonnavmaps::getDescription($resource,'0');
- }
- }
- $output{$symb}{'msg'} = $msg;
+ $currcontainer = $count;
+ $container{$currcontainer} = $resource;
+ $container_title{$currcontainer} = $resource->compTitle();
+ }
+ if (($resource->is_problem() || $resource->is_tool)) {
+ next unless (exists($output{$symb}));
$reservable ++;
- $output{$symb}{'reservable'} = $reservable;
- my $treelevel = $depth;
- my $higherup = $lastcontainer;
- if ($depth > 1) {
- my @maprows;
- while ($treelevel > 1) {
- if (ref($container{$higherup})) {
- my $res = $container{$higherup};
- last if (defined($shownparent{$higherup}));
- my $maptitle = $res->compTitle();
- my $type = 'sequence';
- if ($res->is_page()) {
- $type = 'page';
- }
- &show_map_row($treelevel,$location,$type,$maptitle,
- \@maprows);
- $shownparent{$higherup} = 1;
- }
- $treelevel --;
- $higherup = $parent{$treelevel};
- }
- for (my $i=0; $i<@maprows; $i++) {
- $mapnum ++;
- $rownum ++;
- $shown ++;
- my $bgcolor = $backgrounds[$shown % $numcolors];
- if (!$shownheader) {
- $mapitem .= $slotheader;
- $shownheader = 1;
- }
- if (ref($maprows[$i]) eq 'ARRAY') {
- if ($i < scalar(@maprows)-1) {
- $mapitem .= ''.
- ''.join('',@{$maprows[$i]}).' | '.
- ' |
'."\n";
- } else {
- $mapitem .=
- ''.
- ''.$maprows[$i][0].
- ''.
- $maprows[$i][1].(' ' x6).' | '."\n";
- }
- }
- }
- $output{$symb}{'mapnum'} = $mapnum;
- }
$rownum ++;
- $output{$symb}{'rownum'} = $rownum;
- $output{$symb}{'shown'} = $shown;
if (!$shownheader) {
- $output{$symb}{'header'} = $slotheader;
+ $r->print($slotheader);
$shownheader = 1;
}
- $output{$symb}{'info'} = '';
+ my $style;
+ if (exists($output{$currmap})) {
+ $style = 'none';
+ } else {
+ $style = 'table-row';
+ $shown ++;
+ }
+ my $title = $resource->compTitle();
+ my $bgcolor = $backgrounds[$shown % $numcolors];
+ $r->print(' |
'.
+ '');
for (my $i=0; $i<$depth; $i++) {
- $output{$symb}{'info'} .= '';
+ $r->print('');
}
- $output{$symb}{'info'} .= ''.
- 'src().'?symb='.$symb.'">'.
+ ''.$title.''.(' ' x6).' | ';
-
- my $hasaction;
- if ($status == $resource->OPEN) {
- if ($get_choices) {
- $hasaction = 1;
- $output{$symb}{'hasaction'} = $hasaction;
- }
+ $r->print('problem.gif" alt="'.&mt('Problem'));
}
+ $r->print('" />'.$title.''.(' ' x6).'');
my $class = 'LC_slottext_'.$mapnum;
- if ($hasaction) {
- $output{$symb}{'data'} = ''.$msg.' | '.
- ''.
- &slot_chooser($symb,$class,$reservable,$allavailable,$slots,
- $consumed_uniqueperiods).' | ';
+ if ($output{$symb}{'hasaction'}) {
+ $r->print(''.$output{$symb}{'msg'}.' | '.
+ ''.
+ &slot_chooser($symb,$class,$reservable,$allavailable,$slots,
+ $consumed_uniqueperiods).' | ');
} else {
- $output{$symb}{'data'} = ''.
- ''.$msg.''.
- ' | ';
+ $r->print(''.
+ ''.$output{$symb}{'msg'}.''.
+ ' | ');
}
+ $r->print('
'."\n");
}
}
}
@@ -2154,9 +2175,9 @@ sub manage_reservations {
}
sub show_map_row {
- my ($depth,$location,$type,$title,$maprows) = @_;
+ my ($depth,$location,$type,$title) = @_;
my $spacers;
- for (my $i=0; $i<$depth-2; $i++) {
+ for (my $i=0; $i<$depth-1; $i++) {
$spacers .= '';
}
my $icon;
@@ -2166,8 +2187,7 @@ sub show_map_row {
$icon = ' '."\n";
}
$icon .= $title;
- unshift (@{$maprows},[$spacers,$icon]);
- return;
+ return ($spacers,$icon);
}
sub slot_chooser {
@@ -2186,9 +2206,26 @@ sub slot_chooser {
foreach my $slot (@{$allavailable}) {
# not allowed for this resource
if (ref($slots->{$slot}) eq 'HASH') {
- if ((defined($slots->{$slot}->{'symb'})) &&
- ($slots->{$slot}->{'symb'} ne $symb)) {
- next;
+ if ($slots->{$slot}->{'symb'} ne '') {
+ my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
+ my $exclude = 1;
+ my @reqsymbs = split(/\s*,\s*/,$slots->{$slot}->{'symb'});
+ if (@reqsymbs) {
+ if (grep(/^\Q$symb\E$/,@reqsymbs)) {
+ $exclude = 0;
+ } else {
+ foreach my $reqsymb (@reqsymbs) {
+ my (undef,undef,$sloturl) = &Apache::lonnet::decode_symb($reqsymb);
+ if ($sloturl=~/\.(page|sequence)$/) {
+ if (($map ne '') && ($map eq $sloturl)) {
+ $exclude = 0;
+ last;
+ }
+ }
+ }
+ }
+ next if ($exclude);
+ }
}
}
push(@available,$slot);
@@ -2211,8 +2248,7 @@ sub show_reservations {
$udom = $env{'user.domain'};
}
my $formname = 'slotlog';
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my ($cnum,$cdom)=&get_course();
my $crstype = &Apache::loncommon::course_type();
my %log=&Apache::lonnet::dump('nohist_'.$cdom.'_'.$cnum.'_slotlog',$udom,$uname);
if ($env{'form.origin'} eq 'aboutme') {
@@ -2313,14 +2349,16 @@ sub show_reservations {
if ($showntablehdr) {
$r->print(&Apache::loncommon::end_data_table().'
');
if (($curr{'page'} > 1) || ($more_records)) {
- $r->print('');
+ $r->print('');
$r->print(<<"ENDSCRIPT");