--- loncom/homework/grades.pm 2007/11/08 20:47:56 1.487 +++ loncom/homework/grades.pm 2007/12/15 21:54:35 1.500 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.487 2007/11/08 20:47:56 albertel Exp $ +# $Id: grades.pm,v 1.500 2007/12/15 21:54:35 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,88 +48,6 @@ use POSIX qw(floor); my %perm=(); -my %bubble_lines_per_response = (); # no. bubble lines for each response. - # index is "symb.part_id" - -my %first_bubble_line = (); # First bubble line no. for each bubble. - -# Save and restore the bubble lines array to the form env. - - -sub save_bubble_lines { - foreach my $line (keys(%bubble_lines_per_response)) { - $env{"form.scantron.bubblelines.$line"} = $bubble_lines_per_response{$line}; - $env{"form.scantron.first_bubble_line.$line"} = - $first_bubble_line{$line}; - } -} - - -sub restore_bubble_lines { - my $line = 0; - %bubble_lines_per_response = (); - while ($env{"form.scantron.bubblelines.$line"}) { - my $value = $env{"form.scantron.bubblelines.$line"}; - $bubble_lines_per_response{$line} = $value; - $first_bubble_line{$line} = - $env{"form.scantron.first_bubble_line.$line"}; - $line++; - } - -} - -# Given the parsed scanline, get the response for -# 'answer' number n: - -sub get_response_bubbles { - my ($parsed_line, $response) = @_; - - - my $bubble_line = $first_bubble_line{$response-1} +1; - my $bubble_lines= $bubble_lines_per_response{$response-1}; - - my $selected = ""; - - for (my $bline = 0; $bline < $bubble_lines; $bline++) { - $selected .= $$parsed_line{"scantron.$bubble_line.answer"}.":"; - $bubble_line++; - } - return $selected; -} - - -# ----- These first few routines are general use routines.---- - -# Return the number of occurences of a pattern in a string. - -sub occurence_count { - my ($string, $pattern) = @_; - - my @matches = ($string =~ /$pattern/g); - - return scalar(@matches); -} - - -# Take a string known to have digits and convert all the -# digits into letters in the range J,A..I. - -sub digits_to_letters { - my ($input) = @_; - - my @alphabet = ('J', 'A'..'I'); - - my @input = split(//, $input); - my $output =''; - for (my $i = 0; $i < scalar(@input); $i++) { - if ($input[$i] =~ /\d/) { - $output .= $alphabet[$input[$i]]; - } else { - $output .= $input[$i]; - } - } - return $output; -} # # --- Retrieve the parts from the metadata file.--- @@ -4256,7 +4174,8 @@ sub displayPage { my $result='
- Specify a Scantron data file to upload. - | -|
+ '.&mt('Specify a Scantron data file to upload.').' + | + '.&Apache::loncommon::end_data_table_header_row().' + '.&Apache::loncommon::start_data_table_row().'
-SCANTRONFORM
+');
my $default_form_data=&defaultFormData(&get_symb($r,1));
my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'};
- $r->print(< - + |
-
---|
- Download a scoring office file - | -|
Filename of scoring office file: | $file_selector | -
- - | -
Sequence to be Graded: | $title |
Data File that will be used: | $env{'form.scantron_selectfile'} |
'.&mt('Sequence to be Graded:').' | '.$title.' |
'.&mt('Data File that will be used:').' | '.$env{'form.scantron_selectfile'}.' |
If this information is correct, please click on '$button_text'.
-If something is incorrect, please click the 'Grading Menu' button to start over.
+'.&mt('If this information is correct, please click on \'[_1]\'.',&mt($button_text)).'
+'.&mt('If something is incorrect, please click the \'Grading Menu\' button to start over.').'
You have forgetten to specify some information. Please go Back and try again.
"); + $r->print("".&mt('You have forgetten to specify some information. Please go Back and try again.')."
"); if ( $env{'form.selectpage'} eq '') { - $r->print('You have not selected a Sequence to grade
'); + $r->print(''.&mt('You have not selected a Sequence to grade').'
'); } if ( $env{'form.scantron_selectfile'} eq '') { - $r->print('You have not selected a file that contains the student\'s response data.
'); + $r->print(''.&mt('You have not selected a file that contains the student\'s response data.').'
'); } if ( $env{'form.scantron_format'} eq '') { - $r->print('You have not selected a the format of the student\'s response data.
'); + $r->print(''.&mt('You have not selected a the format of the student\'s response data.').'
'); } } else { my $warning=&scantron_warning_screen('Grading: Validate Records'); - $r->print(<Gathering necessary info.
");$r->rflush(); + $r->print(''.&mt('Gathering necessary info.').'
');$r->rflush(); #get the student pick code ready $r->print(&Apache::loncommon::studentbrowser_javascript()); my $max_bubble=&scantron_get_maxbubble(); @@ -6001,7 +5953,7 @@ sub scantron_validate_file { my $stop=0; while (!$stop && $currentphase < scalar(@validate_phases)) { - $r->print("Validating ".$validate_phases[$currentphase]."
"); + $r->print(''.&mt('Validating '.$validate_phases[$currentphase]).'
'); $r->rflush(); my $which="scantron_validate_".$validate_phases[$currentphase]; { @@ -6011,12 +5963,12 @@ sub scantron_validate_file { } if (!$stop) { my $warning=&scantron_warning_screen('Start Grading'); - $r->print(<Or click the 'Grading Menu' button to start over.
"); + $r->print("".&mt("Or click the 'Grading Menu' button to start over.")."
"); } else { - $r->print(''); - $r->print(' using corrected infoAn error was detected ($error)"); if ( $$scan_record{'scantron.PaperID'} =~ /\S/) { - $r->print(" for PaperID ". - $$scan_record{'scantron.PaperID'}." \n"); + $r->print("
".&mt("An error was detected ($error)". + " for PaperID [_1]", + $$scan_record{'scantron.PaperID'})."
\n"); } else { - $r->print(" in scanline $i". - $line."\n"); - } - my $message="
The ID on the form is ".
- $$scan_record{'scantron.ID'}."
\n".
- "The name on the paper is ".
- $$scan_record{'scantron.LastName'}.",".
- $$scan_record{'scantron.FirstName'}."
".&mt("An error was detected ($error)". + " in scanline [_1]
[_2]", + $i,$line)." \n"); + } + my $message="
".&mt("The ID on the form is [_1]
".
+ "The name on the paper is [_2],[_3]",
+ $$scan_record{'scantron.ID'},
+ $$scan_record{'scantron.LastName'},
+ $$scan_record{'scantron.FirstName'})."
".&mt("The encoded ID is not in the classlist"). + "
\n"); } elsif ($error eq 'duplicateID') { - $r->print("The encoded ID has also been used by a previous paper $arg\n"); + $r->print("".&mt("The encoded ID has also been used by a previous paper [_1]",$arg)."
\n"); } $r->print($message); - $r->print("How should I handle this?
\n");
+ $r->print("
".&mt("How should I handle this?")."
\n");
$r->print("\n
The encoded CODE is not in the list of possible CODEs
\n"); + $r->print("".&mt("The encoded CODE is not in the list of possible CODEs.")."
\n"); } elsif ($error eq 'duplicateCODE') { - $r->print("The encoded CODE has also been used by a previous paper ".join(', ',@{$arg}).", and CODEs are supposed to be unique
\n"); + $r->print("".&mt("The encoded CODE has also been used by a previous paper [_1], and CODEs are supposed to be unique.",join(', ',@{$arg}))."
\n"); } - $r->print("The CODE on the form is '".
- $$scan_record{'scantron.CODE'}."'
\n");
+ $r->print("
".&mt("The CODE on the form is '[_1]'",
+ $$scan_record{'scantron.CODE'})."
\n");
$r->print($message);
- $r->print("
How should I handle this?
\n");
+ $r->print("
".&mt("How should I handle this?")."
\n");
$r->print("\n
");
my $i=0;
if ($error eq 'incorrectCODE'
@@ -6566,7 +6523,13 @@ sub scantron_get_correction {
foreach my $testcode (@{$closest}) {
my $checked='';
if (!$i) { $checked=' checked="checked" '; }
- $r->print("");
+ $r->print("
+
+ ");
$r->print("\n
");
$i++;
}
@@ -6574,7 +6537,12 @@ sub scantron_get_correction {
}
if ($$scan_record{'scantron.CODE'}=~/\S/ ) {
my $checked; if (!$i) { $checked=' checked="checked" '; }
- $r->print("");
+ $r->print("
+ ");
$r->print("\n
");
}
@@ -6596,118 +6564,167 @@ ENDSCRIPT
"&curCODE=".&escape($$scan_record{'scantron.CODE'}).
"&scantron_selectfile=".&escape($env{'form.scantron_selectfile'});
if ($env{'form.scantron_CODElist'} =~ /\S/) {
- $r->print(" Selected CODE is ");
+ $r->print("
+
+ ".&mt("Selected CODE is [_1]",""));
$r->print("\n
");
}
- $r->print(" as the CODE.");
+ $r->print("
+ "));
$r->print("\n
");
} elsif ($error eq 'doublebubble') {
- $r->print("
There have been multiple bubbles scanned for a some question(s)
\n"); + $r->print("".&mt("There have been multiple bubbles scanned for a some question(s)")."
\n"); + + # The form field scantron_questions is acutally a list of line numbers. + # represented by this form so: + + my $line_list = &questions_to_line_list($arg); + $r->print(''); + $line_list.'" />'); $r->print($message); - $r->print("Please indicate which bubble should be used for grading
"); + $r->print("".&mt("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); - &scantron_bubble_selector($r,$scan_config,$question, - @select_array); + &prompt_for_corrections($r, $question, $scan_config, $scan_record); } } elsif ($error eq 'missingbubble') { - $r->print("There have been no bubbles scanned for some question(s)
\n"); + $r->print("".&mt("There have been no bubbles scanned for some question(s)")."
\n"); $r->print($message); - $r->print("Please indicate which bubble should be used for grading
"); - $r->print("Some questions have no scanned bubbles\n"); + $r->print("".&mt("Please indicate which bubble should be used for grading.")."
"); + $r->print(&mt("Some questions have no scanned bubbles")."\n"); + + # The form field scantron_questinos is actually a list of line numbers not + # a list of question numbers. Therefore: + # + + my $line_list = &questions_to_line_list($arg); + $r->print(''); + $line_list.'" />'); foreach my $question (@{$arg}) { - my $selected = &get_response_bubbles($scan_record, $question); - my @select_array = split(/:/,$selected); # ought to be an array of empties. - &scantron_bubble_selector($r,$scan_config,$question, @select_array); + &prompt_for_corrections($r, $question, $scan_config, $scan_record); } } else { $r->print("\n$quest | "); +=cut - for (my $l = 0; $l < $lines; $l++) { - if ($l != 0) { - $r->print('|
'); - if ($selected[0] eq $alphabet[$i]) { - $r->print('X'); - shift(@selected) ; - } else { - $r->print(' '); - } - $r->print(' | '); - - } +sub prompt_for_corrections { + my ($r, $question, $scan_config, $scan_record) = @_; - if ($l == 0) { - my $lspan = $total_lines * 2; # 2 table rows per bubble line. + my $lines = $bubble_lines_per_response{$question-1}; + my $current_line = $first_bubble_line{$question-1} + 1 ; - $r->print(''); - - } + if ($lines > 1) { + $r->print(&mt("The group of bubble lines below responds to a single question. Select at most one bubble in a single line and select 'No Bubble' in all the other lines. ")." |
"); - } - $r->print(' |
$line | "); + for (my $i=0;$i<$max+1;$i++) { + $r->print("\n".''); + if ($selected[0] eq $alphabet[$i]) { $r->print('X'); shift(@selected) } + else { $r->print(' '); } + $r->print(' | '); + } + $r->print('
"); + } + $r->print(' | '); + $r->print(' |
$select_link | |
Course ID: | |
Course Name: | |
Domain: | $domsel |
File to upload: | |
'.$select_link.' | |
'.&mt('Course ID:').' | +|
'.&mt('Course Name:').' | +|
'.&mt('Domain:').' | +'.$domsel.' |
'.&mt('File to upload:').' | +
- The requested file name was invalid. + '.&mt('The requested file name was invalid.').'
-ERROR +'); $r->print(&show_grading_menu_form(&get_symb($r,1))); return; } @@ -7317,17 +7343,20 @@ ERROR &Apache::lonnet::allowuploaded('/adm/grades',$orig); &Apache::lonnet::allowuploaded('/adm/grades',$corrected); &Apache::lonnet::allowuploaded('/adm/grades',$skipped); - $r->print(<- Original file as uploaded by the scantron office. + '.&mt('[_1]Original[_2] file as uploaded by the scantron office.', + '','').'
- Corrections, a file of corrected records that were used in grading. + '.&mt('[_1]Corrections[_2], a file of corrected records that were used in grading.', + '','').'
- Skipped, a file of records that were skipped. + '.&mt('[_1]Skipped[_2], a file of records that were skipped.', + '','').'
-DOWNLOAD +'); $r->print(&show_grading_menu_form(&get_symb($r,1))); return ''; } @@ -7648,6 +7677,7 @@ GRADINGMENUJS '; + $result .= &show_grading_menu_form($symb); return $result; }