--- loncom/homework/grades.pm 2007/11/05 10:19:03 1.479 +++ loncom/homework/grades.pm 2007/11/06 19:19:54 1.484 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.479 2007/11/05 10:19:03 foxr Exp $ +# $Id: grades.pm,v 1.484 2007/11/06 19:19:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,6 @@ use Apache::Constants qw(:common); use Apache::lonlocal; use Apache::lonenc; use String::Similarity; -use Data::Dumper; use LONCAPA; use POSIX qw(floor); @@ -4100,12 +4099,13 @@ LISTJAVASCRIPT $request->print($result); my $studentTable.=' Select a student you wish to grade and then click on the Next button.
'. - '
'. - ''. - ''. - ''. - ''. - ''; + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + ''. + ''. + ''. + &Apache::loncommon::end_data_table_header_row(); my (undef,undef,$fullname) = &getclasslist($getsec,'1'); my $ptr = 1; @@ -4117,15 +4117,21 @@ LISTJAVASCRIPT return $a cmp $b; } (keys(%$fullname))) { my ($uname,$udom) = split(/:/,$student); - $studentTable.=($ptr%2 == 1 ? '' : ''); + $studentTable.=($ptr%2==1 ? &Apache::loncommon::start_data_table_row() + : ''); $studentTable.=''; $studentTable.='' : ''); + $studentTable.= + ($ptr%2 == 0 ? ''.&Apache::loncommon::end_data_table_row() + : ''); $ptr++; } - $studentTable.='' if ($ptr%2 == 0); - $studentTable.='
 No.'.&nameUserString('header').' No.'.&nameUserString('header').'
 No.'.&nameUserString('header').' No.'.&nameUserString('header').'
'.$ptr.'  \n"; - $studentTable.=($ptr%2 == 0 ? '
  
'."\n"; + if ($ptr%2 == 0) { + $studentTable.='  '. + &Apache::loncommon::end_data_table_row(); + } + $studentTable.=&Apache::loncommon::end_data_table()."\n"; $studentTable.=''."\n"; @@ -4225,10 +4231,11 @@ sub displayPage { $studentTable.=' Note: Problems graded correct by the computer are marked with a '.$checkIcon. ' symbol.'."\n". - '
'. - ''. - ''. - ''; + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + ''. + &Apache::loncommon::end_data_table_header_row(); &Apache::lonxml::clear_problem_counter(); my ($depth,$question,$prob) = (1,1,1); @@ -4242,7 +4249,9 @@ sub displayPage { my $parts = $curRes->parts(); my $title = $curRes->compTitle(); my $symbx = $curRes->symb(); - $studentTable.=''; $studentTable.='
 Prob.  '.($env{'form.vProb'} eq 'no' ? 'Title' : 'Problem Text').'/Grade
 Prob.  '.($env{'form.vProb'} eq 'no' ? 'Title' : 'Problem Text').'/Grade
'.$prob. + $studentTable.= + &Apache::loncommon::start_data_table_row(). + ''.$prob. (scalar(@{$parts}) == 1 ? '' : '
('.scalar(@{$parts}).' parts)').'
'; my %form = ('CODE' => $env{'form.CODE'},); @@ -4450,12 +4459,14 @@ sub updateGradeByPage { my $iterator = $navmap->getIterator($map->map_start(), $map->map_finish()); - my $studentTable='
'. - ''. - ''. - ''. - ''. - ''; + my $studentTable= + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + ''. + ''. + ''. + &Apache::loncommon::end_data_table_header_row(); $iterator->next(); # skip the first BEGIN_MAP my $curRes = $iterator->next(); # for "current resource" @@ -4468,7 +4479,9 @@ sub updateGradeByPage { my $parts = $curRes->parts(); my $title = $curRes->compTitle(); my $symbx = $curRes->symb(); - $studentTable.=''; $studentTable.=''; @@ -4556,14 +4569,14 @@ sub updateGradeByPage { $studentTable.=''. ''. - ''; + &Apache::loncommon::end_data_table_row(); $prob++; } $curRes = $iterator->next(); } - $studentTable.='
 Prob.  Title  Previous Score  New Score 
 Prob.  Title  Previous Score  New Score 
'.$prob. + $studentTable.= + &Apache::loncommon::start_data_table_row(). + ''.$prob. (scalar(@{$parts}) == 1 ? '' : '
('.scalar(@{$parts}).' parts)').'
 '.$title.' '.$displayPts[0].''.$displayPts[1].'
'; + $studentTable.=&Apache::loncommon::end_data_table(); $studentTable.=&show_grading_menu_form($env{'form.symb'}); my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' : 'The scores were changed for '. @@ -5150,14 +5163,14 @@ sub scantron_fixup_scanline { } } 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 $on=$scantron_config->{'Qon'}; - my $answer=${off}x$length; my $question_number = $args->{'question'} -1; my $first_position = $first_bubble_line{$question_number}; my $bubble_count = $bubble_lines_per_response{$question_number}; my $bubbles_per_line= $$scantron_config{'Qlength'}; + my $answer=${off}x($bubbles_per_line*$bubble_count); my $final_answer; if ($$scantron_config{'Qon'} eq 'letter' || $$scantron_config{'Qon'} eq 'number') { @@ -5174,20 +5187,24 @@ sub scantron_fixup_scanline { my @alphabet=('A'..'Z'); $answer=$alphabet[$bubble_number]; } elsif ($on eq 'number') { - $answer=$args->$bubble_number+1; + $answer= $bubble_number+1; if ($answer == 10) { $answer = '0'; } } 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, "$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 .= ' '; + + # Positional notation already has the right final answer length.. + + if (($on eq 'letter') || ($on eq 'number')) { + for (my $l = 0; $l < $bubble_count; $l++) { + if ($l eq $bubble_line) { + $final_answer .= $answer; + } else { + $final_answer .= ' '; + } } } } @@ -5195,7 +5212,7 @@ sub scantron_fixup_scanline { #substr($line,$where-1,$length)=$answer; substr($line, $scantron_config->{'Qstart'}+$first_position-1, - $bubbles_per_line) = $final_answer; + $bubbles_per_line*$length) = $final_answer; } } return $line; @@ -5443,11 +5460,16 @@ sub scantron_parse_scanline { if (!&scan_data($scan_data,"$whichline.no_bubble.$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 $line_num = $location / $$scantron_config{'Qlength'}; + my $line_num = int($location / $$scantron_config{'Qlength'}); my $bubble = $alphabet[$location % $$scantron_config{'Qlength'}]; + for (my $ans = 0; $ans < $answers_needed; $ans++) { if ($ans eq $line_num) { @@ -6520,7 +6542,6 @@ ENDSCRIPT foreach my $question (@{$arg}) { my $selected = &get_response_bubbles($scan_record, $question); my @select_array = split(/:/,$selected); - &Apache::lonnet::logthis("Questnum: $question, bubbles: $selected scanline $i"); &scantron_bubble_selector($r,$scan_config,$question, @select_array); } @@ -6800,7 +6821,6 @@ sub scantron_validate_doublebubble { my ($scanlines,$scan_data)=&scantron_getfile(); &scantron_get_maxbubble(); # parse needs the bubble line array. - &Apache::lonnet::logthis("validate_double_bubble"); for (my $i=0;$i<=$scanlines->{'count'};$i++) { my $line=&scantron_get_line($scanlines,$scan_data,$i); @@ -6808,7 +6828,6 @@ sub scantron_validate_doublebubble { my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, $scan_data); 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, 'doublebubble', $$scan_record{'scantron.doubleerror'});