version 1.459, 2007/10/15 09:47:47
|
version 1.461, 2007/10/17 10:48:20
|
Line 57 my %first_bubble_line = (); # First bubb
|
Line 57 my %first_bubble_line = (); # First bubb
|
|
|
|
|
sub save_bubble_lines { |
sub save_bubble_lines { |
&Apache::lonnet::logthis("Saving bubble_lines..."); |
|
foreach my $line (keys(%bubble_lines_per_response)) { |
foreach my $line (keys(%bubble_lines_per_response)) { |
&Apache::lonnet::logthis("Saving form.scantron.bubblelines.$line value: $bubble_lines_per_response{$line}"); |
|
$env{"form.scantron.bubblelines.$line"} = $bubble_lines_per_response{$line}; |
$env{"form.scantron.bubblelines.$line"} = $bubble_lines_per_response{$line}; |
$env{"form.scantron.first_bubble_line.$line"} = |
$env{"form.scantron.first_bubble_line.$line"} = |
$first_bubble_line{$line}; |
$first_bubble_line{$line}; |
Line 72 sub restore_bubble_lines {
|
Line 70 sub restore_bubble_lines {
|
%bubble_lines_per_response = (); |
%bubble_lines_per_response = (); |
while ($env{"form.scantron.bubblelines.$line"}) { |
while ($env{"form.scantron.bubblelines.$line"}) { |
my $value = $env{"form.scantron.bubblelines.$line"}; |
my $value = $env{"form.scantron.bubblelines.$line"}; |
&Apache::lonnet::logthis("Restoring form.scantron.bubblelines.$line value: $value"); |
|
$bubble_lines_per_response{$line} = $value; |
$bubble_lines_per_response{$line} = $value; |
$first_bubble_line{$line} = |
$first_bubble_line{$line} = |
$env{"form.scantron.first_bubble_line.$line"}; |
$env{"form.scantron.first_bubble_line.$line"}; |
Line 87 sub restore_bubble_lines {
|
Line 84 sub restore_bubble_lines {
|
sub get_response_bubbles { |
sub get_response_bubbles { |
my ($parsed_line, $response) = @_; |
my ($parsed_line, $response) = @_; |
|
|
my $bubble_line = $first_bubble_line{$response}; |
|
my $bubble_lines= $bubble_lines_per_response{$response}; |
my $bubble_line = $first_bubble_line{$response-1} +1; |
|
my $bubble_lines= $bubble_lines_per_response{$response-1}; |
|
|
my $selected = ""; |
my $selected = ""; |
|
|
for (my $bline = 0; $bline < $bubble_lines; $bline++) { |
for (my $bline = 0; $bline < $bubble_lines; $bline++) { |
$selected .= $$parsed_line{"scantron.$bubble_line.answer"}; |
$selected .= $$parsed_line{"scantron.$bubble_line.answer"}.":"; |
$bubble_line++; |
$bubble_line++; |
} |
} |
return $selected; |
return $selected; |
Line 5269 sub scantron_parse_scanline {
|
Line 5268 sub scantron_parse_scanline {
|
|| (&occurence_count($currentquest, "[A-Z]") > 1)) { |
|| (&occurence_count($currentquest, "[A-Z]") > 1)) { |
push(@{$record{'scantron.doubleerror'}},$questnum); |
push(@{$record{'scantron.doubleerror'}},$questnum); |
for (my $ans = 0; $ans < $answers_needed; $ans++) { |
for (my $ans = 0; $ans < $answers_needed; $ans++) { |
$record{"scantron.$ansnum.answer"}=''; |
my $bubble = substr($currentquest, $ans, 1); |
|
if ($bubble =~ /[A-Z]/ ) { |
|
$record{"scantron.$ansnum.answer"} = $bubble; |
|
} else { |
|
$record{"scantron.$ansnum.answer"}=''; |
|
} |
$ansnum++; |
$ansnum++; |
} |
} |
|
|
Line 5304 sub scantron_parse_scanline {
|
Line 5308 sub scantron_parse_scanline {
|
|| (&occurence_count($currentquest, '\d') > 1)) { |
|| (&occurence_count($currentquest, '\d') > 1)) { |
push(@{$record{'scantron.doubleerror'}},$questnum); |
push(@{$record{'scantron.doubleerror'}},$questnum); |
for (my $ans = 0; $ans < $answers_needed; $ans++) { |
for (my $ans = 0; $ans < $answers_needed; $ans++) { |
$record{"scantron.$ansnum.answer"}=''; |
my $bubble = substr($currentquest, $ans, 1); |
|
if ($bubble =~ /\d/) { |
|
$record{"scantron.$ansnum.answer"} = $alphabet[$bubble]; |
|
} else { |
|
$record{"scantron.$ansnum.answer"}=' '; |
|
} |
$ansnum++; |
$ansnum++; |
} |
} |
|
|
Line 5747 SCANTRONFORM
|
Line 5756 SCANTRONFORM
|
|
|
my $line = 0; |
my $line = 0; |
while (defined($env{"form.scantron.bubblelines.$line"})) { |
while (defined($env{"form.scantron.bubblelines.$line"})) { |
&Apache::lonnet::logthis("Saving chunk for $line"); |
|
my $chunk = |
my $chunk = |
'<input type="hidden" name="scantron.bubblelines.'.$line.'" value="'.$env{"form.scantron.bubblelines.$line"}.'" />'."\n"; |
'<input type="hidden" name="scantron.bubblelines.'.$line.'" value="'.$env{"form.scantron.bubblelines.$line"}.'" />'."\n"; |
$chunk .= |
$chunk .= |
Line 5813 sub scantron_validate_file {
|
Line 5821 sub scantron_validate_file {
|
} |
} |
my $currentphase=$env{'form.validatepass'}; |
my $currentphase=$env{'form.validatepass'}; |
|
|
&Apache::lonnet::logthis("Phase: $currentphase"); |
|
|
|
my $stop=0; |
my $stop=0; |
while (!$stop && $currentphase < scalar(@validate_phases)) { |
while (!$stop && $currentphase < scalar(@validate_phases)) { |
Line 6424 ENDSCRIPT
|
Line 6431 ENDSCRIPT
|
$r->print($message); |
$r->print($message); |
$r->print("<p>Please indicate which bubble should be used for grading</p>"); |
$r->print("<p>Please indicate which bubble should be used for grading</p>"); |
foreach my $question (@{$arg}) { |
foreach my $question (@{$arg}) { |
|
|
my $selected = &get_response_bubbles($scan_record, $question); |
my $selected = &get_response_bubbles($scan_record, $question); |
|
my @select_array = split(/:/,$selected); |
&scantron_bubble_selector($r,$scan_config,$question, |
&scantron_bubble_selector($r,$scan_config,$question, |
split('',$selected)); |
@select_array); |
} |
} |
} elsif ($error eq 'missingbubble') { |
} elsif ($error eq 'missingbubble') { |
$r->print("<p>There have been <b>no</b> bubbles scanned for some question(s)</p>\n"); |
$r->print("<p>There have been <b>no</b> bubbles scanned for some question(s)</p>\n"); |
Line 6458 ENDSCRIPT
|
Line 6465 ENDSCRIPT
|
$r - Apache request object |
$r - Apache request object |
$scan_config - hash from &get_scantron_config() |
$scan_config - hash from &get_scantron_config() |
$quest - number of the bubble line to make a corrector for |
$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 |
=cut |
|
|
sub scantron_bubble_selector { |
sub scantron_bubble_selector { |
my ($r,$scan_config,$quest,@selected)=@_; |
my ($r,$scan_config,$quest,@lines)=@_; |
my $max=$$scan_config{'Qlength'}; |
my $max=$$scan_config{'Qlength'}; |
|
|
|
|
my $scmode=$$scan_config{'Qon'}; |
my $scmode=$$scan_config{'Qon'}; |
|
|
|
my $bubble_length = scalar(@lines); |
|
|
|
|
if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; } |
if ($scmode eq 'number' || $scmode eq 'letter') { $max=10; } |
|
|
my $response = $quest-1; |
my $response = $quest-1; |
my $lines = $bubble_lines_per_response{$response}; |
my $lines = $bubble_lines_per_response{$response}; |
&Apache::lonnet::logthis("Question $quest, lines: $lines"); |
|
|
|
my $total_lines = $lines*2; |
my $total_lines = $lines*2; |
my @alphabet=('A'..'Z'); |
my @alphabet=('A'..'Z'); |
Line 6483 sub scantron_bubble_selector {
|
Line 6492 sub scantron_bubble_selector {
|
if ($l != 0) { |
if ($l != 0) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
} |
} |
|
|
# FIXME: This loop probably has to be considerably more clever for |
|
# multiline bubbles: User can multibubble by having bubbles in |
|
# several lines. User can skip lines legitimately etc. etc. |
|
|
|
for (my $i=0;$i<$max;$i++) { |
for (my $i=0;$i<$max;$i++) { |
|
my @selected = split(//,$lines[$l]); |
$r->print("\n".'<td align="center">'); |
$r->print("\n".'<td align="center">'); |
if ($selected[0] eq $alphabet[$i]) { |
if ($selected[0] eq $alphabet[$i]) { |
$r->print('X'); |
$r->print('X'); |
Line 6737 sub scantron_validate_doublebubble {
|
Line 6742 sub scantron_validate_doublebubble {
|
=cut |
=cut |
|
|
sub scantron_get_maxbubble { |
sub scantron_get_maxbubble { |
&Apache::lonnet::logthis("get_max_bubble"); |
|
if (defined($env{'form.scantron_maxbubble'}) && |
if (defined($env{'form.scantron_maxbubble'}) && |
$env{'form.scantron_maxbubble'}) { |
$env{'form.scantron_maxbubble'}) { |
&Apache::lonnet::logthis("cached"); |
|
&restore_bubble_lines(); |
&restore_bubble_lines(); |
return $env{'form.scantron_maxbubble'}; |
return $env{'form.scantron_maxbubble'}; |
} |
} |
&Apache::lonnet::logthis("computing"); |
|
|
|
my (undef, undef, $sequence) = |
my (undef, undef, $sequence) = |
&Apache::lonnet::decode_symb($env{'form.selectpage'}); |
&Apache::lonnet::decode_symb($env{'form.selectpage'}); |
Line 6782 sub scantron_get_maxbubble {
|
Line 6784 sub scantron_get_maxbubble {
|
|
|
|
|
foreach my $part_id (@{$analysis{'parts'}}) { |
foreach my $part_id (@{$analysis{'parts'}}) { |
my ($trash, $part) = split(/\./, $part_id); |
|
|
|
my $lines = $analysis{"$part_id.bubble_lines"}[0]; |
|
|
my $lines = $analysis{"$part_id.bubble_lines"};; |
|
|
# TODO - make this a persistent hash not an array. |
# TODO - make this a persistent hash not an array. |
|
|
Line 8071 sub handler {
|
Line 8073 sub handler {
|
} elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) { |
} elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) { |
$request->print(&csvuploadassign($request)); |
$request->print(&csvuploadassign($request)); |
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { |
&Apache::lonnet::logthis("Selecting pyhase"); |
|
$request->print(&scantron_selectphase($request)); |
$request->print(&scantron_selectphase($request)); |
} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) { |
$request->print(&scantron_do_warning($request)); |
$request->print(&scantron_do_warning($request)); |