Diff for /loncom/homework/lonhomework.pm between versions 1.333 and 1.334

version 1.333, 2011/12/15 01:21:28 version 1.334, 2011/12/20 22:46:06
Line 246  sub check_slot_access { Line 246  sub check_slot_access {
 #    }  #    }
     my $slotstatus='NOT_IN_A_SLOT';      my $slotstatus='NOT_IN_A_SLOT';
     my ($returned_slot,$slot_name);      my ($returned_slot,$slot_name);
       my $now = time;
       my $num_usable_slots = 0;
     foreach my $slot (@slots) {      foreach my $slot (@slots) {
  $slot =~ s/(^\s*|\s*$)//g;   $slot =~ s/(^\s*|\s*$)//g;
  &Apache::lonxml::debug("getting $slot");   &Apache::lonxml::debug("getting $slot");
  my %slot=&Apache::lonnet::get_slot($slot);   my %slot=&Apache::lonnet::get_slot($slot);
  &Apache::lonhomework::showhash(%slot);   &Apache::lonhomework::showhash(%slot);
  if ($slot{'starttime'} < time &&          next if ($slot{'endtime'} < $now);
     $slot{'endtime'} > time &&          $num_usable_slots ++;
    if ($slot{'starttime'} < $now &&
       $slot{'endtime'} > $now &&
     &Apache::loncommon::check_ip_acc($slot{'ip'})) {      &Apache::loncommon::check_ip_acc($slot{'ip'})) {
     &Apache::lonxml::debug("$slot is good");      &Apache::lonxml::debug("$slot is good");
     $slotstatus='NEEDS_CHECKIN';      $slotstatus='NEEDS_CHECKIN';
     $returned_slot=\%slot;      $returned_slot=\%slot;
     $slot_name=$slot;      $slot_name=$slot;
     last;      last;
  }          } 
     }      }
     if ($slotstatus eq 'NEEDS_CHECKIN' &&      if ($slotstatus eq 'NEEDS_CHECKIN' &&
  &proctor_checked_in($slot_name,$returned_slot,$type)) {   &proctor_checked_in($slot_name,$returned_slot,$type)) {
Line 299  sub check_slot_access { Line 303  sub check_slot_access {
     # However, the problem is not closed, and potentially, another slot might be      # However, the problem is not closed, and potentially, another slot might be
     # used to gain access to it to work on it, until the due date is reached, and the      # used to gain access to it to work on it, until the due date is reached, and the
     # problem then becomes CLOSED.  Therefore return the slotstatus -       # problem then becomes CLOSED.  Therefore return the slotstatus - 
     # (which will be NOT_IN_SLOT).      # (which will be one of: NOT_IN_A_SLOT, RESERVABLE, RESERVABLE_LATER, or NOTRESERVABLE.
     if (!defined($slot_name)      if (!defined($slot_name) && $type eq 'problem') {
  && $checkedin           if ($slotstatus eq 'NOT_IN_A_SLOT') {
  && $type eq 'problem') {              if (!$num_usable_slots) {
         return ($slotstatus);                  if ($env{'request.course.id'}) {
                       my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                       my ($symb)=&Apache::lonnet::whichuser();
                       $slotstatus = 'NOTRESERVABLE';
                       my ($reservable_now_order,$reservable_now,$reservable_future_order,
                           $reservable_future) = 
                           &Apache::loncommon::get_future_slots($cnum,$cdom,$now,$symb);
                       if ((ref($reservable_now_order) eq 'ARRAY') && (ref($reservable_now) eq 'HASH')) {
                           if (@{$reservable_now_order} > 0) {
                               $slotstatus = 'RESERVABLE';
                               $datemsg = $reservable_now->{$reservable_now_order->[-1]}{'endreserve'};
                           }
                       }
                       unless ($slotstatus eq 'RESERVABLE') {
                           if ((ref($reservable_future_order) eq 'ARRAY') && (ref($reservable_future) eq 'HASH')) {
                               if (@{$reservable_future_order} > 0) {
                                   $slotstatus = 'RESERVABLE_LATER';
                                   $datemsg = $reservable_future->{$reservable_future_order->[0]}{'startreserve'};
                               }
                           }
                       }
                   }
               }
           }
           return ($slotstatus,$datemsg);
     }      }
   
     if ($slotstatus eq 'NOT_IN_A_SLOT'       if ($slotstatus eq 'NOT_IN_A_SLOT' 

Removed from v.1.333  
changed lines
  Added in v.1.334


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