version 1.125.2.3, 2016/10/24 01:13:54
|
version 1.130, 2015/09/27 22:35:39
|
Line 260 function uncheckSlotRadio() {
|
Line 260 function uncheckSlotRadio() {
|
} |
} |
} |
} |
} |
} |
|
|
|
function toggleSlotMap(maprownum,rownum) { |
|
if (document.getElementById('arrow'+maprownum)) { |
|
var img = document.getElementById('arrow'+maprownum); |
|
var rowdisplay; |
|
var celldisplay = ''; |
|
if (img.src.indexOf('arrow.open.gif')!=-1) { |
|
img.src = '/adm/lonIcons/arrow.closed.gif'; |
|
rowdisplay = 'none'; |
|
} |
|
else { |
|
img.src = '/adm/lonIcons/arrow.open.gif'; |
|
rowdisplay = 'table-row'; |
|
celldisplay = 'none'; |
|
} |
|
var resrows; |
|
var maptext; |
|
if (document.getElementsByClassName) { |
|
resrows = document.getElementsByClassName('LC_slotresrow_'+maprownum); |
|
maptext = document.getElementsByClassName('LC_slotmaptext_'+maprownum); |
|
} else { |
|
resrows = getElementsByClassName(document.body,'LC_slotresrow_'+maprownum); |
|
maptext = getElementsByClassName(document.body,'LC_slotmaptext_'+maprownum); |
|
} |
|
if (maptext.length) { |
|
for (var i=0; i<maptext.length; i++) { |
|
maptext[i].style.display = celldisplay; |
|
} |
|
} |
|
if (resrows.length) { |
|
var mapbgidx = 0; |
|
var rowclasses = ['LC_even_row','LC_odd_row']; |
|
var mapbgClass = 'LC_even_row'; |
|
var regExpBg = /LC_odd_row/i; |
|
if (rowdisplay == 'table-row') { |
|
if (document.getElementById('LC_slotmaprow_'+rownum)) { |
|
mapbgClass = document.getElementById('LC_slotmaprow_'+rownum).className; |
|
if (regExpBg.test(mapbgClass)) { |
|
mapbgidx = 1; |
|
} |
|
} |
|
} |
|
for (var i=0; i<resrows.length; i++) { |
|
resrows[i].style.display = rowdisplay; |
|
if (rowdisplay == 'table-row') { |
|
mapbgidx ++; |
|
var bgcolnew = mapbgidx % 2; |
|
var bgcolold = (mapbgidx+1) % 2; |
|
var k = i+parseInt(rownum)+1; |
|
if (document.getElementById('LC_slotresrow_'+k)) { |
|
document.getElementById('LC_slotresrow_'+k).className = document.getElementById('LC_slotresrow_'+k).className.replace(rowclasses[bgcolold],rowclasses[bgcolnew]); |
|
} |
|
} |
|
} |
|
if (document.getElementById('LC_slot_reservations')) { |
|
var numrowsOdd = resrows.length % 2; |
|
if (numrowsOdd) { |
|
var lastbgClass = 'LC_even_row'; |
|
var idx = 0; |
|
var lastresnum = parseInt(rownum) + resrows.length; |
|
if (rowdisplay == 'none') { |
|
lastresnum = rownum; |
|
if (document.getElementById('LC_slotmaprow_'+rownum)) { |
|
lastbgClass = document.getElementById('LC_slotmaprow_'+rownum).className; |
|
} |
|
} else { |
|
lastresnum = parseInt(rownum) + resrows.length; |
|
if (document.getElementById('LC_slotresrow_'+lastresnum)) { |
|
lastbgClass = document.getElementById('LC_slotresrow_'+lastresnum).className; |
|
} |
|
} |
|
if (regExpBg.test(lastbgClass)) { |
|
idx = 1; |
|
} |
|
var table = document.getElementById('LC_slot_reservations'); |
|
if ((table.rows.length) && (table.rows.length >= lastresnum)) { |
|
for (var i=lastresnum; i<table.rows.length; i++) { |
|
if (table.rows[i].style.display != 'none') { |
|
idx ++; |
|
var bgcolnew = idx % 2; |
|
var bgcolold = (idx+1) % 2; |
|
j = i+1; |
|
if (document.getElementById('LC_slotmaprow_'+j)) { |
|
document.getElementById('LC_slotmaprow_'+j).className = rowclasses[bgcolnew]; |
|
} else { |
|
if (document.getElementById('LC_slotresrow_'+j)) { |
|
document.getElementById('LC_slotresrow_'+j).className = document.getElementById('LC_slotresrow_'+j).className.replace(rowclasses[bgcolold],rowclasses[bgcolnew]); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
// ]]> |
// ]]> |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
Line 1015 sub allowed_slot {
|
Line 1112 sub allowed_slot {
|
return 0 if (!$userallowed); |
return 0 if (!$userallowed); |
|
|
# not allowed for this resource |
# not allowed for this resource |
if (defined($slot->{'symb'}) |
if (defined($slot->{'symb'})) { |
&& $slot->{'symb'} ne $symb) { |
my $exclude = 1; |
unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) { |
my @symbs; |
return 0; |
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; |
|
} |
|
} |
|
if ($exclude) { |
|
unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) { |
|
return 0; |
|
} |
} |
} |
} |
} |
|
|
Line 1047 sub get_description {
|
Line 1166 sub get_description {
|
} |
} |
|
|
sub show_choices { |
sub show_choices { |
my ($r,$symb,$formname,$num,$slots,$consumed_uniqueperiods,$available,$got_slots)=@_; |
my ($symb,$formname,$num,$class,$slots,$consumed_uniqueperiods,$available,$got_slots)=@_; |
my $output; |
my $output; |
&Apache::lonxml::debug("Checking Slots"); |
&Apache::lonxml::debug("Checking Slots"); |
if (!ref($available) eq 'ARRAY') { |
if (!ref($available) eq 'ARRAY') { |
Line 1059 sub show_choices {
|
Line 1178 sub show_choices {
|
$output .= ' <a href="/adm/flip?postdata=return:">'. |
$output .= ' <a href="/adm/flip?postdata=return:">'. |
&mt('Return to last resource').'</a>'; |
&mt('Return to last resource').'</a>'; |
} |
} |
$r->print($output); |
if ($class) { |
return; |
return '<div class="'.$class.'">'.$output.'</div>'; |
|
} else { |
|
return $output; |
|
} |
} |
} |
if (@{$available} > 1) { |
if (@{$available} > 1) { |
my $numavailable = scalar(@{$available}); |
my $numavailable = scalar(@{$available}); |
Line 1208 STUFF
|
Line 1330 STUFF
|
if (@{$available} > 1) { |
if (@{$available} > 1) { |
$output .= '</div></fieldset>'; |
$output .= '</div></fieldset>'; |
} |
} |
$r->print($output); |
if ($class) { |
return; |
return '<div class="'.$class.'">'.$output.'</div>'; |
|
} else { |
|
return $output; |
|
} |
} |
} |
|
|
sub to_show { |
sub to_show { |
Line 1364 sub show_table {
|
Line 1489 sub show_table {
|
'secret' => 'Secret Word', |
'secret' => 'Secret Word', |
'space' => '# of students/max', |
'space' => '# of students/max', |
'ip' => 'IP or DNS restrictions', |
'ip' => 'IP or DNS restrictions', |
'symb' => 'Resource slot is restricted to.', |
'symb' => 'Resource(s)/Map(s) slot is restricted to.', |
'allowedsections' => 'Sections slot is restricted to.', |
'allowedsections' => 'Sections slot is restricted to.', |
'allowedusers' => 'Users slot is restricted to.', |
'allowedusers' => 'Users slot is restricted to.', |
'uniqueperiod' => 'Period of time slot is unique', |
'uniqueperiod' => 'Period of time slot is unique', |
Line 1476 sub show_table {
|
Line 1601 sub show_table {
|
$r->print('</div>'); |
$r->print('</div>'); |
$r->print('<p><input type="submit" name="start" value="'.&mt('Update Display').'" /></p>'); |
$r->print('<p><input type="submit" name="start" value="'.&mt('Update Display').'" /></p>'); |
my $linkstart='<a href="/adm/slotrequest?command=showslots&order='; |
my $linkstart='<a href="/adm/slotrequest?command=showslots&order='; |
my $tableheader = &Apache::loncommon::start_data_table(). |
$r->print(&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row().' |
&Apache::loncommon::start_data_table_header_row().' |
<th></th>'; |
<th></th>'); |
foreach my $which (@show_order) { |
foreach my $which (@show_order) { |
if ($which ne 'proctor' && exists($show{$which})) { |
if ($which ne 'proctor' && exists($show{$which})) { |
$tableheader .= '<th>'.$linkstart.$which.'">'.$show_fields{$which}.'</a></th>'; |
$r->print('<th>'.$linkstart.$which.'">'.$show_fields{$which}.'</a></th>'); |
} |
} |
} |
} |
$tableheader .= &Apache::loncommon::end_data_table_header_row(); |
$r->print(&Apache::loncommon::end_data_table_header_row()); |
my $shownheader = 0; |
|
|
|
my %name_cache; |
my %name_cache; |
my $slotsort = sub { |
my $slotsort = sub { |
Line 1580 sub show_table {
|
Line 1704 sub show_table {
|
localtime($slots{$slot}{'uniqueperiod'}[1]); |
localtime($slots{$slot}{'uniqueperiod'}[1]); |
} |
} |
|
|
my $title; |
my @titles; |
if (exists($slots{$slot}{'symb'})) { |
if (exists($slots{$slot}{'symb'})) { |
my (undef,undef,$res)= |
my @symbs; |
&Apache::lonnet::decode_symb($slots{$slot}{'symb'}); |
if ($slots{$slot}{'symb'} =~ /,/) { |
$res = &Apache::lonnet::clutter($res); |
@symbs = split(/\s*,\s*/,$slots{$slot}{'symb'}); |
$title = &Apache::lonnet::gettitle($slots{$slot}{'symb'}); |
} else { |
$title='<a href="'.$res.'?symb='.$slots{$slot}{'symb'}.'">'.$title.'</a>'; |
@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,'<a href="'.$res.'?symb='.$reqsymb.'">'.$title.'</a>'); |
|
} |
} |
} |
|
|
my $allowedsections; |
my $allowedsections; |
Line 1634 sub show_table {
|
Line 1766 sub show_table {
|
delete => 'Delete', |
delete => 'Delete', |
slotlog => 'History', |
slotlog => 'History', |
); |
); |
my ($edit,$delete,$showlog,$remove_all); |
my $edit=(<<"EDITLINK"); |
if ($mgr) { |
|
$edit=(<<"EDITLINK"); |
|
<a href="/adm/helper/newslot.helper?name=$slot">$lt{'edit'}</a> |
<a href="/adm/helper/newslot.helper?name=$slot">$lt{'edit'}</a> |
EDITLINK |
EDITLINK |
|
|
$delete=(<<"DELETELINK"); |
my $delete=(<<"DELETELINK"); |
<a href="/adm/slotrequest?command=delete&slotname=$slot">$lt{'delete'}</a> |
<a href="/adm/slotrequest?command=delete&slotname=$slot">$lt{'delete'}</a> |
DELETELINK |
DELETELINK |
|
|
$remove_all=&remove_link($slot,'remove all').'<br />'; |
my $showlog=(<<"LOGLINK"); |
|
|
if ($ids eq '') { |
|
undef($remove_all); |
|
} else { |
|
undef($delete); |
|
} |
|
} |
|
|
|
$showlog=(<<"LOGLINK"); |
|
<a href="/adm/slotrequest?command=slotlog&slotname=$slot">$lt{'slotlog'}</a> |
<a href="/adm/slotrequest?command=slotlog&slotname=$slot">$lt{'slotlog'}</a> |
LOGLINK |
LOGLINK |
|
|
|
my $remove_all=&remove_link($slot,'remove all').'<br />'; |
|
|
|
if ($ids eq '') { |
|
undef($remove_all); |
|
} else { |
|
undef($delete); |
|
} |
if ($slots{$slot}{'type'} ne 'schedulable_student') { |
if ($slots{$slot}{'type'} ne 'schedulable_student') { |
undef($showlog); |
undef($showlog); |
undef($remove_all); |
undef($remove_all); |
} |
} |
|
|
unless ($shownheader) { |
|
$r->print($tableheader); |
|
$shownheader = 1; |
|
} |
|
|
|
my $row_start=&Apache::loncommon::start_data_table_row(); |
my $row_start=&Apache::loncommon::start_data_table_row(); |
my $row_end=&Apache::loncommon::end_data_table_row(); |
my $row_end=&Apache::loncommon::end_data_table_row(); |
$r->print($row_start. |
$r->print($row_start. |
Line 1712 LOGLINK
|
Line 1835 LOGLINK
|
$colspan++;$r->print("<td>$slots{$slot}{'ip'}</td>\n"); |
$colspan++;$r->print("<td>$slots{$slot}{'ip'}</td>\n"); |
} |
} |
if (exists($show{'symb'})) { |
if (exists($show{'symb'})) { |
$colspan++;$r->print("<td>$title</td>\n"); |
$colspan++;$r->print("<td>".join('<br />',@titles)."</td>\n"); |
} |
} |
if (exists($show{'allowedsections'})) { |
if (exists($show{'allowedsections'})) { |
$colspan++;$r->print("<td>$allowedsections</td>\n"); |
$colspan++;$r->print("<td>$allowedsections</td>\n"); |
Line 1735 $row_end
|
Line 1858 $row_end
|
STUFF |
STUFF |
} |
} |
} |
} |
if ($shownheader) { |
$r->print(&Apache::loncommon::end_data_table().'</form>'); |
$r->print(&Apache::loncommon::end_data_table()); |
|
} else { |
|
$r->print('<p>'.&mt('No slots meet the criteria for display').'</p>'); |
|
} |
|
$r->print('</form>'); |
|
return; |
return; |
} |
} |
|
|
Line 1778 sub manage_reservations {
|
Line 1896 sub manage_reservations {
|
return; |
return; |
} |
} |
my (%parent,%shownparent,%container,%container_title,%contents); |
my (%parent,%shownparent,%container,%container_title,%contents); |
my ($depth,$count,$reservable,$lastcontainer,$rownum) = (0,0,0,0,0); |
my ($depth,$count,$reservable,$lastcontainer,$rownum,$shown) = (0,0,0,0,0,0); |
my @backgrounds = ("LC_odd_row","LC_even_row"); |
my @backgrounds = ("LC_odd_row","LC_even_row"); |
my $numcolors = scalar(@backgrounds); |
my $numcolors = scalar(@backgrounds); |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif"); |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif"); |
my $slotheader = '<p>'. |
my $slotheader = '<p>'. |
&mt('Your reservation status for any such assignments is listed below:'). |
&mt('Your reservation status for any such assignments is listed below:'). |
'</p>'. |
'</p>'. |
'<table class="LC_data_table LC_tableOfContent">'."\n"; |
'<table class="LC_data_table LC_tableOfContent" id="LC_slot_reservations">'."\n"; |
my $shownheader = 0; |
my $shownheader = 0; |
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); |
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()) { |
while (my $resource = $it->next()) { |
if ($resource == $it->BEGIN_MAP()) { |
if ($resource == $it->BEGIN_MAP()) { |
$depth++; |
$depth++; |
Line 1796 sub manage_reservations {
|
Line 1917 sub manage_reservations {
|
if ($resource == $it->END_MAP()) { |
if ($resource == $it->END_MAP()) { |
$depth--; |
$depth--; |
$lastcontainer = $parent{$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); |
|
} else { |
|
$allstatuses{$output{$symb}{'slotstatus'}} = [$symb]; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
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 .= '<td valign="top"><span class="'.$class.'">'. |
|
$output{$repsymb}{'msg'}. |
|
'</span></td><td valign="top">'. |
|
&slot_chooser($repsymb,$class,$formnum,$allavailable,$slots, |
|
$consumed_uniqueperiods). |
|
'</td>'; |
|
|
|
} else { |
|
$mapitem .= '<td colspan="2" valign="middle"><span class="'.$class.'">'. |
|
$output{$repsymb}{'msg'}. |
|
'</span></td>'; |
|
} |
|
} |
|
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'}. |
|
'<tr class="'.$bgcolor.' LC_slotresrow_'.$output{$symb}{'mapnum'}.'"'. |
|
' style="display:none" id="LC_slotresrow_'.$output{$symb}{'rownum'}.'">'. |
|
$output{$symb}{'info'}. |
|
$output{$symb}{'data'}.'</tr>'."\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'}. |
|
'<tr class="'.$bgcolor.' LC_slotresrow_'.$output{$symb}{'mapnum'}.'"'. |
|
' style="display:table-row" id="LC_slotresrow_'.$output{$symb}{'rownum'}.'">'. |
|
$output{$symb}{'info'}. |
|
$output{$symb}{'data'}.'</tr>'."\n"; |
|
$shown ++; |
|
} |
|
} |
|
} |
|
if ($mapitem) { |
|
if ($got_map_slot) { |
|
$mapitem =~ s{(<img src=\"/adm/lonIcons/arrow\.)open(\.gif\")}{$1closed$2}; |
|
$mapitem .= '</tr>'."\n"; |
|
} else { |
|
$mapitem .= '<td colspan="2"> </td></tr>'."\n"; |
|
} |
|
} |
|
$r->print($mapitem.$currmapoutput); |
|
@ordered=(); |
|
undef(%output); |
|
$currmapoutput = ''; |
|
$got_map_slot = ''; |
|
$mapitem = ''; |
} |
} |
if (ref($resource)) { |
if (ref($resource)) { |
my $symb = $resource->symb(); |
my $symb = $resource->symb(); |
my $ressymb = $symb; |
|
$contents{$lastcontainer} ++; |
$contents{$lastcontainer} ++; |
next if (!$resource->is_problem() && !$resource->is_sequence() && |
next if (!$resource->is_problem() && !$resource->is_sequence() && |
!$resource->is_page()); |
!$resource->is_page()); |
Line 1812 sub manage_reservations {
|
Line 2013 sub manage_reservations {
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
my ($useslots) = $resource->slot_control(); |
my ($useslots) = $resource->slot_control(); |
next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i)); |
next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i)); |
|
push(@ordered,$symb); |
|
$output{$symb}{type} = $useslots; |
my ($msg,$get_choices,$slotdescription); |
my ($msg,$get_choices,$slotdescription); |
my $title = $resource->compTitle(); |
my $title = $resource->compTitle(); |
my $status = $resource->simpleStatus('0'); |
my $status = $resource->simpleStatus('0'); |
my ($slot_status,$date,$slot_name) = $resource->check_for_slot('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 '') { |
if ($slot_name ne '') { |
my %slot=&Apache::lonnet::get_slot($slot_name); |
my %slot=&Apache::lonnet::get_slot($slot_name); |
$slotdescription=&get_description($slot_name,\%slot); |
$slotdescription=&get_description($slot_name,\%slot); |
Line 1859 sub manage_reservations {
|
Line 2065 sub manage_reservations {
|
$msg = &Apache::lonnavmaps::getDescription($resource,'0'); |
$msg = &Apache::lonnavmaps::getDescription($resource,'0'); |
} |
} |
} |
} |
|
$output{$symb}{'msg'} = $msg; |
$reservable ++; |
$reservable ++; |
|
$output{$symb}{'reservable'} = $reservable; |
my $treelevel = $depth; |
my $treelevel = $depth; |
my $higherup = $lastcontainer; |
my $higherup = $lastcontainer; |
if ($depth > 1) { |
if ($depth > 1) { |
Line 1880 sub manage_reservations {
|
Line 2088 sub manage_reservations {
|
$treelevel --; |
$treelevel --; |
$higherup = $parent{$treelevel}; |
$higherup = $parent{$treelevel}; |
} |
} |
foreach my $item (@maprows) { |
for (my $i=0; $i<@maprows; $i++) { |
|
$mapnum ++; |
$rownum ++; |
$rownum ++; |
my $bgcolor = $backgrounds[$rownum % $numcolors]; |
$shown ++; |
|
my $bgcolor = $backgrounds[$shown % $numcolors]; |
if (!$shownheader) { |
if (!$shownheader) { |
$r->print($slotheader); |
$mapitem .= $slotheader; |
$shownheader = 1; |
$shownheader = 1; |
} |
} |
$r->print('<tr class="'.$bgcolor.'">'.$item.'</tr>'."\n"); |
if (ref($maprows[$i]) eq 'ARRAY') { |
|
if ($i < scalar(@maprows)-1) { |
|
$mapitem .= '<tr class="'.$bgcolor.'" id="LC_slotmaprow_'.$rownum.'">'. |
|
'<td>'.join('',@{$maprows[$i]}).'</td>'. |
|
'<td colspan="2"> </td></tr>'."\n"; |
|
} else { |
|
$mapitem .= |
|
'<tr class="'.$bgcolor.'" id="LC_slotmaprow_'.$rownum.'">'. |
|
'<td>'.$maprows[$i][0]. |
|
'<img src="/adm/lonIcons/arrow.open.gif" id="arrow'.$mapnum.'" '. |
|
'alt="arrow" onmouseover="this.style.cursor=\'pointer\'" '. |
|
'onclick="'."toggleSlotMap('$mapnum','$rownum');".'" />'. |
|
$maprows[$i][1].(' ' x6).'</td>'."\n"; |
|
} |
|
} |
} |
} |
|
$output{$symb}{'mapnum'} = $mapnum; |
} |
} |
$rownum ++; |
$rownum ++; |
my $bgcolor = $backgrounds[$rownum % $numcolors]; |
$output{$symb}{'rownum'} = $rownum; |
|
$output{$symb}{'shown'} = $shown; |
if (!$shownheader) { |
if (!$shownheader) { |
$r->print($slotheader); |
$output{$symb}{'header'} = $slotheader; |
$shownheader = 1; |
$shownheader = 1; |
} |
} |
$r->print('<tr class="'.$bgcolor.'"><td>'."\n"); |
$output{$symb}{'info'} = '<td>'; |
for (my $i=0; $i<$depth; $i++) { |
for (my $i=0; $i<$depth; $i++) { |
$r->print('<img src="'.$location.'" alt="" />'); |
$output{$symb}{'info'} .= '<img src="'.$location.'" alt="" />'; |
} |
} |
my $result = '<a href="'.$resource->src().'?symb='.$symb.'">'. |
$output{$symb}{'info'} .= '<a href="'.$resource->src().'?symb='.$symb.'">'. |
'<img class="LC_contentImage" src="/adm/lonIcons/'; |
'<img class="LC_contentImage" src="/adm/lonIcons/'; |
if ($resource->is_task()) { |
if ($resource->is_task()) { |
$result .= 'task.gif" alt="'.&mt('Task'); |
$output{$symb}{'info'} .= 'task.gif" alt="'.&mt('Task'); |
} else { |
} else { |
$result .= 'problem.gif" alt="'.&mt('Problem'); |
$output{$symb}{'info'} .= 'problem.gif" alt="'.&mt('Problem'); |
} |
} |
$result .= '" /><b>'.$title.'</b></a>'.(' ' x6).'</td>'; |
$output{$symb}{'info'} .= '" /><b>'.$title.'</b></a>'.(' ' x6).'</td>'; |
|
|
my $hasaction; |
my $hasaction; |
if ($status == $resource->OPEN) { |
if ($status == $resource->OPEN) { |
if ($get_choices) { |
if ($get_choices) { |
$hasaction = 1; |
$hasaction = 1; |
|
$output{$symb}{'hasaction'} = $hasaction; |
} |
} |
} |
} |
|
my $class = 'LC_slottext_'.$mapnum; |
if ($hasaction) { |
if ($hasaction) { |
$result .= '<td valign="top">'.$msg.'</td>'. |
$output{$symb}{'data'} = '<td valign="top"><span class="'.$class.'">'.$msg.'</span></td>'. |
'<td valign="top">'; |
'<td valign="top">'. |
|
&slot_chooser($symb,$class,$reservable,$allavailable,$slots, |
|
$consumed_uniqueperiods).'</td>'; |
} else { |
} else { |
$result .= '<td colspan="2" valign="middle">'.$msg.'</td>'; |
$output{$symb}{'data'} = '<td colspan="2" valign="middle">'. |
|
'<span class="'.$class.'">'.$msg.'</span>'. |
|
'</td>'; |
} |
} |
$r->print($result); |
|
if ($hasaction) { |
|
my @got_slots=&check_for_reservation($symb,'allslots'); |
|
if ($got_slots[0] =~ /^error: /) { |
|
$r->print('<span class="LC_error">'. |
|
&mt('An error occurred determining slot availability.'). |
|
'</span>'); |
|
} else { |
|
my $formname = 'manageres_'.$reservable; |
|
if (ref($allavailable) eq 'ARRAY') { |
|
my @available; |
|
if (ref($slots) eq 'HASH') { |
|
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; |
|
} |
|
} |
|
push(@available,$slot); |
|
} |
|
} |
|
&show_choices($r,$symb,$formname,$reservable,$slots,$consumed_uniqueperiods, |
|
\@available,\@got_slots); |
|
} |
|
} |
|
$r->print('</td>'); |
|
} |
|
$r->print('</tr>'); |
|
} |
} |
} |
} |
} |
} |
Line 1971 sub manage_reservations {
|
Line 2174 sub manage_reservations {
|
|
|
sub show_map_row { |
sub show_map_row { |
my ($depth,$location,$type,$title,$maprows) = @_; |
my ($depth,$location,$type,$title,$maprows) = @_; |
my $output = '<td>'; |
my $spacers; |
for (my $i=0; $i<$depth-1; $i++) { |
for (my $i=0; $i<$depth-2; $i++) { |
$output .= '<img src="'.$location.'" alt="" />'; |
$spacers .= '<img src="'.$location.'" alt="" />'; |
} |
} |
|
my $icon; |
if ($type eq 'page') { |
if ($type eq 'page') { |
$output .= '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n"; |
$icon = '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n"; |
} else { |
} else { |
$output .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n"; |
$icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n"; |
} |
} |
$output .= $title.'</td><td colspan="2"> </td>'."\n"; |
$icon .= $title; |
unshift (@{$maprows},$output); |
unshift (@{$maprows},[$spacers,$icon]); |
return; |
return; |
} |
} |
|
|
|
sub slot_chooser { |
|
my ($symb,$class,$formnum,$allavailable,$slots,$consumed_uniqueperiods) = @_; |
|
my $output; |
|
my @got_slots=&check_for_reservation($symb,'allslots'); |
|
if ($got_slots[0] =~ /^error: /) { |
|
$output = '<span class="'.$class.'"><span class="LC_error">'. |
|
&mt('An error occurred determining slot availability.'). |
|
'</span></span>'; |
|
} else { |
|
my $formname = 'manageres_'.$formnum; |
|
if (ref($allavailable) eq 'ARRAY') { |
|
my @available; |
|
if (ref($slots) eq 'HASH') { |
|
foreach my $slot (@{$allavailable}) { |
|
# not allowed for this resource |
|
if (ref($slots->{$slot}) eq 'HASH') { |
|
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); |
|
} |
|
} |
|
$output .= &show_choices($symb,$formname,$formnum,$class, |
|
$slots,$consumed_uniqueperiods, |
|
\@available,\@got_slots); |
|
} |
|
} |
|
return $output; |
|
} |
|
|
sub show_reservations { |
sub show_reservations { |
my ($r,$uname,$udom) = @_; |
my ($r,$uname,$udom) = @_; |
if (!defined($uname)) { |
if (!defined($uname)) { |
Line 2096 sub show_reservations {
|
Line 2349 sub show_reservations {
|
if ($showntablehdr) { |
if ($showntablehdr) { |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
if (($curr{'page'} > 1) || ($more_records)) { |
if (($curr{'page'} > 1) || ($more_records)) { |
$r->print('<p>'); |
$r->print('<table><tr>'); |
if ($curr{'page'} > 1) { |
if ($curr{'page'} > 1) { |
$r->print('<input type="button" onclick="javascript:chgPage('."'previous'".');" value="'. |
$r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>'); |
&mt('Previous [_1] changes',$curr{'show'}).'" />'); |
|
} |
} |
if ($more_records) { |
if ($more_records) { |
$r->print('<input type="button" onclick="javascript:chgPage('."'next'".');" value="'. |
$r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>'); |
&mt('Next [_1] changes',$curr{'show'}).'" />'); |
|
} |
} |
$r->print('</p>'); |
$r->print('</tr></table>'); |
$r->print(<<"ENDSCRIPT"); |
$r->print(<<"ENDSCRIPT"); |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 2309 sub show_reservations_log {
|
Line 2560 sub show_reservations_log {
|
if ($showntablehdr) { |
if ($showntablehdr) { |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
if (($curr{'page'} > 1) || ($more_records)) { |
if (($curr{'page'} > 1) || ($more_records)) { |
$r->print('<p>'); |
$r->print('<table><tr>'); |
if ($curr{'page'} > 1) { |
if ($curr{'page'} > 1) { |
$r->print('<input type="button" onclick="javascript:chgPage('."'previous'".');" value="'. |
$r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>'); |
&mt('Previous [_1] changes',$curr{'show'}).'" />'); |
|
} |
} |
if ($more_records) { |
if ($more_records) { |
$r->print('<input type="button" onclick="javascript:chgPage('."'next'".');" value="'. |
$r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>'); |
&mt('Next [_1] changes',$curr{'show'}).'" />'); |
|
} |
} |
$r->print('</p>'); |
$r->print('</tr></table>'); |
$r->print(<<"ENDSCRIPT"); |
$r->print(<<"ENDSCRIPT"); |
<script type="text/javascript"> |
<script type="text/javascript"> |
function chgPage(caller) { |
function chgPage(caller) { |
Line 2458 sub display_filter {
|
Line 2707 sub display_filter {
|
} |
} |
$output .= '</select></td>'; |
$output .= '</select></td>'; |
} |
} |
$output .= '<td> </td></tr></table>'. |
$output .= '<td> </td><td valign="middle"><input type="submit" value="'. |
'<p><input type="submit" value="'. |
&mt('Update Display').'" /></tr></table>'. |
&mt('Update Display').'" /></p>'. |
|
'<p class="LC_info">'. |
'<p class="LC_info">'. |
&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.' |
&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.' |
,'2.9.0'); |
,'2.9.0'); |
Line 2707 sub csvupload_fields {
|
Line 2955 sub csvupload_fields {
|
['proctor','List of proctor ids'], |
['proctor','List of proctor ids'], |
['description','Slot Description'], |
['description','Slot Description'], |
['maxspace','Maximum number of reservations'], |
['maxspace','Maximum number of reservations'], |
['symb','Resource Restriction'], |
['symb','Resource(s)/Map(s) Restriction'], |
['uniqueperiod','Date range of slot exclusion'], |
['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'], |
['allowedsections','Sections slot is restricted to'], |
Line 2775 sub csv_upload_assign {
|
Line 3023 sub csv_upload_assign {
|
} |
} |
|
|
if ($entries{$fields{'startreserve'}}) { |
if ($entries{$fields{'startreserve'}}) { |
my $date = &UnixDate($entries{$fields{'startreserve'}},"%s"); |
$slot{'startreserve'}= |
if ($date eq '') { |
&UnixDate($entries{$fields{'startreserve'}},"%s"); |
push(@errors,"$name -- No reservation start time set for slot -- value provided had invalid format"); |
|
} else { |
|
$slot{'startreserve'} = $date; |
|
} |
|
} |
} |
if (defined($slot{'startreserve'}) |
if (defined($slot{'startreserve'}) |
&& $slot{'startreserve'} > $slot{'starttime'}) { |
&& $slot{'startreserve'} > $slot{'starttime'}) { |
Line 2789 sub csv_upload_assign {
|
Line 3033 sub csv_upload_assign {
|
} |
} |
|
|
if ($entries{$fields{'endreserve'}}) { |
if ($entries{$fields{'endreserve'}}) { |
my $date = &UnixDate($entries{$fields{'endreserve'}},"%s"); |
$slot{'endreserve'}= |
if ($date eq '') { |
&UnixDate($entries{$fields{'endreserve'}},"%s"); |
push(@errors,"$name -- No reservation end time set for slot -- value provided had invalid format"); |
|
} else { |
|
$slot{'endreserve'} = $date; |
|
} |
|
} |
} |
if (defined($slot{'endreserve'}) |
if (defined($slot{'endreserve'}) |
&& $slot{'endreserve'} > $slot{'starttime'}) { |
&& $slot{'endreserve'} > $slot{'starttime'}) { |
Line 2854 sub csv_upload_assign {
|
Line 3094 sub csv_upload_assign {
|
} |
} |
} |
} |
if ($entries{$fields{'uniqueperiod'}}) { |
if ($entries{$fields{'uniqueperiod'}}) { |
my ($start,$end)= map { &UnixDate($_,"%s"); } split(',',$entries{$fields{'uniqueperiod'}}); |
my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}}); |
if (($start ne '') && ($end ne '')) { |
my @times=(&UnixDate($start,"%s"), |
$slot{'uniqueperiod'}=[$start,$end]; |
&UnixDate($end,"%s")); |
} else { |
$slot{'uniqueperiod'}=\@times; |
push(@errors,"$name -- Slot's unique period ignored -- one or both of the comma separated values for start and end had an invalid format"); |
|
} |
|
} |
} |
if (ref($slot{'uniqueperiod'}) eq 'ARRAY' |
if (defined($slot{'uniqueperiod'}) |
&& $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) { |
&& $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) { |
push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time."); |
push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time."); |
next; |
next; |
Line 3024 sub handler {
|
Line 3262 sub handler {
|
} |
} |
&csv_upload_map($r); |
&csv_upload_map($r); |
} |
} |
} elsif (($env{'form.command'} eq 'slotlog') && ($vgr eq 'F')) { |
} elsif ($env{'form.command'} eq 'slotlog' && $mgr eq 'F') { |
&show_reservations_log($r); |
&show_reservations_log($r); |
} else { |
} else { |
my $symb=&unescape($env{'form.symb'}); |
my $symb=&unescape($env{'form.symb'}); |
Line 3052 sub handler {
|
Line 3290 sub handler {
|
} |
} |
if ($env{'form.requestattempt'}) { |
if ($env{'form.requestattempt'}) { |
$r->print('<div class="LC_left_float">'); |
$r->print('<div class="LC_left_float">'); |
&show_choices($r,$symb,undef,undef,\%slots,$consumed_uniqueperiods,$available,$got_slots); |
$r->print(&show_choices($symb,undef,undef,undef,\%slots,$consumed_uniqueperiods,$available,$got_slots)); |
$r->print('</div><div style="padding:0;clear:both;margin:0;border:0"></div>'); |
$r->print('</div><div style="padding:0;clear:both;margin:0;border:0"></div>'); |
} elsif ($env{'form.command'} eq 'release') { |
} elsif ($env{'form.command'} eq 'release') { |
&release_slot($r,$symb); |
&release_slot($r,$symb); |