Diff for /loncom/homework/lonhomework.pm between versions 1.216 and 1.224

version 1.216, 2005/08/16 16:31:14 version 1.224, 2005/11/15 18:38:47
Line 94  sub get_target { Line 94  sub get_target {
  if ( defined($env{'form.submitted'}) &&   if ( defined($env{'form.submitted'}) &&
      ( !defined($env{'form.resetdata'})) &&       ( !defined($env{'form.resetdata'})) &&
      ( !defined($env{'form.newrandomization'}))) {       ( !defined($env{'form.newrandomization'}))) {
     return ('grade', 'web','answer');      return ('grade', 'web');
  } else {   } else {
     return ('web','answer');      return ('web');
  }   }
     } elsif ($env{'request.state'} eq "construct") {      } elsif ($env{'request.state'} eq "construct") {
  if ( defined($env{'form.grade_target'}) ) {   if ( defined($env{'form.grade_target'}) ) {
Line 183  sub proctor_checked_in { Line 183  sub proctor_checked_in {
 $Apache::lonxml::browse='';  $Apache::lonxml::browse='';
 sub check_ip_acc {  sub check_ip_acc {
     my ($acc)=@_;      my ($acc)=@_;
     if (!defined($acc) || $acc =~ /^\s*$/) { return 1; }      &Apache::lonxml::debug("acc is $acc");
       if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { 
    return 1;
       }
     my $allowed=0;      my $allowed=0;
     my $ip=$ENV{'REMOTE_ADDR'};      my $ip=$ENV{'REMOTE_ADDR'};
     my $name;      my $name;
Line 578  sub handle_save_or_undo { Line 581  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 612  sub analyze { Line 613  sub analyze {
     &Apache::lonxml::debug("Analyze");      &Apache::lonxml::debug("Analyze");
     my $result;      my $result;
     my %overall;      my %overall;
       my %seedexample;
     my %allparts;      my %allparts;
     my $rndseed=$env{'form.rndseed'};      my $rndseed=$env{'form.rndseed'};
     &analyze_header($request);      &analyze_header($request);
Line 624  sub analyze { Line 626  sub analyze {
  &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,   &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,
  &mt('last problem'));   &mt('last problem'));
  if (&Apache::loncommon::connection_aborted($request)) { return; }   if (&Apache::loncommon::connection_aborted($request)) { return; }
           my $thisseed=$i+$rndseed;
  my $subresult=&Apache::lonnet::ssi($request->uri,   my $subresult=&Apache::lonnet::ssi($request->uri,
    ('grade_target' => 'analyze'),     ('grade_target' => 'analyze'),
    ('rndseed' => $i+$rndseed));     ('rndseed' => $thisseed));
  (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);   (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);
  my %analyze=&Apache::lonnet::str2hash($subresult);   my %analyze=&Apache::lonnet::str2hash($subresult);
  my @parts;   my @parts;
Line 638  sub analyze { Line 641  sub analyze {
     if ($analyze{$part.'.type'} eq 'numericalresponse' ||      if ($analyze{$part.'.type'} eq 'numericalresponse' ||
  $analyze{$part.'.type'} eq 'stringresponse' ||   $analyze{$part.'.type'} eq 'stringresponse' ||
  $analyze{$part.'.type'} eq 'formularesponse'   ) {   $analyze{$part.'.type'} eq 'formularesponse'   ) {
    my $concatanswer=join("\0",@{ $analyze{$part.'.answer'} });
    if (($concatanswer eq '') || ($concatanswer=~/^\@/)) {
       @{$analyze{$part.'.answer'}}=('<font color="red">'.&mt('Error').'</font>');
    }
  push( @{ $overall{$part.'.answer'} },   push( @{ $overall{$part.'.answer'} },
       [@{ $analyze{$part.'.answer'} }]);        [@{ $analyze{$part.'.answer'} }]);
                   $seedexample{join("\0",@{ $analyze{$part.'.answer'}})}=$thisseed;
     }      }
  }   }
     }      }
Line 649  sub analyze { Line 657  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><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 })}++;
     }      }
     $request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'</th></tr>');      $request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'<br />('
       .&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 align="right">'.   $request->print('<tr><td class="center">'.
  join('</td><td align="right">',split("\0",$answer)).   join('</td><td class="center">',split("\0",$answer)).
  '</td><td>('.$frequency{$answer}.   '</td><td class="center"><a href="'.$request->uri.'?rndseed='.$seedexample{$answer}.'">'.$frequency{$answer}.
  ')</td></tr>');   '</a></td></tr>');
     }      }
     $request->print('</table>');      $request->print('</table>');
  } else {   } else {
Line 706  sub editxmlmode { Line 715  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 759  sub renderpage { Line 766  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 770  sub renderpage { Line 779  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 910  EDITMENU Line 919  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 930  sub handler { Line 939  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.216  
changed lines
  Added in v.1.224


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