Diff for /loncom/homework/grades.pm between versions 1.433 and 1.436

version 1.433, 2007/08/22 18:27:03 version 1.436, 2007/08/29 13:41:32
Line 45  use LONCAPA; Line 45  use LONCAPA;
   
 use POSIX qw(floor);  use POSIX qw(floor);
   
   
 my %perm=();  my %perm=();
   my %bubble_lines_per_response;     # no. bubble lines for each response.
                                      # index is "symb.part_id"
   
   
 # ----- These first few routines are general use routines.----  # ----- These first few routines are general use routines.----
 #  #
Line 194  sub showResourceInfo { Line 198  sub showResourceInfo {
     return $result,$responseType,$hdgrade,$partlist,$handgrade;      return $result,$responseType,$hdgrade,$partlist,$handgrade;
 }  }
   
   sub reset_caches {
       &reset_analyze_cache();
       &reset_perm();
   }
   
   {
       my %analyze_cache;
   
 sub get_order {      sub reset_analyze_cache {
     my ($partid,$respid,$symb,$uname,$udom)=@_;   undef(%analyze_cache);
     my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);      }
     $url=&Apache::lonnet::clutter($url);  
     my $subresult=&Apache::lonnet::ssi($url,      sub get_analyze {
        ('grade_target' => 'analyze'),   my ($symb,$uname,$udom)=@_;
        ('grade_domain' => $udom),   my $key = "$symb\0$uname\0$udom";
        ('grade_symb' => $symb),   return $analyze_cache{$key} if (exists($analyze_cache{$key}));
        ('grade_courseid' =>   
         $env{'request.course.id'}),   my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
        ('grade_username' => $uname));   $url=&Apache::lonnet::clutter($url);
     (undef,$subresult)=split(/_HASH_REF__/,$subresult,2);   my $subresult=&Apache::lonnet::ssi($url,
     my %analyze=&Apache::lonnet::str2hash($subresult);     ('grade_target' => 'analyze'),
     return ($analyze{"$partid.$respid.shown"});     ('grade_domain' => $udom),
      ('grade_symb' => $symb),
      ('grade_courseid' => 
       $env{'request.course.id'}),
      ('grade_username' => $uname));
    (undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
    my %analyze=&Apache::lonnet::str2hash($subresult);
    return $analyze_cache{$key} = \%analyze;
       }
   
       sub get_order {
    my ($partid,$respid,$symb,$uname,$udom)=@_;
    my $analyze = &get_analyze($symb,$uname,$udom);
    return $analyze->{"$partid.$respid.shown"};
       }
   
       sub get_radiobutton_correct_foil {
    my ($partid,$respid,$symb,$uname,$udom)=@_;
    my $analyze = &get_analyze($symb,$uname,$udom);
    foreach my $foil (@{&get_order($partid,$respid,$symb,$uname,$udom)}) {
       if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') {
    return $foil;
       }
    }
       }
 }  }
   
 #--- Clean response type for display  #--- Clean response type for display
 #--- Currently filters option/rank/radiobutton/match/essay/Task  #--- Currently filters option/rank/radiobutton/match/essay/Task
 #        response types only.  #        response types only.
Line 258  sub cleanRecord { Line 294  sub cleanRecord {
     } elsif ($response eq 'radiobutton') {      } elsif ($response eq 'radiobutton') {
  my %answer=&Apache::lonnet::str2hash($answer);   my %answer=&Apache::lonnet::str2hash($answer);
  my ($toprow,$bottomrow);   my ($toprow,$bottomrow);
  my $correct=($order->[0])+1;   my $correct = 
  for (my $i=1;$i<=$#$order;$i++) {      &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom);
     my $foil=$order->[$i];   foreach my $foil (@$order) {
     if (exists($answer{$foil})) {      if (exists($answer{$foil})) {
  if ($i == $correct) {   if ($foil eq $correct) {
     $toprow.='<td><b>true</b></td>';      $toprow.='<td><b>true</b></td>';
  } else {   } else {
     $toprow.='<td><i>true</i></td>';      $toprow.='<td><i>true</i></td>';
Line 1665  sub build_section_inputs { Line 1701  sub build_section_inputs {
         $section_inputs .= '<input type="hidden" name="section" value="all" />'."\n";          $section_inputs .= '<input type="hidden" name="section" value="all" />'."\n";
     } else {      } else {
         my @sections = &Apache::loncommon::get_env_multiple('form.section');          my @sections = &Apache::loncommon::get_env_multiple('form.section');
         foreach my $section(@sections) {          foreach my $section (@sections) {
             $section_inputs .= '<input type="hidden" name="section" value="'.$section.'" />'."\n";              $section_inputs .= '<input type="hidden" name="section" value="'.$section.'" />'."\n";
         }          }
     }      }
Line 4396  one of the predefined configurations for Line 4432  one of the predefined configurations for
 like.  like.
   
 Next each scanline is checked for any errors of either 'missing  Next each scanline is checked for any errors of either 'missing
 bubbles' (it's an error because it may have been missed scanned  bubbles' (it's an error because it may have been mis-scanned
 because too light bubbling), 'double bubble' (each bubble line should  because too light bubbling), 'double bubble' (each bubble line should
 have no more that one letter picked), invalid or duplicated CODE,  have no more that one letter picked), invalid or duplicated CODE,
 invalid student ID  invalid student ID
Line 4407  username:domain. Line 4443  username:domain.
   
 During the validation phase the instructor can choose to skip scanlines.   During the validation phase the instructor can choose to skip scanlines. 
   
 After the validation phase, there is now 3 bubble sheet files  After the validation phase, there are now 3 bubble sheet files
   
   scantron_original_filename (unmodified original file)    scantron_original_filename (unmodified original file)
   scantron_corrected_filename (file where the corrected information has replaced the original information)    scantron_corrected_filename (file where the corrected information has replaced the original information)
Line 6477  sub scantron_validate_doublebubble { Line 6513  sub scantron_validate_doublebubble {
 =cut  =cut
   
 sub scantron_get_maxbubble {      sub scantron_get_maxbubble {    
   
     if (defined($env{'form.scantron_maxbubble'}) &&      if (defined($env{'form.scantron_maxbubble'}) &&
  $env{'form.scantron_maxbubble'}) {   $env{'form.scantron_maxbubble'}) {
  return $env{'form.scantron_maxbubble'};   return $env{'form.scantron_maxbubble'};
Line 6491  sub scantron_get_maxbubble { Line 6528  sub scantron_get_maxbubble {
   
     &Apache::lonxml::clear_problem_counter();      &Apache::lonxml::clear_problem_counter();
   
       my $uname       = $env{'form.student'};
       my $udom        = $env{'form.userdom'};
       my $cid         = $env{'request.course.id'};
       my $total_lines = 0;
       %bubble_lines_per_response = ();
   
     foreach my $resource (@resources) {      foreach my $resource (@resources) {
    my $symb = $resource->symb();
  my $result=&Apache::lonnet::ssi($resource->src(),   my $result=&Apache::lonnet::ssi($resource->src(),
  ('symb' => $resource->symb()));   ('symb' => $resource->symb()),
    ('grade_target' => 'analyze'),
    ('grade_courseid' => $cid),
    ('grade_domain' => $udom),
    ('grade_username' => $uname));
    my (undef, $an) =
       split(/_HASH_REF__/,$result, 2);
   
    my %analysis = &Apache::lonnet::str2hash($an);
   
   
   
    foreach my $part_id (@{$analysis{'parts'}}) {
       my $bubble_lines = $analysis{"$part_id.bubble_lines"}[0];
       if (!$bubble_lines) {
    $bubble_lines = 1;
       }
       $bubble_lines_per_response{"$symb.$part_id"} = $bubble_lines;
       $total_lines = $total_lines + $bubble_lines;
    }
   
     }      }
     &Apache::lonnet::delenv('scantron\.');      &Apache::lonnet::delenv('scantron\.');
     $env{'form.scantron_maxbubble'} =      $env{'form.scantron_maxbubble'} =
  &Apache::lonxml::get_problem_counter()-1;   $total_lines;
   
     return $env{'form.scantron_maxbubble'};      return $env{'form.scantron_maxbubble'};
 }  }
   
Line 7515  ENDHEADER Line 7578  ENDHEADER
 sub handler {  sub handler {
     my $request=$_[0];      my $request=$_[0];
   
     &reset_perm();      &reset_caches();
     if ($env{'browser.mathml'}) {      if ($env{'browser.mathml'}) {
  &Apache::loncommon::content_type($request,'text/xml');   &Apache::loncommon::content_type($request,'text/xml');
     } else {      } else {
Line 7628  sub handler { Line 7691  sub handler {
  }   }
     }      }
     $request->print(&Apache::loncommon::end_page());      $request->print(&Apache::loncommon::end_page());
       &reset_caches();
     return '';      return '';
 }  }
   

Removed from v.1.433  
changed lines
  Added in v.1.436


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