Diff for /loncom/homework/lonhomework.pm between versions 1.219 and 1.226

version 1.219, 2005/11/08 17:53:20 version 1.226, 2005/11/21 21:51:29
Line 166  sub send_footer { Line 166  sub send_footer {
 }  }
   
 sub proctor_checked_in {  sub proctor_checked_in {
     my ($slot_name,$slot)=@_;      my ($slot_name,$slot,$type)=@_;
     my @allowed=split(",",$slot->{'proctor'});      my @possible_proctors=split(",",$slot->{'proctor'});
     my $version=$Apache::lonhomework::history{'resource.version'};      
     foreach my $possible (@allowed) {       my $key;
  if ($Apache::lonhomework::history{"resource.$version.checkedin"} eq      if ($type eq 'Task') {
     $possible &&   my $version=$Apache::lonhomework::history{'resource.version'};
     $Apache::lonhomework::history{"resource.$version.checkedin.slot"}   $key ="resource.$version.checkedin";
        eq $slot_name) {      } elsif ($type eq 'problem') {
    $key ='resource.0.checkedin';
       }
       
       foreach my $possible (@possible_proctors) { 
    if ($Apache::lonhomework::history{$key} eq $possible
       && $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) {
     return 1;      return 1;
  }   }
     }      }
       
     return 0;      return 0;
 }  }
   
Line 230  sub check_ip_acc { Line 237  sub check_ip_acc {
     return $allowed;      return $allowed;
 }  }
   
 sub check_task_access {  sub check_slot_access {
       my ($id,$type)=@_;
   
     # does it pass normal muster      # does it pass normal muster
     # yes we really do want the default args passing      my ($status,$datemsg)=&check_access($id);
     my ($status,$datemsg)=&check_access;      
       my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");
       if ($useslots ne 'resource') {
    return ($status,$datemsg);
       }
   
     if ($status eq 'SHOW_ANSWER' ||      if ($status eq 'SHOW_ANSWER' ||
  $status eq 'CLOSED' ||   $status eq 'CLOSED' ||
  $status eq 'CANNOT_ANSWER' ||  
  $status eq 'INVALID_ACCESS' ||   $status eq 'INVALID_ACCESS' ||
  $status eq 'UNAVAILABLE') {   $status eq 'UNAVAILABLE') {
  return ($status,$datemsg);   return ($status,$datemsg);
Line 244  sub check_task_access { Line 257  sub check_task_access {
     if ($env{'request.state'} eq "construct") {      if ($env{'request.state'} eq "construct") {
  return ($status,$datemsg);   return ($status,$datemsg);
     }      }
     my $version=$Apache::lonhomework::history{'resource.version'};      
     if ($Apache::lonhomework::history{"resource.$version.checkedin"} &&      if ($type eq 'Task') {
  $Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {   my $version=$Apache::lonhomework::history{'resource.version'};
  return ('SHOW_ANSWER');   if ($Apache::lonhomework::history{"resource.$version.checkedin"} &&
       $Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
       return ('SHOW_ANSWER');
    }
     }      }
     my ($id)=@_;  
     my @slots=      my @slots=
  (split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")),   (split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")),
  split(':',&Apache::lonnet::EXT("resource.$id.available")));   split(':',&Apache::lonnet::EXT("resource.$id.available")));
Line 274  sub check_task_access { Line 290  sub check_task_access {
  }   }
     }      }
     if ($slotstatus eq 'NEEDS_CHECKIN' &&      if ($slotstatus eq 'NEEDS_CHECKIN' &&
  &proctor_checked_in($slot_name,$returned_slot)) {   &proctor_checked_in($slot_name,$returned_slot,$type)) {
  &Apache::lonxml::debug("protoctor checked in");   &Apache::lonxml::debug("protoctor checked in");
  $slotstatus='CAN_ANSWER';   $slotstatus='CAN_ANSWER';
     }      }
     if ( $slotstatus eq 'NOT_IN_A_SLOT' &&   
  $Apache::lonhomework::history{"resource.$version.checkedin"}) {      my ($pass_status,$checkedin);
  if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {      if ($type eq 'Task') {
    my $version=$Apache::lonhomework::history{'resource.version'};
    $pass_status = 
       $Apache::lonhomework::history{"resource.$version.status"} eq 'fail';
    $checkedin =
       $Apache::lonhomework::history{"resource.$version.checkedin"};
       } elsif ($type eq 'problem') {
    $pass_status = 1;
    $checkedin = $Apache::lonhomework::history{"resource.0.checkedin"};
       }
       
       if ($slotstatus eq 'NOT_IN_A_SLOT' 
    && $checkedin ) {
   
    if ($pass_status) {
     return ('SHOW_ANSWER');      return ('SHOW_ANSWER');
  } else {   } else {
     return ('WAITING_FOR_GRADE');      return ('WAITING_FOR_GRADE');
  }   }
   
     }      }
       if ( $status eq 'CANNOT_ANSWER' && 
    ($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) {
    return ($status,$datemsg);
       }
   
     return ($slotstatus,$datemsg,$slot_name,$returned_slot);      return ($slotstatus,$datemsg,$slot_name,$returned_slot);
 }  }
   
Line 297  sub check_access { Line 333  sub check_access {
     my $status;      my $status;
     my $datemsg = '';      my $datemsg = '';
     my $lastdate = '';      my $lastdate = '';
     my $temp;  
     my $type;      my $type;
     my $passed;      my $passed;
   
Line 334  sub check_access { Line 369  sub check_access {
     return($status,$date);      return($status,$date);
  }   }
   
  foreach $temp ("opendate","duedate","answerdate") {   foreach my $temp ("opendate","duedate","answerdate") {
     $lastdate = $date;      $lastdate = $date;
     $date = &Apache::lonnet::EXT("resource.$id.$temp");      $date = &Apache::lonnet::EXT("resource.$id.$temp");
     my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");      my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");
Line 581  sub handle_save_or_undo { Line 616  sub handle_save_or_undo {
   
 sub analyze_header {  sub analyze_header {
     my ($request) = @_;      my ($request) = @_;
     my $bodytag='<body bgcolor="#ffffff">';      my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
     if ($env{'environment.remote'} eq 'off') {      ($env{'environment.remote'} ne 'off'));
  $bodytag=&Apache::loncommon::bodytag();  
     }  
     my $html=&Apache::lonxml::xmlbegin();      my $html=&Apache::lonxml::xmlbegin();
     my $result.=$html.'      my $result.=$html.'
             <head><title>'.&mt("Analyzing a problem").'</title></head>              <head><title>'.&mt("Analyzing a problem").'</title></head>
Line 659  sub analyze { Line 692  sub analyze {
     foreach my $part (sort(keys(%allparts))) {      foreach my $part (sort(keys(%allparts))) {
  if (defined(@{ $overall{$part.'.answer'} })) {   if (defined(@{ $overall{$part.'.answer'} })) {
     my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] });      my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] });
     $request->print('<table border="1"><tr><th colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part.'</th></tr>');      $request->print('<table class="thinborder"><tr><th colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part.'</th></tr>');
     my %frequency;      my %frequency;
     foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {      foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {
  $frequency{join("\0",@{ $answer })}++;   $frequency{join("\0",@{ $answer })}++;
Line 667  sub analyze { Line 700  sub analyze {
     $request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'<br />('      $request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'<br />('
     .&mt('click for example').')</th></tr>');      .&mt('click for example').')</th></tr>');
     foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) {      foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) {
  $request->print('<tr><td>'.   $request->print('<tr><td class="center">'.
  join('</td><td>',split("\0",$answer)).   join('</td><td class="center">',split("\0",$answer)).
  '</td><td><a href="'.$request->uri.'?rndseed='.$seedexample{$answer}.'">'.$frequency{$answer}.   '</td><td class="center"><a href="'.$request->uri.'?rndseed='.$seedexample{$answer}.'">'.$frequency{$answer}.
  '</a></td></tr>');   '</a></td></tr>');
     }      }
     $request->print('</table>');      $request->print('</table>');
Line 717  sub editxmlmode { Line 750  sub editxmlmode {
  if ($cols > 80) { $cols = 80; }   if ($cols > 80) { $cols = 80; }
  if ($cols < 70) { $cols = 70; }   if ($cols < 70) { $cols = 70; }
  if ($rows < 20) { $rows = 20; }   if ($rows < 20) { $rows = 20; }
  my $bodytag='<body bgcolor="#ffffff">';   my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
  if ($env{'environment.remote'} eq 'off') {   ($env{'environment.remote'} ne 'off'));
     $bodytag=&Apache::loncommon::bodytag();  
  }  
  my $html=&Apache::lonxml::xmlbegin();   my $html=&Apache::lonxml::xmlbegin();
  $result.=$html.$bodytag.   $result.=$html.$bodytag.
     &renderpage($request,$file,['no_output_web'],1).      &renderpage($request,$file,['no_output_web'],1).
Line 770  sub renderpage { Line 801  sub renderpage {
     $target = 'web'; $output=0;      $target = 'web'; $output=0;
  }   }
  my $problem=&Apache::lonnet::getfile($file);   my $problem=&Apache::lonnet::getfile($file);
    my $result;
  if ($problem eq -1) {   if ($problem eq -1) {
     &Apache::lonxml::error("<b> ".&mt('Unable to find')." <i>$file</i></b>");      my $filename=(split('/',$file))[-1];
       $result.="<b> ".&mt('Unable to find')." <i>$filename</i></b>";
     $problem='';      $problem='';
  }   }
   
Line 781  sub renderpage { Line 814  sub renderpage {
  if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');}   if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');}
   
  &Apache::lonxml::debug("Should be parsing now");   &Apache::lonxml::debug("Should be parsing now");
  my $result = &Apache::lonxml::xmlparse($request, $target, $problem,   $result .= &Apache::lonxml::xmlparse($request, $target, $problem,
        &setup_vars($target),%mystyle);       &setup_vars($target),%mystyle);
  undef($Apache::lonhomework::parsing_a_problem);   undef($Apache::lonhomework::parsing_a_problem);
  if (!$output) { $result = ''; }   if (!$output) { $result = ''; }
  #$request->print("Result follows:");   #$request->print("Result follows:");
Line 921  EDITMENU Line 954  EDITMENU
 sub handler {  sub handler {
     #my $t0 = [&gettimeofday()];      #my $t0 = [&gettimeofday()];
     my $request=$_[0];      my $request=$_[0];
           $Apache::lonxml::request=$request;
     $Apache::lonxml::debug=$env{'user.debug'};      $Apache::lonxml::debug=$env{'user.debug'};
     $env{'request.uri'}=$request->uri;      $env{'request.uri'}=$request->uri;
     &setuppermissions();      &setuppermissions();
Line 941  sub handler { Line 974  sub handler {
  if ($Apache::lonhomework::browse ne 'F' &&    if ($Apache::lonhomework::browse ne 'F' && 
     $env{'request.state'} ne "construct") {      $env{'request.state'} ne "construct") {
     #should know where we are, so ask      #should know where we are, so ask
     if ( &Apache::lonnet::mod_perl_version() == 2 ) {  
  &Apache::lonnet::cleanenv();  
     }  
     &Apache::lonnet::logthis(&Apache::lonnet::mod_perl_version());  
     $request->internal_redirect('/adm/ambiguous'); return OK;      $request->internal_redirect('/adm/ambiguous'); return OK;
  }   }
     }      }

Removed from v.1.219  
changed lines
  Added in v.1.226


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