Diff for /loncom/homework/grades.pm between versions 1.478 and 1.479

version 1.478, 2007/11/03 00:18:37 version 1.479, 2007/11/05 10:19:03
Line 42  use Apache::Constants qw(:common); Line 42  use Apache::Constants qw(:common);
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonenc;  use Apache::lonenc;
 use String::Similarity;  use String::Similarity;
   use Data::Dumper;
 use LONCAPA;  use LONCAPA;
   
 use POSIX qw(floor);  use POSIX qw(floor);
Line 5116  sub username_to_idmap { Line 5117  sub username_to_idmap {
   
 sub scantron_fixup_scanline {  sub scantron_fixup_scanline {
     my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_;      my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_;
       
       
     if ($field eq 'ID') {      if ($field eq 'ID') {
  if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) {   if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) {
     return ($line,1,'New value too large');      return ($line,1,'New value too large');
Line 5147  sub scantron_fixup_scanline { Line 5149  sub scantron_fixup_scanline {
    $$scantron_config{'CODElength'})=$args->{'CODE'};     $$scantron_config{'CODElength'})=$args->{'CODE'};
  }   }
     } elsif ($field eq 'answer') {      } elsif ($field eq 'answer') {
    &scantron_get_maxbubble(); # Need the bubble counter info.
  my $length=$scantron_config->{'Qlength'};   my $length=$scantron_config->{'Qlength'};
  my $off=$scantron_config->{'Qoff'};   my $off=$scantron_config->{'Qoff'};
  my $on=$scantron_config->{'Qon'};   my $on=$scantron_config->{'Qon'};
  my $answer=${off}x$length;   my $answer=${off}x$length;
  if ($args->{'response'} eq 'none') {          my $question_number = $args->{'question'} -1;
     &scan_data($scan_data,          my $first_position  = $first_bubble_line{$question_number};
        "$whichline.no_bubble.".$args->{'question'},'1');   my $bubble_count    = $bubble_lines_per_response{$question_number};
  } else {          my $bubbles_per_line= $$scantron_config{'Qlength'};
     if ($on eq 'letter') {          my $final_answer;
  my @alphabet=('A'..'Z');          if ($$scantron_config{'Qon'} eq 'letter'  ||
  $answer=$alphabet[$args->{'response'}];      $$scantron_config{'Qon'} eq 'number') { 
     } elsif ($on eq 'number') {      $bubbles_per_line = 10;
  $answer=$args->{'response'}+1;   }
  if ($answer == 10) { $answer = '0'; }   if (defined $args->{'response'}) {
       
       if ($args->{'response'} eq 'none') {
    &scan_data($scan_data,
      "$whichline.no_bubble.".$args->{'question'},'1');
     } else {      } else {
  substr($answer,$args->{'response'},1)=$on;   my ($bubble_line, $bubble_number) = split(/:/,$args->{'response'});
    if ($on eq 'letter') {
       my @alphabet=('A'..'Z');
       $answer=$alphabet[$bubble_number];
    } elsif ($on eq 'number') {
       $answer=$args->$bubble_number+1;
       if ($answer == 10) { $answer = '0'; }
    } else {
       substr($answer,$args->{'response'},1)=$on;
    }
    my $before = Dumper($scan_data);
    &scan_data($scan_data,
      "$whichline.no_bubble.".$args->{'question'},undef,'1');
    my $after = Dumper($scan_data);
    for (my $l = 0; $l < $bubble_count; $l++) {
       if ($l eq $bubble_line) {
    $final_answer .= $answer;
       } else {
    $final_answer .= ' ';
       }
    }
     }      }
     &scan_data($scan_data,      # $where=$length*($args->{'question'}-1)+$scantron_config->{'Qstart'};
        "$whichline.no_bubble.".$args->{'question'},undef,'1');      #substr($line,$where-1,$length)=$answer;
       substr($line, 
      $scantron_config->{'Qstart'}+$first_position-1,
      $bubbles_per_line) = $final_answer;
  }   }
  my $where=$length*($args->{'question'}-1)+$scantron_config->{'Qstart'};  
  substr($line,$where-1,$length)=$answer;  
     }      }
     return $line;      return $line;
 }  }
Line 6492  ENDSCRIPT Line 6520  ENDSCRIPT
  foreach my $question (@{$arg}) {   foreach my $question (@{$arg}) {
     my $selected  = &get_response_bubbles($scan_record, $question);      my $selected  = &get_response_bubbles($scan_record, $question);
     my @select_array = split(/:/,$selected);      my @select_array = split(/:/,$selected);
       &Apache::lonnet::logthis("Questnum: $question, bubbles: $selected scanline $i");
     &scantron_bubble_selector($r,$scan_config,$question,      &scantron_bubble_selector($r,$scan_config,$question,
       @select_array);        @select_array);
  }   }
Line 6546  sub scantron_bubble_selector { Line 6575  sub scantron_bubble_selector {
   
     my $total_lines = $lines*2;      my $total_lines = $lines*2;
     my @alphabet=('A'..'Z');      my @alphabet=('A'..'Z');
   
     $r->print("<table border='1'><tr><td rowspan='".$total_lines."'>$quest</td>");      $r->print("<table border='1'><tr><td rowspan='".$total_lines."'>$quest</td>");
   
     for (my $l = 0; $l < $lines; $l++) {      for (my $l = 0; $l < $lines; $l++) {
Line 6579  sub scantron_bubble_selector { Line 6609  sub scantron_bubble_selector {
  #        multiline questions (different values e.g..).   #        multiline questions (different values e.g..).
   
  for (my $i=0;$i<$max;$i++) {   for (my $i=0;$i<$max;$i++) {
       my $value = "$l:$i"; # Relative bubble line #: Bubble in line.
     $r->print("\n".      $r->print("\n".
       '<td><label><input type="radio" name="scantron_correct_Q_'.        '<td><label><input type="radio" name="scantron_correct_Q_'.
       $quest.'" value="'.$i.'" />'.$alphabet[$i]."</label></td>");        $quest.'" value="'.$value.'" />'.$alphabet[$i]."</label></td>");
  }   }
  $r->print('</tr>');   $r->print('</tr>');
   
Line 6769  sub scantron_validate_doublebubble { Line 6800  sub scantron_validate_doublebubble {
     my ($scanlines,$scan_data)=&scantron_getfile();      my ($scanlines,$scan_data)=&scantron_getfile();
   
     &scantron_get_maxbubble(); # parse needs the bubble line array.      &scantron_get_maxbubble(); # parse needs the bubble line array.
       &Apache::lonnet::logthis("validate_double_bubble");
   
     for (my $i=0;$i<=$scanlines->{'count'};$i++) {      for (my $i=0;$i<=$scanlines->{'count'};$i++) {
  my $line=&scantron_get_line($scanlines,$scan_data,$i);   my $line=&scantron_get_line($scanlines,$scan_data,$i);
Line 6776  sub scantron_validate_doublebubble { Line 6808  sub scantron_validate_doublebubble {
  my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,   my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,
  $scan_data);   $scan_data);
  if (!defined($$scan_record{'scantron.doubleerror'})) { next; }   if (!defined($$scan_record{'scantron.doubleerror'})) { next; }
    &Apache::lonnet::logthis("Double found for line $i : $line");
  &scantron_get_correction($r,$i,$scan_record,\%scantron_config,$line,   &scantron_get_correction($r,$i,$scan_record,\%scantron_config,$line,
  'doublebubble',   'doublebubble',
  $$scan_record{'scantron.doubleerror'});   $$scan_record{'scantron.doubleerror'});

Removed from v.1.478  
changed lines
  Added in v.1.479


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