Diff for /loncom/homework/lonhomework.pm between versions 1.285 and 1.288

version 1.285, 2007/11/17 02:51:29 version 1.288, 2008/01/14 14:32:14
Line 292  sub check_slot_access { Line 292  sub check_slot_access {
  }   }
     }      }
   
     my @slots=      my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent");
  (split(':',&Apache::lonnet::EXT("resource.0.availablestudent")),      my $available = &Apache::lonnet::EXT("resource.0.available");
  split(':',&Apache::lonnet::EXT("resource.0.available")));      my @slots= (split(':',$availablestudent),split(':',$available));
   
 #    if (!@slots) {  #    if (!@slots) {
 # return ($status,$datemsg);  # return ($status,$datemsg);
Line 421  sub check_access { Line 421  sub check_access {
     &Apache::lonxml::debug("symb:".$symb);      &Apache::lonxml::debug("symb:".$symb);
     #if ($env{'request.state'} ne "construct" && $symb ne '') {      #if ($env{'request.state'} ne "construct" && $symb ne '') {
     if ($env{'request.state'} ne "construct") {      if ($env{'request.state'} ne "construct") {
  my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc"));          my $idacc = &Apache::lonnet::EXT("resource.$id.acc");
    my $allowed=&check_ip_acc($idacc);
  if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {   if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {
     $status='INVALID_ACCESS';      $status='INVALID_ACCESS';
     $date=&mt("can not be accessed from your location.");      $date=&mt("can not be accessed from your location.");
Line 500  sub check_access { Line 501  sub check_access {
  }   }
     }      }
     if ($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER') {      if ($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER') {
  my $interval=&Apache::lonnet::EXT("resource.$id.interval");   my @interval=&Apache::lonnet::EXT("resource.$id.interval");
  &Apache::lonxml::debug("looking for interval $interval");   &Apache::lonxml::debug("looking for interval @interval");
  if ($interval) {   if ($interval[0]) {
     my $first_access=&Apache::lonnet::get_first_access('map');      my $first_access=&Apache::lonnet::get_first_access($interval[1]);
     &Apache::lonxml::debug("looking for accesstime $first_access");      &Apache::lonxml::debug("looking for accesstime $first_access");
     if (!$first_access) {      if (!$first_access) {
  $status='NOT_YET_VIEWED';   $status='NOT_YET_VIEWED';
  my $due_date = &due_date($id);   my $due_date = &due_date($id);
  my $seconds_left = $due_date - time;   my $seconds_left = $due_date - time;
  if ($seconds_left > $interval || $due_date eq '') {   if ($seconds_left > $interval[0] || $due_date eq '') {
     $seconds_left = $interval;      $seconds_left = $interval[0];
  }   }
  $datemsg=&seconds_to_human_length($seconds_left);   $datemsg=&seconds_to_human_length($seconds_left);
     }      }
Line 536  sub check_access { Line 537  sub check_access {
 sub due_date {  sub due_date {
     my ($part_id,$symb,$udom,$uname)=@_;      my ($part_id,$symb,$udom,$uname)=@_;
     my $date;      my $date;
     my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb,      my @interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb,
        $udom,$uname);         $udom,$uname);
     &Apache::lonxml::debug("looking for interval $part_id $symb $interval");      &Apache::lonxml::debug("looking for interval $part_id $symb @interval");
     my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb,      my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb,
        $udom,$uname);         $udom,$uname);
     &Apache::lonxml::debug("looking for due_date $part_id $symb $due_date");      &Apache::lonxml::debug("looking for due_date $part_id $symb $due_date");
     if ($interval =~ /\d+/) {      if ($interval[0] =~ /\d+/) {
  my $first_access=&Apache::lonnet::get_first_access('map',$symb);   my $first_access=&Apache::lonnet::get_first_access($interval[1],$symb);
  &Apache::lonxml::debug("looking for first_access $first_access");   &Apache::lonxml::debug("looking for first_access $first_access ($interval[1])");
  if (defined($first_access)) {   if (defined($first_access)) {
     $interval = $first_access+$interval;      my $interval = $first_access+$interval[0];
     $date = (!$due_date || $interval < $due_date) ? $interval      $date = (!$due_date || $interval < $due_date) ? $interval
                                                           : $due_date;                                                            : $due_date;
  } else {   } else {
Line 1082  sub get_template_list { Line 1083  sub get_template_list {
      '/templates/*.'.$glob_extension);       '/templates/*.'.$glob_extension);
     @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title'))]} (@files);      @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title'))]} (@files);
     @files = sort {$a->[1] cmp $b->[1]} (@files);      @files = sort {$a->[1] cmp $b->[1]} (@files);
       my ($midpoint,$seconddiv,$numfiles);
       $numfiles = 0;
       foreach my $file (@files) {
           next if ($file->[1] !~ /\S/);
           $numfiles ++;
       }
       if ($numfiles > 0) {
           $result = '<div class="LC_left_float">';
           $midpoint = int($numfiles/2);
           if ($numfiles%2) {
               $midpoint ++;
           }
       }
       my $count = 0;
     foreach my $file (@files) {      foreach my $file (@files) {
  next if ($file->[1] !~ /\S/);   next if ($file->[1] !~ /\S/);
  $result .=   $result .=
     '<label><input type="radio" name="template" value="'.$file->[0].'" />'.      '<label><input type="radio" name="template" value="'.$file->[0].'" />'.
     $file->[1].'</label><br />';      $file->[1].'</label><br />'."\n";
           $count ++;
           if ((!$seconddiv) && ($count >= $midpoint)) {
               $result .= '</div>'."\n".'<div class="LC_left_float">'."\n";
               $seconddiv = 1;
           }
       }
       if ($numfiles > 0) {
           $result .= '</div>'."\n".'<div class="LC_clear_float_footer"></div>'."\n";
     }      }
     return $result;      return $result;
 }  }

Removed from v.1.285  
changed lines
  Added in v.1.288


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