--- loncom/interface/slotrequest.pm 2005/11/08 03:13:20 1.29 +++ loncom/interface/slotrequest.pm 2005/11/14 23:21:55 1.30 @@ -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.29 2005/11/08 03:13:20 albertel Exp $ +# $Id: slotrequest.pm,v 1.30 2005/11/14 23:21:55 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -450,6 +450,49 @@ STUFF $r->print(''); } +sub to_show { + my ($when,$slot) = @_; + my $time=time; + my $week=60*60*24*7; + if ($when eq 'now') { + if ($time > $slot->{'starttime'} && + $time < $slot->{'endtime'}) { + return 1; + } + return 0; + } elsif ($when eq 'nextweek') { + if ( ($time < $slot->{'starttime'} && + ($time+$week) > $slot->{'starttime'}) + || + ($time < $slot->{'endtime'} && + ($time+$week) > $slot->{'endtime'}) ) { + return 1; + } + return 0; + } elsif ($when eq 'lastweek') { + if ( ($time > $slot->{'starttime'} && + ($time-$week) < $slot->{'starttime'}) + || + ($time > $slot->{'endtime'} && + ($time-$week) < $slot->{'endtime'}) ) { + return 1; + } + return 0; + } elsif ($when eq 'willopen') { + if ($time < $slot->{'starttime'}) { + return 1; + } + return 0; + } elsif ($when eq 'wereopen') { + if ($time > $slot->{'endtime'}) { + return 1; + } + return 0; + } + + return 1; +} + sub show_table { my ($r,$mgr)=@_; @@ -460,6 +503,7 @@ sub show_table { } my $available; if ($mgr eq 'F') { + $r->print('
'); $r->print('
@@ -467,14 +511,17 @@ sub show_table { $r->print('
'); + $r->print('
'); } - my %Saveable_Parameters = ('show' => 'array'); + my %Saveable_Parameters = ('show' => 'array', + 'when' => 'scalar', + 'order' => 'scalar'); - &Apache::loncommon::store_course_settings('chart',\%Saveable_Parameters); - &Apache::loncommon::restore_course_settings('chart',\%Saveable_Parameters); + &Apache::loncommon::store_course_settings('slotrequest',\%Saveable_Parameters); + &Apache::loncommon::restore_course_settings('slotrequest',\%Saveable_Parameters); - my %fields=&Apache::lonlocal::texthash( + my %show_fields=&Apache::lonlocal::texthash( 'name' => 'Slot Name', 'description' => 'Description', 'type' => 'Type', @@ -487,26 +534,40 @@ sub show_table { 'symb' => 'Resource slot is restricted to.', 'uniqueperiod' => 'Period of time slot is unique', 'proctor' => 'List of proctors'); - my @order=('name','description','type','starttime','endtime', + my @show_order=('name','description','type','starttime','endtime', 'startreserve','secret','maxspace','ip','symb', 'uniqueperiod','proctor'); - my @sel = + my @show = (exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show') - : keys(%fields); - my %sel = map { $_ => 1 } (@sel); + : keys(%show_fields); + my %show = map { $_ => 1 } (@show); + + my %when_fields=&Apache::lonlocal::texthash( + 'now' => 'Open now', + 'nextweek' => 'Open within the next week', + 'lastweek' => 'Were open last week', + 'willopen' => 'Will open later', + 'wereopen' => 'Were open'); + my @when_order=('now','nextweek','lastweek','willopen','wereopen'); + $when_fields{'select_form_order'} = \@when_order; + my $when = (exists($env{'form.when'})) ? $env{'form.when'} + : 'now'; $r->print('
- -'); - $r->print('
Show: '.&Apache::loncommon::multiple_select_form('show',\@sel,6,\%fields,\@order). +'); + $r->print('
'); + $r->print('
'.&mt('Show').''.&mt('Open').'
'.&Apache::loncommon::multiple_select_form('show',\@show,6,\%show_fields,\@show_order). + ''.&Apache::loncommon::select_form($when,'when',%when_fields). '
'); + $r->print('
'); + $r->print('

'); my $linkstart=' + $r->print(''); - foreach my $which (@order) { - if ($which ne 'proctor' && exists($sel{$which})) { - $r->print(''); + foreach my $which (@show_order) { + if ($which ne 'proctor' && exists($show{$which})) { + $r->print(''); } } $r->print(''); @@ -539,6 +600,7 @@ sub show_table { return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'}; }; foreach my $slot (sort $slotsort (keys(%slots))) { + if (!&to_show($when,$slots{$slot})) { next; } if (defined($slots{$slot}->{'type'}) && $slots{$slot}->{'type'} ne 'schedulable_student') { #next; @@ -574,7 +636,7 @@ sub show_table { my @proctors; my $rowspan=1; my $colspan=1; - if (exists($sel{'proctor'})) { + if (exists($show{'proctor'})) { $rowspan=2; @proctors= map { my ($uname,$udom)=split(/@/,$_); @@ -598,41 +660,41 @@ sub show_table { EDITFORM $r->print("\n\n"); - if (exists($sel{'name'})) { + if (exists($show{'name'})) { $colspan++;$r->print(""); } - if (exists($sel{'type'})) { + if (exists($show{'type'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'description'})) { + if (exists($show{'description'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'starttime'})) { + if (exists($show{'starttime'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'endtime'})) { + if (exists($show{'endtime'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'startreserve'})) { + if (exists($show{'startreserve'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'secret'})) { + if (exists($show{'secret'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'maxspace'})) { + if (exists($show{'maxspace'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'ip'})) { + if (exists($show{'ip'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'symb'})) { + if (exists($show{'symb'})) { $colspan++;$r->print("\n"); } - if (exists($sel{'uniqueperiod'})) { + if (exists($show{'uniqueperiod'})) { $colspan++;$r->print("\n"); } $colspan++;$r->print("\n\n"); - if (exists($sel{'proctor'})) { + if (exists($show{'proctor'})) { $r->print(< @@ -872,6 +934,13 @@ sub csv_upload_assign { sub handler { my $r=shift; + &Apache::loncommon::content_type($r,'text/html'); + &Apache::loncommon::no_cache($r); + if ($r->header_only()) { + $r->send_http_header(); + return OK; + } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});
'.$linkstart.$which.'">'.$fields{$which}.''.$linkstart.$which.'">'.$show_fields{$which}.'Scheduled Students
$edit$slot$slots{$slot}->{'type'}$description$start$end$start_reserve$slots{$slot}{'secret'}$slots{$slot}{'maxspace'}$slots{$slot}{'ip'}$title$unique$ids
$proctors