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

version 1.479, 2007/11/05 10:19:03 version 1.484, 2007/11/06 19:19:54
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 4100  LISTJAVASCRIPT Line 4099  LISTJAVASCRIPT
     $request->print($result);      $request->print($result);
   
     my $studentTable.='&nbsp;<b>Select a student you wish to grade and then click on the Next button.</b><br />'.      my $studentTable.='&nbsp;<b>Select a student you wish to grade and then click on the Next button.</b><br />'.
  '<table border="0"><tr><td bgcolor="#777777">'.   &Apache::loncommon::start_data_table().
  '<table border="0"><tr bgcolor="#e6ffff">'.   &Apache::loncommon::start_data_table_header_row().
  '<td align="right">&nbsp;<b>No.</b></td>'.   '<th align="right">&nbsp;No.</th>'.
  '<td>'.&nameUserString('header').'</td>'.   '<th>'.&nameUserString('header').'</th>'.
  '<td align="right">&nbsp;<b>No.</b></td>'.   '<th align="right">&nbsp;No.</th>'.
  '<td>'.&nameUserString('header').'</td></tr>';   '<th>'.&nameUserString('header').'</th>'.
    &Apache::loncommon::end_data_table_header_row();
     
     my (undef,undef,$fullname) = &getclasslist($getsec,'1');      my (undef,undef,$fullname) = &getclasslist($getsec,'1');
     my $ptr = 1;      my $ptr = 1;
Line 4117  LISTJAVASCRIPT Line 4117  LISTJAVASCRIPT
      return $a cmp $b;       return $a cmp $b;
  } (keys(%$fullname))) {   } (keys(%$fullname))) {
  my ($uname,$udom) = split(/:/,$student);   my ($uname,$udom) = split(/:/,$student);
  $studentTable.=($ptr%2 == 1 ? '<tr bgcolor="#ffffe6">' : '</td>');   $studentTable.=($ptr%2==1 ? &Apache::loncommon::start_data_table_row()
                                     : '</td>');
  $studentTable.='<td align="right">'.$ptr.'&nbsp;</td>';   $studentTable.='<td align="right">'.$ptr.'&nbsp;</td>';
  $studentTable.='<td>&nbsp;<label><input type="radio" name="student" value="'.$student.'" /> '   $studentTable.='<td>&nbsp;<label><input type="radio" name="student" value="'.$student.'" /> '
     .&nameUserString(undef,$$fullname{$student},$uname,$udom)."</label>\n";      .&nameUserString(undef,$$fullname{$student},$uname,$udom)."</label>\n";
  $studentTable.=($ptr%2 == 0 ? '</td></tr>' : '');   $studentTable.=
       ($ptr%2 == 0 ? '</td>'.&Apache::loncommon::end_data_table_row() 
                            : '');
  $ptr++;   $ptr++;
     }      }
     $studentTable.='</td><td>&nbsp;</td><td>&nbsp;</td></tr>' if ($ptr%2 == 0);      if ($ptr%2 == 0) {
     $studentTable.='</table></td></tr></table>'."\n";   $studentTable.='</td><td>&nbsp;</td><td>&nbsp;</td>'.
       &Apache::loncommon::end_data_table_row();
       }
       $studentTable.=&Apache::loncommon::end_data_table()."\n";
     $studentTable.='<input type="button" '.      $studentTable.='<input type="button" '.
  'onClick="javascript:checkPickOne(this.form);"value="Next->" /></form>'."\n";   'onClick="javascript:checkPickOne(this.form);"value="Next->" /></form>'."\n";
   
Line 4225  sub displayPage { Line 4231  sub displayPage {
   
     $studentTable.='&nbsp;<b>Note:</b> Problems graded correct by the computer are marked with a '.$checkIcon.      $studentTable.='&nbsp;<b>Note:</b> Problems graded correct by the computer are marked with a '.$checkIcon.
  ' symbol.'."\n".   ' symbol.'."\n".
  '<table border="0"><tr><td bgcolor="#777777">'.   &Apache::loncommon::start_data_table().
  '<table border="0"><tr bgcolor="#e6ffff">'.   &Apache::loncommon::start_data_table_header_row().
  '<td align="center"><b>&nbsp;Prob.&nbsp;</b></td>'.   '<th align="center">&nbsp;Prob.&nbsp;</th>'.
  '<td><b>&nbsp;'.($env{'form.vProb'} eq 'no' ? 'Title' : 'Problem Text').'/Grade</b></td></tr>';   '<th>&nbsp;'.($env{'form.vProb'} eq 'no' ? 'Title' : 'Problem Text').'/Grade</th>'.
    &Apache::loncommon::end_data_table_header_row();
   
     &Apache::lonxml::clear_problem_counter();      &Apache::lonxml::clear_problem_counter();
     my ($depth,$question,$prob) = (1,1,1);      my ($depth,$question,$prob) = (1,1,1);
Line 4242  sub displayPage { Line 4249  sub displayPage {
     my $parts = $curRes->parts();      my $parts = $curRes->parts();
             my $title = $curRes->compTitle();              my $title = $curRes->compTitle();
     my $symbx = $curRes->symb();      my $symbx = $curRes->symb();
     $studentTable.='<tr bgcolor="#ffffe6"><td align="center" valign="top" >'.$prob.      $studentTable.=
    &Apache::loncommon::start_data_table_row().
    '<td align="center" valign="top" >'.$prob.
  (scalar(@{$parts}) == 1 ? '' : '<br />('.scalar(@{$parts}).'&nbsp;parts)').'</td>';   (scalar(@{$parts}) == 1 ? '' : '<br />('.scalar(@{$parts}).'&nbsp;parts)').'</td>';
     $studentTable.='<td valign="top">';      $studentTable.='<td valign="top">';
     my %form = ('CODE' => $env{'form.CODE'},);      my %form = ('CODE' => $env{'form.CODE'},);
Line 4450  sub updateGradeByPage { Line 4459  sub updateGradeByPage {
     my $iterator = $navmap->getIterator($map->map_start(),      my $iterator = $navmap->getIterator($map->map_start(),
  $map->map_finish());   $map->map_finish());
   
     my $studentTable='<table border="0"><tr><td bgcolor="#777777">'.      my $studentTable=
  '<table border="0"><tr bgcolor="#e6ffff">'.   &Apache::loncommon::start_data_table().
  '<td align="center"><b>&nbsp;Prob.&nbsp;</b></td>'.   &Apache::loncommon::start_data_table_header_row().
  '<td><b>&nbsp;Title&nbsp;</b></td>'.   '<th align="center">&nbsp;Prob.&nbsp;</th>'.
  '<td><b>&nbsp;Previous Score&nbsp;</b></td>'.   '<th>&nbsp;Title&nbsp;</th>'.
  '<td><b>&nbsp;New Score&nbsp;</b></td></tr>';   '<th>&nbsp;Previous Score&nbsp;</th>'.
    '<th>&nbsp;New Score&nbsp;</th>'.
    &Apache::loncommon::end_data_table_header_row();
   
     $iterator->next(); # skip the first BEGIN_MAP      $iterator->next(); # skip the first BEGIN_MAP
     my $curRes = $iterator->next(); # for "current resource"      my $curRes = $iterator->next(); # for "current resource"
Line 4468  sub updateGradeByPage { Line 4479  sub updateGradeByPage {
     my $parts = $curRes->parts();      my $parts = $curRes->parts();
             my $title = $curRes->compTitle();              my $title = $curRes->compTitle();
     my $symbx = $curRes->symb();      my $symbx = $curRes->symb();
     $studentTable.='<tr bgcolor="#ffffe6"><td align="center" valign="top" >'.$prob.      $studentTable.=
    &Apache::loncommon::start_data_table_row().
    '<td align="center" valign="top" >'.$prob.
  (scalar(@{$parts}) == 1 ? '' : '<br />('.scalar(@{$parts}).'&nbsp;parts)').'</td>';   (scalar(@{$parts}) == 1 ? '' : '<br />('.scalar(@{$parts}).'&nbsp;parts)').'</td>';
     $studentTable.='<td valign="top">&nbsp;<b>'.$title.'</b>&nbsp;</td>';      $studentTable.='<td valign="top">&nbsp;<b>'.$title.'</b>&nbsp;</td>';
   
Line 4556  sub updateGradeByPage { Line 4569  sub updateGradeByPage {
   
     $studentTable.='<td valign="top">'.$displayPts[0].'</td>'.      $studentTable.='<td valign="top">'.$displayPts[0].'</td>'.
  '<td valign="top">'.$displayPts[1].'</td>'.   '<td valign="top">'.$displayPts[1].'</td>'.
  '</tr>';   &Apache::loncommon::end_data_table_row();
   
     $prob++;      $prob++;
  }   }
         $curRes = $iterator->next();          $curRes = $iterator->next();
     }      }
   
     $studentTable.='</td></tr></table></td></tr></table>';      $studentTable.=&Apache::loncommon::end_data_table();
     $studentTable.=&show_grading_menu_form($env{'form.symb'});      $studentTable.=&show_grading_menu_form($env{'form.symb'});
     my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' :      my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' :
   'The scores were changed for '.    'The scores were changed for '.
Line 5150  sub scantron_fixup_scanline { Line 5163  sub scantron_fixup_scanline {
  }   }
     } elsif ($field eq 'answer') {      } elsif ($field eq 'answer') {
  &scantron_get_maxbubble(); # Need the bubble counter info.   &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 $question_number = $args->{'question'} -1;          my $question_number = $args->{'question'} -1;
         my $first_position  = $first_bubble_line{$question_number};          my $first_position  = $first_bubble_line{$question_number};
  my $bubble_count    = $bubble_lines_per_response{$question_number};   my $bubble_count    = $bubble_lines_per_response{$question_number};
         my $bubbles_per_line= $$scantron_config{'Qlength'};          my $bubbles_per_line= $$scantron_config{'Qlength'};
    my $answer=${off}x($bubbles_per_line*$bubble_count);
         my $final_answer;          my $final_answer;
         if ($$scantron_config{'Qon'} eq 'letter'  ||          if ($$scantron_config{'Qon'} eq 'letter'  ||
     $$scantron_config{'Qon'} eq 'number') {       $$scantron_config{'Qon'} eq 'number') { 
Line 5174  sub scantron_fixup_scanline { Line 5187  sub scantron_fixup_scanline {
     my @alphabet=('A'..'Z');      my @alphabet=('A'..'Z');
     $answer=$alphabet[$bubble_number];      $answer=$alphabet[$bubble_number];
  } elsif ($on eq 'number') {   } elsif ($on eq 'number') {
     $answer=$args->$bubble_number+1;      $answer= $bubble_number+1;
     if ($answer == 10) { $answer = '0'; }      if ($answer == 10) { $answer = '0'; }
  } else {   } else {
     substr($answer,$args->{'response'},1)=$on;      substr($answer,$bubble_number+$bubble_line*$bubbles_per_line,1)=$on;
       $final_answer = $answer;
  }   }
  my $before = Dumper($scan_data);  
  &scan_data($scan_data,   &scan_data($scan_data,
    "$whichline.no_bubble.".$args->{'question'},undef,'1');     "$whichline.no_bubble.".$args->{'question'},undef,'1');
  my $after = Dumper($scan_data);  
  for (my $l = 0; $l < $bubble_count; $l++) {   # Positional notation already has the right final answer length..
     if ($l eq $bubble_line) {  
  $final_answer .= $answer;   if (($on eq 'letter') || ($on eq 'number')) {
     } else {      for (my $l = 0; $l < $bubble_count; $l++) {
  $final_answer .= ' ';   if ($l eq $bubble_line) {
       $final_answer .= $answer;
    } else {
       $final_answer .= ' ';
    }
     }      }
  }   }
     }      }
Line 5195  sub scantron_fixup_scanline { Line 5212  sub scantron_fixup_scanline {
     #substr($line,$where-1,$length)=$answer;      #substr($line,$where-1,$length)=$answer;
     substr($line,       substr($line, 
    $scantron_config->{'Qstart'}+$first_position-1,     $scantron_config->{'Qstart'}+$first_position-1,
    $bubbles_per_line) = $final_answer;     $bubbles_per_line*$length) = $final_answer;
  }   }
     }      }
     return $line;      return $line;
Line 5443  sub scantron_parse_scanline { Line 5460  sub scantron_parse_scanline {
  if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) {   if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) {
     push(@{$record{"scantron.missingerror"}},$questnum);      push(@{$record{"scantron.missingerror"}},$questnum);
  }   }
     } elsif (scalar(@array) lt 2) {  
    #  If the bubble is not the last position, there will be
    # 2 elements.  If it is the last position, there will be 1 element.
   
       } elsif (scalar(@array) le 2) {
   
  my $location      = length($array[0]);   my $location      = length($array[0]);
  my $line_num      = $location / $$scantron_config{'Qlength'};   my $line_num      = int($location / $$scantron_config{'Qlength'});
  my $bubble        = $alphabet[$location % $$scantron_config{'Qlength'}];   my $bubble        = $alphabet[$location % $$scantron_config{'Qlength'}];
   
   
  for (my $ans = 0; $ans < $answers_needed; $ans++) {   for (my $ans = 0; $ans < $answers_needed; $ans++) {
     if ($ans eq $line_num) {      if ($ans eq $line_num) {
Line 6520  ENDSCRIPT Line 6542  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 6800  sub scantron_validate_doublebubble { Line 6821  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 6808  sub scantron_validate_doublebubble { Line 6828  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.479  
changed lines
  Added in v.1.484


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