--- loncom/homework/grades.pm 2007/10/17 09:40:49 1.460 +++ loncom/homework/grades.pm 2007/10/24 09:51:47 1.462 @@ -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.462 2007/10/24 09:51:47 foxr 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; @@ -5312,7 +5312,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 +5383,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 +6434,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 +6467,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 +6494,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]) {