Diff for /loncom/interface/slotrequest.pm between versions 1.29 and 1.30

version 1.29, 2005/11/08 03:13:20 version 1.30, 2005/11/14 23:21:55
Line 450  STUFF Line 450  STUFF
     $r->print('</table>');      $r->print('</table>');
 }  }
   
   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 {  sub show_table {
     my ($r,$mgr)=@_;      my ($r,$mgr)=@_;
   
Line 460  sub show_table { Line 503  sub show_table {
     }       } 
     my $available;      my $available;
     if ($mgr eq 'F') {      if ($mgr eq 'F') {
    $r->print('<div>');
  $r->print('<form method="POST" action="/adm/slotrequest">   $r->print('<form method="POST" action="/adm/slotrequest">
 <input type="hidden" name="command" value="uploadstart" />  <input type="hidden" name="command" value="uploadstart" />
 <input type="submit" name="start" value="'.&mt('Upload Slot List').'" />  <input type="submit" name="start" value="'.&mt('Upload Slot List').'" />
Line 467  sub show_table { Line 511  sub show_table {
  $r->print('<form method="POST" action="/adm/helper/newslot.helper">   $r->print('<form method="POST" action="/adm/helper/newslot.helper">
 <input type="submit" name="newslot" value="'.&mt('Create a New Slot').'" />  <input type="submit" name="newslot" value="'.&mt('Create a New Slot').'" />
 </form>');  </form>');
    $r->print('</div>');
     }      }
           
     my %Saveable_Parameters = ('show' => 'array');      my %Saveable_Parameters = ('show'  => 'array',
          'when'  => 'scalar',
          'order' => 'scalar');
   
     &Apache::loncommon::store_course_settings('chart',\%Saveable_Parameters);      &Apache::loncommon::store_course_settings('slotrequest',\%Saveable_Parameters);
     &Apache::loncommon::restore_course_settings('chart',\%Saveable_Parameters);      &Apache::loncommon::restore_course_settings('slotrequest',\%Saveable_Parameters);
   
     my %fields=&Apache::lonlocal::texthash(      my %show_fields=&Apache::lonlocal::texthash(
      'name'         => 'Slot Name',       'name'         => 'Slot Name',
      'description'  => 'Description',       'description'  => 'Description',
      'type'         => 'Type',       'type'         => 'Type',
Line 487  sub show_table { Line 534  sub show_table {
      'symb'         => 'Resource slot is restricted to.',       'symb'         => 'Resource slot is restricted to.',
      'uniqueperiod' => 'Period of time slot is unique',       'uniqueperiod' => 'Period of time slot is unique',
      'proctor'      => 'List of proctors');       'proctor'      => 'List of proctors');
     my @order=('name','description','type','starttime','endtime',      my @show_order=('name','description','type','starttime','endtime',
        'startreserve','secret','maxspace','ip','symb',         'startreserve','secret','maxspace','ip','symb',
        'uniqueperiod','proctor');         'uniqueperiod','proctor');
     my @sel =       my @show = 
  (exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')   (exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
                             : keys(%fields);                              : keys(%show_fields);
     my %sel =  map { $_ => 1 } (@sel);      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('<form method="POST" action="/adm/slotrequest">      $r->print('<form method="POST" action="/adm/slotrequest">
 <input type="hidden" name="command" value="showslots" />  <input type="hidden" name="command" value="showslots" />');
 <input type="submit" name="start" value="'.&mt('Change').'" />');      $r->print('<div>');
     $r->print('<table><tr><td>Show: '.&Apache::loncommon::multiple_select_form('show',\@sel,6,\%fields,\@order).      $r->print('<table class="inline"><tr><th>'.&mt('Show').'</th><th>'.&mt('Open').'</th></tr><tr><td>'.&Apache::loncommon::multiple_select_form('show',\@show,6,\%show_fields,\@show_order).
         '</td><td>'.&Apache::loncommon::select_form($when,'when',%when_fields).
       '</td></tr></table>');        '</td></tr></table>');
       $r->print('</div>');
       $r->print('<p><input type="submit" name="start" value="'.&mt('Update Display').'" /></p>');
     my $linkstart='<a href="/adm/slotrequest?command=showslots&amp;order=';      my $linkstart='<a href="/adm/slotrequest?command=showslots&amp;order=';
     $r->print('<table border="1">      $r->print('<table class="thinborder">
 <tr>  <tr>
   <th></th>');    <th></th>');
     foreach my $which (@order) {      foreach my $which (@show_order) {
  if ($which ne 'proctor' && exists($sel{$which})) {   if ($which ne 'proctor' && exists($show{$which})) {
     $r->print('<th>'.$linkstart.$which.'">'.$fields{$which}.'</a></th>');      $r->print('<th>'.$linkstart.$which.'">'.$show_fields{$which}.'</a></th>');
  }   }
     }      }
     $r->print('<th>Scheduled Students</th></tr>');      $r->print('<th>Scheduled Students</th></tr>');
Line 539  sub show_table { Line 600  sub show_table {
  return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'};   return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'};
     };      };
     foreach my $slot (sort $slotsort (keys(%slots)))  {      foreach my $slot (sort $slotsort (keys(%slots)))  {
    if (!&to_show($when,$slots{$slot})) { next; }
  if (defined($slots{$slot}->{'type'})   if (defined($slots{$slot}->{'type'})
     && $slots{$slot}->{'type'} ne 'schedulable_student') {      && $slots{$slot}->{'type'} ne 'schedulable_student') {
     #next;      #next;
Line 574  sub show_table { Line 636  sub show_table {
  my @proctors;   my @proctors;
  my $rowspan=1;   my $rowspan=1;
  my $colspan=1;   my $colspan=1;
  if (exists($sel{'proctor'})) {   if (exists($show{'proctor'})) {
     $rowspan=2;      $rowspan=2;
     @proctors= map {      @proctors= map {
  my ($uname,$udom)=split(/@/,$_);   my ($uname,$udom)=split(/@/,$_);
Line 598  sub show_table { Line 660  sub show_table {
 EDITFORM  EDITFORM
     
         $r->print("<tr>\n<td rowspan=\"$rowspan\">$edit</td>\n");          $r->print("<tr>\n<td rowspan=\"$rowspan\">$edit</td>\n");
  if (exists($sel{'name'})) {   if (exists($show{'name'})) {
     $colspan++;$r->print("<td>$slot</td>");      $colspan++;$r->print("<td>$slot</td>");
  }   }
  if (exists($sel{'type'})) {   if (exists($show{'type'})) {
     $colspan++;$r->print("<td>$slots{$slot}->{'type'}</td>\n");      $colspan++;$r->print("<td>$slots{$slot}->{'type'}</td>\n");
  }   }
  if (exists($sel{'description'})) {   if (exists($show{'description'})) {
     $colspan++;$r->print("<td>$description</td>\n");      $colspan++;$r->print("<td>$description</td>\n");
  }   }
  if (exists($sel{'starttime'})) {   if (exists($show{'starttime'})) {
     $colspan++;$r->print("<td>$start</td>\n");      $colspan++;$r->print("<td>$start</td>\n");
  }   }
  if (exists($sel{'endtime'})) {   if (exists($show{'endtime'})) {
     $colspan++;$r->print("<td>$end</td>\n");      $colspan++;$r->print("<td>$end</td>\n");
  }   }
  if (exists($sel{'startreserve'})) {   if (exists($show{'startreserve'})) {
     $colspan++;$r->print("<td>$start_reserve</td>\n");      $colspan++;$r->print("<td>$start_reserve</td>\n");
  }   }
  if (exists($sel{'secret'})) {   if (exists($show{'secret'})) {
     $colspan++;$r->print("<td>$slots{$slot}{'secret'}</td>\n");      $colspan++;$r->print("<td>$slots{$slot}{'secret'}</td>\n");
  }   }
  if (exists($sel{'maxspace'})) {   if (exists($show{'maxspace'})) {
     $colspan++;$r->print("<td>$slots{$slot}{'maxspace'}</td>\n");      $colspan++;$r->print("<td>$slots{$slot}{'maxspace'}</td>\n");
  }   }
  if (exists($sel{'ip'})) {   if (exists($show{'ip'})) {
     $colspan++;$r->print("<td>$slots{$slot}{'ip'}</td>\n");      $colspan++;$r->print("<td>$slots{$slot}{'ip'}</td>\n");
  }   }
  if (exists($sel{'symb'})) {   if (exists($show{'symb'})) {
     $colspan++;$r->print("<td>$title</td>\n");      $colspan++;$r->print("<td>$title</td>\n");
  }   }
  if (exists($sel{'uniqueperiod'})) {   if (exists($show{'uniqueperiod'})) {
     $colspan++;$r->print("<td>$unique</td>\n");      $colspan++;$r->print("<td>$unique</td>\n");
  }   }
  $colspan++;$r->print("<td>$ids</td>\n</tr>\n");   $colspan++;$r->print("<td>$ids</td>\n</tr>\n");
  if (exists($sel{'proctor'})) {   if (exists($show{'proctor'})) {
     $r->print(<<STUFF);      $r->print(<<STUFF);
 <tr>  <tr>
  <td colspan="$colspan">$proctors</td>   <td colspan="$colspan">$proctors</td>
Line 872  sub csv_upload_assign { Line 934  sub csv_upload_assign {
 sub handler {  sub handler {
     my $r=shift;      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'});      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
           
     my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});      my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});

Removed from v.1.29  
changed lines
  Added in v.1.30


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>