--- loncom/homework/grades.pm 2007/11/03 00:08:09 1.477 +++ loncom/homework/grades.pm 2007/11/05 10:19:03 1.479 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.477 2007/11/03 00:08:09 albertel Exp $ +# $Id: grades.pm,v 1.479 2007/11/05 10:19:03 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,7 @@ use Apache::Constants qw(:common); use Apache::lonlocal; use Apache::lonenc; use String::Similarity; +use Data::Dumper; use LONCAPA; use POSIX qw(floor); @@ -3394,8 +3395,8 @@ sub editgrades { } my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); foreach my $partid (@partid) { - $header .= 'Old Score'. - 'New Score'; + $header .= ''.&mt('Old Score').''. + ''.&mt('New Score').''; $columns{$partid}=2; foreach my $stores (@parts) { my ($part,$type) = &split_part_type($stores); @@ -3404,16 +3405,16 @@ sub editgrades { my $display=&Apache::lonnet::metadata($url,$stores.'.display'); $display =~ s/\[Part: (\w)+\]//; $display =~ s/Number of Attempts/Tries/; - $header .= 'Old '.$display.''. - 'New '.$display.''; + $header .= ''.&mt('Old '.$display).''. + ''.&mt('New '.$display).''; $columns{$partid}+=2; } } foreach my $partid (@partid) { my $display_part=&get_display_part($partid,$symb); - $result .= 'Part: '.$display_part. - ' (Weight = '.$weight{$partid}.')'; + $result .= ''. + &mt('Part: [_1] (Weight = [_2])',$display_part,$weight{$partid}). + ''; } $result .= &Apache::loncommon::end_data_table_header_row(). @@ -3433,7 +3434,8 @@ sub editgrades { if (!&canmodify($usec)) { my $numcols=scalar(@partid)*4+2; push(@noupdate, - $line."Not allowed to modify student"); + $line."". + &mt('Not allowed to modify student').""); next; } my %aggregate = (); @@ -3553,7 +3555,9 @@ sub editgrades { # my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3; my $numcols=scalar(@partid)*4+2; $result .= &Apache::loncommon::start_data_table_row('LC_empty_row'). - 'No Changes Occurred For the Students Below'. + ''. + &mt('No Changes Occurred For the Students Below'). + ''. &Apache::loncommon::end_data_table_row(); foreach my $line (@noupdate) { $result.= @@ -3564,9 +3568,11 @@ sub editgrades { } $result .= &Apache::loncommon::end_data_table(). &show_grading_menu_form($symb); - my $msg = '

Number of records updated = '.$rec_update. - ' for '.$count.' student'.($count <= 1 ? '' : 's').'.
'. - 'Total number of students = '.$env{'form.total'}.'

'; + my $msg = '

'. + &mt('Number of records updated = [_1] for [quant,_2,student].', + $rec_update,$count).'
'. + ''.&mt('Total number of students = [_1]',$env{'form.total'}). + '

'; return $title.$msg.$result; } @@ -5111,7 +5117,8 @@ sub username_to_idmap { sub scantron_fixup_scanline { my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_; - + + if ($field eq 'ID') { if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) { return ($line,1,'New value too large'); @@ -5142,28 +5149,54 @@ sub scantron_fixup_scanline { $$scantron_config{'CODElength'})=$args->{'CODE'}; } } elsif ($field eq 'answer') { + &scantron_get_maxbubble(); # Need the bubble counter info. my $length=$scantron_config->{'Qlength'}; my $off=$scantron_config->{'Qoff'}; my $on=$scantron_config->{'Qon'}; my $answer=${off}x$length; - if ($args->{'response'} eq 'none') { - &scan_data($scan_data, - "$whichline.no_bubble.".$args->{'question'},'1'); - } else { - if ($on eq 'letter') { - my @alphabet=('A'..'Z'); - $answer=$alphabet[$args->{'response'}]; - } elsif ($on eq 'number') { - $answer=$args->{'response'}+1; - if ($answer == 10) { $answer = '0'; } + 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 $final_answer; + if ($$scantron_config{'Qon'} eq 'letter' || + $$scantron_config{'Qon'} eq 'number') { + $bubbles_per_line = 10; + } + if (defined $args->{'response'}) { + + if ($args->{'response'} eq 'none') { + &scan_data($scan_data, + "$whichline.no_bubble.".$args->{'question'},'1'); } 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, - "$whichline.no_bubble.".$args->{'question'},undef,'1'); + # $where=$length*($args->{'question'}-1)+$scantron_config->{'Qstart'}; + #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; } @@ -6487,6 +6520,7 @@ 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); } @@ -6541,6 +6575,7 @@ sub scantron_bubble_selector { my $total_lines = $lines*2; my @alphabet=('A'..'Z'); + $r->print(""); for (my $l = 0; $l < $lines; $l++) { @@ -6574,9 +6609,10 @@ sub scantron_bubble_selector { # multiline questions (different values e.g..). for (my $i=0;$i<$max;$i++) { + my $value = "$l:$i"; # Relative bubble line #: Bubble in line. $r->print("\n". '"); + $quest.'" value="'.$value.'" />'.$alphabet[$i].""); } $r->print(''); @@ -6764,6 +6800,7 @@ 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); @@ -6771,6 +6808,7 @@ 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'}); @@ -7226,7 +7264,7 @@ sub show_grading_menu_form { ''."\n". ''."\n". ''."\n". - ''."\n". + ''."\n". ''."\n"; return $result; }
$quest