".&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("
".&mt("Please indicate which bubble should be used for grading")."
".&mt("There have been no bubbles scanned for some question(s)")."
\n");
$r->print($message);
$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
");
}
$r->print("\n
");
-
}
=pod
-=item scantron_bubble_selector
-
- Generates the html radiobuttons to correct a single bubble line
- possibly showing the existing the selected bubbles if known
+=item questions_to_line_list
- Arguments:
- $r - Apache request object
- $scan_config - hash from &get_scantron_config()
- $quest - number of the bubble line to make a corrector for
- @lines - array of answer lines.
+Converts a list of questions into a string of comma separated
+line numbers in the answer sheet used by the questions. This is
+used to fill in the scantron_questions form field.
+
+ Arguments:
+ questions - Reference to an array of questions.
=cut
-sub scantron_bubble_selector {
- my ($r,$scan_config,$quest,@lines)=@_;
- my $max=$$scan_config{'Qlength'};
+sub questions_to_line_list {
+ my ($questions) = @_;
+ my @lines;
- my $scmode=$$scan_config{'Qon'};
+ foreach my $question (@{$questions}) {
+ my $first = $first_bubble_line{$question-1} + 1;
+ my $count = $bubble_lines_per_response{$question-1};
+ my $last = $first+$count-1;
+ push(@lines, ($first..$last));
+ }
+ return join(',', @lines);
+}
- my $bubble_length = scalar(@lines);
+=pod
+=item prompt_for_corrections
- if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; }
+Prompts for a potentially multiline correction to the
+user's bubbling (factors out common code from scantron_get_correction
+for multi and missing bubble cases).
- my $response = $quest-1;
- my $lines = $bubble_lines_per_response{$response};
+ Arguments:
+ $r - Apache request object.
+ $question - The question number to prompt for.
+ $scan_config - The scantron file configuration hash.
+ $scan_record - Reference to the hash that has the the parsed scanlines.
- my $total_lines = $lines*2;
- my @alphabet=('A'..'Z');
+ Implicit inputs:
+ %bubble_lines_per_response - Starting line numbers for each question.
+ Numbered from 0 (but question numbers are from
+ 1.
+ %first_bubble_line - Starting bubble line for each question.
- $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. ")." ");
+ }
+ for (my $i =0; $i < $lines; $i++) {
+ my $selected = $$scan_record{"scantron.$current_line.answer"};
+ &scantron_bubble_selector($r, $scan_config, $current_line,
+ split('', $selected));
+ $current_line++;
+ }
+ if ($lines > 1) {
+ $r->print(" ");
+ }
+}
- $r->print('
');
+=pod
- # FIXME: This may have to be a bit more clever for
- # multiline questions (different values e.g..).
+=item scantron_bubble_selector
+
+ Generates the html radiobuttons to correct a single bubble line
+ possibly showing the existing the selected bubbles if known
- for (my $i=0;$i<$max;$i++) {
- my $value = "$l:$i"; # Relative bubble line #: Bubble in line.
- $r->print("\n".
- '
");
- }
- $r->print('
');
+ Arguments:
+ $r - Apache request object
+ $scan_config - hash from &get_scantron_config()
+ $line - Number of the line being displayed.
+ @selected - Array of bubbles picked on this line.
-
- }
- $r->print('
');
+=cut
+
+sub scantron_bubble_selector {
+ my ($r,$scan_config,$line,@selected)=@_;
+ my $max=$$scan_config{'Qlength'};
+
+ my $scmode=$$scan_config{'Qon'};
+ if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; }
+
+ my @alphabet=('A'..'Z');
+ $r->print("
$line
");
+ for (my $i=0;$i<$max+1;$i++) {
+ $r->print("\n".'