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

version 1.282, 2007/11/03 00:52:06 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 494  sub check_access { Line 495  sub check_access {
    $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {     $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {
     $status = 'CANNOT_ANSWER';      $status = 'CANNOT_ANSWER';
  }   }
    if ($status eq 'CANNOT_ANSWER'
       && &show_answer_problem_status()) {
       $status = 'SHOW_ANSWER';
    }
     }      }
     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 532  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 = ($interval < $due_date)? $interval : $due_date;      $date = (!$due_date || $interval < $due_date) ? $interval
                                                             : $due_date;
  } else {   } else {
     $date = $due_date;      $date = $due_date;
  }   }
Line 683  sub handle_save_or_undo { Line 689  sub handle_save_or_undo {
     my $error=0;      my $error=0;
     if ($env{'form.Undo'} eq &mt('undo')) {      if ($env{'form.Undo'} eq &mt('undo')) {
  my $error=0;   my $error=0;
  if (!copy($file,$filetmp)) { $error=1; }   if (!&File::Copy::copy($file,$filetmp)) { $error=1; }
  if ((!$error) && (!copy($filebak,$file))) { $error=1; }   if ((!$error) && (!&File::Copy::copy($filebak,$file))) { $error=1; }
  if ((!$error) && (!move($filetmp,$filebak))) { $error=1; }   if ((!$error) && (!&File::Copy::move($filetmp,$filebak))) { $error=1; }
  if (!$error) {   if (!$error) {
     &Apache::lonxml::info("<p><b>".      &Apache::lonxml::info("<p><b>".
   &mt("Undid changes, Switched [_1] and [_2]",    &mt("Undid changes, Switched [_1] and [_2]",
Line 882  sub analyze { Line 888  sub analyze {
   
     sub show_problem_status {      sub show_problem_status {
  return ($show_problem_status eq 'yes'   return ($show_problem_status eq 'yes'
    || $show_problem_status eq 'answer'
  || $show_problem_status eq '');   || $show_problem_status eq '');
     }      }
           
Line 892  sub analyze { Line 899  sub analyze {
     sub show_no_problem_status {      sub show_no_problem_status {
  return ($show_problem_status eq 'no_feedback_ever');   return ($show_problem_status eq 'no_feedback_ever');
     }      }
     
       sub show_answer_problem_status {
    return ($show_problem_status eq 'answer');
       }
 }  }
   
 sub editxmlmode {  sub editxmlmode {
Line 1072  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.282  
changed lines
  Added in v.1.288


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