Diff for /loncom/homework/lonhomework.pm between versions 1.160 and 1.168

version 1.160, 2004/01/15 03:44:01 version 1.168, 2004/02/16 20:30:34
Line 201  sub check_access { Line 201  sub check_access {
     my $passed;      my $passed;
   
     if ($ENV{'request.state'} eq "construct") {      if ($ENV{'request.state'} eq "construct") {
    if ($ENV{'form.problemstate'}) {
       if ($ENV{'form.problemstate'} =~ /^CANNOT_ANSWER/) {
    if ( ! ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct' &&
    lc($Apache::lonhomework::problemstatus) eq 'no')) {
       return ('CANNOT_ANSWER',
       &mt('is in this state by royal decree.'));
    }
       } else {
    return ($ENV{'form.problemstate'},
    &mt('is in this state by royal decree.'));
       }
    }
  &Apache::lonxml::debug("in construction ignoring dates");   &Apache::lonxml::debug("in construction ignoring dates");
  $status='CAN_ANSWER';   $status='CAN_ANSWER';
  $datemsg=&mt('is in under construction');   $datemsg=&mt('is in under construction');
  return ($status,$datemsg);  # return ($status,$datemsg);
     }      }
   
     &Apache::lonxml::debug("checking for part :$id:");      &Apache::lonxml::debug("checking for part :$id:");
     &Apache::lonxml::debug("time:".time);      &Apache::lonxml::debug("time:".time);
       
     my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc"));  
     if (!$allowed) {  
  $status='INVALID_ACCESS';  
  $date=&mt("can not be accessed from your location.");  
  return($status,$date);  
     }  
   
     foreach $temp ("opendate","duedate","answerdate") {      if ($ENV{'request.state'} ne "construct") {
  $lastdate = $date;   my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc"));
  $date = &Apache::lonnet::EXT("resource.$id.$temp");   if (!$allowed && ($Apache::lonhomework::browse ne 'F')) {
  my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");      $status='INVALID_ACCESS';
  if ($thistype =~ /^(con_lost|no_such_host)/ ||      $date=&mt("can not be accessed from your location.");
     $date     =~ /^(con_lost|no_such_host)/) {  
     $status='UNAVAILABLE';  
     $date=&mt("may open later.");  
     return($status,$date);      return($status,$date);
  }   }
  if ($thistype eq 'date_interval') {  
     if ($temp eq 'opendate') {   foreach $temp ("opendate","duedate","answerdate") {
  $date=&Apache::lonnet::EXT("resource.$id.duedate")-$date;      $lastdate = $date;
       $date = &Apache::lonnet::EXT("resource.$id.$temp");
       my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");
       if ($thistype =~ /^(con_lost|no_such_host)/ ||
    $date     =~ /^(con_lost|no_such_host)/) {
    $status='UNAVAILABLE';
    $date=&mt("may open later.");
    return($status,$date);
       }
       if ($thistype eq 'date_interval') {
    if ($temp eq 'opendate') {
       $date=&Apache::lonnet::EXT("resource.$id.duedate")-$date;
    }
    if ($temp eq 'answerdate') {
       $date=&Apache::lonnet::EXT("resource.$id.duedate")+$date;
    }
     }      }
     if ($temp eq 'answerdate') {      &Apache::lonxml::debug("found :$date: for :$temp:");
  $date=&Apache::lonnet::EXT("resource.$id.duedate")+$date;      if ($date eq '') {
    $date = &mt("an unknown date"); $passed = 0;
       } elsif ($date eq 'con_lost') {
    $date = &mt("an indeterminate date"); $passed = 0;
       } else {
    if (time < $date) { $passed = 0; } else { $passed = 1; }
    $date = localtime $date;
     }      }
       if (!$passed) { $type=$temp; last; }
  }   }
  &Apache::lonxml::debug("found :$date: for :$temp:");   &Apache::lonxml::debug("have :$type:$passed:");
  if ($date eq '') {   if ($passed) {
     $date = &mt("an unknown date"); $passed = 0;      $status='SHOW_ANSWER';
  } elsif ($date eq 'con_lost') {      $datemsg=$date;
     $date = &mt("an indeterminate date"); $passed = 0;   } elsif ($type eq 'opendate') {
  } else {      $status='CLOSED';
     if (time < $date) { $passed = 0; } else { $passed = 1; }      $datemsg = &mt("will open on")." $date";
     $date = localtime $date;   } elsif ($type eq 'duedate') {
       $status='CAN_ANSWER';
       $datemsg = &mt("is due at")." $date";
    } elsif ($type eq 'answerdate') {
       $status='CLOSED';
       $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date";
  }   }
  if (!$passed) { $type=$temp; last; }  
     }  
     &Apache::lonxml::debug("have :$type:$passed:");  
     if ($passed) {  
  $status='SHOW_ANSWER';  
  $datemsg=$date;  
     } elsif ($type eq 'opendate') {  
  $status='CLOSED';  
  $datemsg = &mt("will open on")." $date";  
     } elsif ($type eq 'duedate') {  
  $status='CAN_ANSWER';  
  $datemsg = &mt("is due at")." $date";  
     } elsif ($type eq 'answerdate') {  
  $status='CLOSED';  
  $datemsg = &mt("was due on")." $lastdate".&mt(", and answers will be available on")." $date";  
     }      }
     if ($status eq 'CAN_ANSWER') {      if ($status eq 'CAN_ANSWER') {
  #check #tries, and if correct.   #check #tries, and if correct.
  my $tries = $Apache::lonhomework::history{"resource.$id.tries"};   my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
  my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");   my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
  if ( $tries eq '' ) { $tries = '0'; }   if ( $tries eq '' ) { $tries = '0'; }
  if ( $maxtries eq '' ) { $maxtries = '2'; }    if ( $maxtries eq '' && 
  if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }       $ENV{'request.state'} ne 'construct') { $maxtries = '2'; } 
    if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }
  # if (correct and show prob status) or excused then CANNOT_ANSWER   # if (correct and show prob status) or excused then CANNOT_ANSWER
  if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/   if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/
     &&      &&
Line 490  sub analyze { Line 505  sub analyze {
     }      }
     $request->print('</table>');      $request->print('</table>');
  } else {   } else {
     $request->print('<p>'.&mt('Part').' '.$part.' '.      $request->print('<p>'.&mt('Response').' '.$part.' '.
     &mt('is not analyzable at this time').'</p>');      &mt('is not analyzable at this time').'</p>');
  }   }
     }      }
     if (scalar(keys(%allparts)) == 0 ) {      if (scalar(keys(%allparts)) == 0 ) {
  $request->print('<p>'.&mt('Found no analyzable parts in this problem, currently only Numerical, Formula and String response styles are supported.').'</p>');   $request->print('<p>'.&mt('Found no analyzable respones in this problem, currently only Numerical, Formula and String response styles are supported.').'</p>');
     }      }
     &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state);      &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state);
     &analyze_footer($request);      &analyze_footer($request);
Line 557  sub renderpage { Line 572  sub renderpage {
     my ($request,$file) = @_;      my ($request,$file) = @_;
   
     my (@targets) = &get_target();      my (@targets) = &get_target();
       &Apache::lonhomework::showhashsubset(\%ENV,'form.');
     &Apache::lonxml::debug("Running targets ".join(':',@targets));      &Apache::lonxml::debug("Running targets ".join(':',@targets));
     foreach my $target (@targets) {      foreach my $target (@targets) {
  #my $t0 = [&gettimeofday()];   #my $t0 = [&gettimeofday()];
Line 705  sub handler { Line 721  sub handler {
     my $request=$_[0];      my $request=$_[0];
           
     $Apache::lonxml::debug=$ENV{'user.debug'};      $Apache::lonxml::debug=$ENV{'user.debug'};
   
     if (&setupheader($request)) { return OK; }      if (&setupheader($request)) { return OK; }
     $ENV{'request.uri'}=$request->uri;      $ENV{'request.uri'}=$request->uri;
   

Removed from v.1.160  
changed lines
  Added in v.1.168


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