--- loncom/homework/grades.pm 2007/10/17 09:40:49 1.460 +++ loncom/homework/grades.pm 2007/10/25 00:47:24 1.463 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.460 2007/10/17 09:40:49 foxr Exp $ +# $Id: grades.pm,v 1.463 2007/10/25 00:47:24 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -91,7 +91,7 @@ sub get_response_bubbles { my $selected = ""; for (my $bline = 0; $bline < $bubble_lines; $bline++) { - $selected .= $$parsed_line{"scantron.$bubble_line.answer"}; + $selected .= $$parsed_line{"scantron.$bubble_line.answer"}.":"; $bubble_line++; } return $selected; @@ -3912,7 +3912,8 @@ sub csvuploadassign { if ($wgt) { $entries{$fields{$dest}}=~s/\s//g; my $pcr=$entries{$fields{$dest}} / $wgt; - my $award='correct_by_override'; + my $award=($pcr == 0) ? 'incorrect_by_override' + : 'correct_by_override'; $grades{"resource.$part.awarded"}=$pcr; $grades{"resource.$part.solved"}=$award; $points{$part}=1; @@ -5312,7 +5313,7 @@ sub scantron_parse_scanline { if ($bubble =~ /\d/) { $record{"scantron.$ansnum.answer"} = $alphabet[$bubble]; } else { - $record{"scantron.$ansnum.answer"}=''; + $record{"scantron.$ansnum.answer"}=' '; } $ansnum++; } @@ -5383,20 +5384,22 @@ sub scantron_parse_scanline { my $first_answer = $ansnum; for (my $ans =0; $ans < $answers_needed; $ans++) { - $record{"scantron.$ansnum.answer"} = ''; - $ans++; + my $item = $first_answer+$ans; + $record{"scantron.$item.answer"} = ''; } my @ans=@array; - my $i=length($ans[0]);shift(@ans); + my $i=0; + my $increment = 0; while ($#ans) { - $i+=length($ans[0])+1; - my $line = $i/$$scantron_config{'Qlength'} + $first_answer; + $i+=length($ans[0]) + $increment; + my $line = int($i/$$scantron_config{'Qlength'} + $first_answer); my $bubble = $i%$$scantron_config{'Qlength'}; - $record{"scantron.$line.answer"}.=$alphabet[$bubble]; shift(@ans); + $increment = 1; } + $ansnum += $answers_needed; } } } @@ -6432,7 +6435,7 @@ ENDSCRIPT $r->print("

Please indicate which bubble should be used for grading

"); foreach my $question (@{$arg}) { my $selected = &get_response_bubbles($scan_record, $question); - my @select_array = split('',$selected); + my @select_array = split(/:/,$selected); &scantron_bubble_selector($r,$scan_config,$question, @select_array); } @@ -6465,17 +6468,18 @@ ENDSCRIPT $r - Apache request object $scan_config - hash from &get_scantron_config() $quest - number of the bubble line to make a corrector for - $selected - array of letters of previously selected bubbles + $lines - array of answer lines. =cut sub scantron_bubble_selector { - my ($r,$scan_config,$quest,@selected)=@_; + my ($r,$scan_config,$quest,@lines)=@_; my $max=$$scan_config{'Qlength'}; + my $scmode=$$scan_config{'Qon'}; - my $bubble_length = scalar(@selected); + my $bubble_length = scalar(@lines); if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; } @@ -6491,7 +6495,7 @@ sub scantron_bubble_selector { if ($l != 0) { $r->print(''); } - + my @selected = split(//,$lines[$l]); for (my $i=0;$i<$max;$i++) { $r->print("\n".''); if ($selected[0] eq $alphabet[$i]) { @@ -7191,10 +7195,6 @@ sub grading_menu { my $probTitle = &Apache::lonnet::gettitle($symb); my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle); - # - # Define menu data - $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb); - my ($table) = &showResourceInfo($symb,$env{'form.probTitle'}); $request->print($table); my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb), 'handgrade'=>$hdgrade,