version 1.549, 2009/02/04 13:21:40
|
version 1.554, 2009/03/06 16:13:29
|
Line 274 sub reset_caches {
|
Line 274 sub reset_caches {
|
} |
} |
} |
} |
} |
} |
|
|
|
sub scantron_partids_tograde { |
|
my ($resource,$cid,$uname,$udom) = @_; |
|
my (%analysis,@parts); |
|
if (ref($resource)) { |
|
my $symb = $resource->symb(); |
|
my $analyze = &get_analyze($symb,$uname,$udom); |
|
if (ref($analyze) eq 'HASH') { |
|
%analysis = %{$analyze}; |
|
} |
|
if (ref($analysis{'parts'}) eq 'ARRAY') { |
|
foreach my $part (@{$analysis{'parts'}}) { |
|
my ($id,$respid) = split(/\./,$part); |
|
if (!&Apache::loncommon::check_if_partid_hidden($id,$symb,$udom,$uname)) { |
|
push(@parts,$part); |
|
} |
|
} |
|
} |
|
} |
|
return (\%analysis,\@parts); |
|
} |
|
|
} |
} |
|
|
#--- Clean response type for display |
#--- Clean response type for display |
Line 699 sub verifyreceipt {
|
Line 721 sub verifyreceipt {
|
|
|
my $title.= |
my $title.= |
'<h3><span class="LC_info">'. |
'<h3><span class="LC_info">'. |
&mt('Verifying Submission Receipt [_1]',$receipt). |
&mt('Verifying Receipt No. [_1]',$receipt). |
'</span></h3>'."\n". |
'</span></h3>'."\n". |
'<h4>'.&mt('<b>Resource: </b>[_1]',$env{'form.probTitle'}). |
'<h4>'.&mt('<b>Resource: </b>[_1]',$env{'form.probTitle'}). |
'</h4>'."\n"; |
'</h4>'."\n"; |
Line 3426 sub editgrades {
|
Line 3448 sub editgrades {
|
if ($part !~ m/^\Q$partid\E/) { next;} |
if ($part !~ m/^\Q$partid\E/) { next;} |
if ($type eq 'awarded' || $type eq 'solved') { next; } |
if ($type eq 'awarded' || $type eq 'solved') { next; } |
my $display=&Apache::lonnet::metadata($url,$stores.'.display'); |
my $display=&Apache::lonnet::metadata($url,$stores.'.display'); |
$display =~ s/\[Part: (\w)+\]//; |
$display =~ s/\[Part: \Q$part\E\]//; |
my $narrowtext = &mt('Tries'); |
my $narrowtext = &mt('Tries'); |
$display =~ s/Number of Attempts/$narrowtext/; |
$display =~ s/Number of Attempts/$narrowtext/; |
$header .= '<th align="center">'.&mt('Old').' '.$display.'</th>'. |
$header .= '<th align="center">'.&mt('Old').' '.$display.'</th>'. |
Line 4728 sub getSequenceDropDown {
|
Line 4750 sub getSequenceDropDown {
|
} |
} |
|
|
my %bubble_lines_per_response; # no. bubble lines for each response. |
my %bubble_lines_per_response; # no. bubble lines for each response. |
# index is "symb.part_id" |
# key is zero-based index - 0, 1, 2 ... |
|
|
my %first_bubble_line; # First bubble line no. for each bubble. |
my %first_bubble_line; # First bubble line no. for each bubble. |
|
|
Line 4769 sub restore_bubble_lines {
|
Line 4791 sub restore_bubble_lines {
|
$env{"form.scantron.responsetype.$line"}; |
$env{"form.scantron.responsetype.$line"}; |
$line++; |
$line++; |
} |
} |
|
|
} |
} |
|
|
# Given the parsed scanline, get the response for |
# Given the parsed scanline, get the response for |
Line 4778 sub restore_bubble_lines {
|
Line 4799 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-1} +1; |
my $bubble_line = $first_bubble_line{$response-1} +1; |
my $bubble_lines= $bubble_lines_per_response{$response-1}; |
my $bubble_lines= $bubble_lines_per_response{$response-1}; |
|
|
Line 5487 sub scantron_parse_scanline {
|
Line 5507 sub scantron_parse_scanline {
|
my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_; |
my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_; |
|
|
my %record; |
my %record; |
my $questions=substr($line,$$scantron_config{'Qstart'}-1); # Answers |
my $lastpos = $env{'form.scantron_maxbubble'}*$$scantron_config{'Qlength'}; |
|
my $questions=substr($line,$$scantron_config{'Qstart'}-1,$lastpos); # Answers |
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); # earlier stuff |
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); # earlier stuff |
if (!($$scantron_config{'CODElocation'} eq 0 || |
if (!($$scantron_config{'CODElocation'} eq 0 || |
$$scantron_config{'CODElocation'} eq 'none')) { |
$$scantron_config{'CODElocation'} eq 'none')) { |
Line 7242 sub scantron_get_maxbubble {
|
Line 7263 sub scantron_get_maxbubble {
|
%first_bubble_line = (); |
%first_bubble_line = (); |
%subdivided_bubble_lines = (); |
%subdivided_bubble_lines = (); |
%responsetype_per_response = (); |
%responsetype_per_response = (); |
|
|
my $response_number = 0; |
my $response_number = 0; |
my $bubble_line = 0; |
my $bubble_line = 0; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
Line 7301 sub scantron_get_maxbubble {
|
Line 7322 sub scantron_get_maxbubble {
|
} |
} |
} |
} |
} |
} |
&Apache::lonnet::delenv('scantron\.'); |
&Apache::lonnet::delenv('scantron.'); |
|
|
&save_bubble_lines(); |
&save_bubble_lines(); |
$env{'form.scantron_maxbubble'} = |
$env{'form.scantron_maxbubble'} = |
Line 7309 sub scantron_get_maxbubble {
|
Line 7330 sub scantron_get_maxbubble {
|
return $env{'form.scantron_maxbubble'}; |
return $env{'form.scantron_maxbubble'}; |
} |
} |
|
|
sub scantron_partids_tograde { |
|
my ($resource,$cid,$uname,$udom) = @_; |
|
my (%analysis,@parts); |
|
|
|
if (ref($resource)) { |
|
my $symb = $resource->symb(); |
|
my $result=&ssi_with_retries($resource->src(), $ssi_retries, |
|
('symb' => $symb, |
|
'grade_target' => 'analyze', |
|
'grade_courseid' => $cid, |
|
'grade_domain' => $udom, |
|
'grade_username' => $uname)); |
|
my (undef, $an) = split(/_HASH_REF__/,$result, 2); |
|
%analysis = &Apache::lonnet::str2hash($an); |
|
|
|
if (ref($analysis{'parts'}) eq 'ARRAY') { |
|
foreach my $part (@{$analysis{'parts'}}) { |
|
my ($id,$respid) = split(/\./,$part); |
|
if (!&Apache::loncommon::check_if_partid_hidden($id,$symb,$udom,$uname)) { |
|
push(@parts,$part); |
|
} |
|
} |
|
} |
|
} |
|
return (\%analysis,\@parts); |
|
} |
|
|
|
sub scantron_validate_missingbubbles { |
sub scantron_validate_missingbubbles { |
my ($r,$currentphase) = @_; |
my ($r,$currentphase) = @_; |
#get student info |
#get student info |
Line 7407 sub scantron_process_students {
|
Line 7401 sub scantron_process_students {
|
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $map=$navmap->getResourceByUrl($sequence); |
my $map=$navmap->getResourceByUrl($sequence); |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
|
|
my ($uname,$udom,%partids_by_symb); |
|
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
|
my ($analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); |
|
$partids_by_symb{$ressymb} = $parts; |
|
} |
|
# $r->print("geto ".scalar(@resources)."<br />"); |
# $r->print("geto ".scalar(@resources)."<br />"); |
|
my ($uname,$udom); |
my $result= <<SCANTRONFORM; |
my $result= <<SCANTRONFORM; |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> |
<input type="hidden" name="command" value="scantron_configphase" /> |
<input type="hidden" name="command" value="scantron_configphase" /> |
Line 7439 SCANTRONFORM
|
Line 7426 SCANTRONFORM
|
my $started; |
my $started; |
|
|
&scantron_get_maxbubble(); # Need the bubble lines array to parse. |
&scantron_get_maxbubble(); # Need the bubble lines array to parse. |
|
|
|
|
# If an ssi failed in scantron_get_maxbubble, put an error message out to |
# If an ssi failed in scantron_get_maxbubble, put an error message out to |
# the user and return. |
# the user and return. |
Line 7480 SCANTRONFORM
|
Line 7466 SCANTRONFORM
|
} |
} |
($uname,$udom)=split(/:/,$uname); |
($uname,$udom)=split(/:/,$uname); |
|
|
|
my %partids_by_symb; |
|
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
|
my ($analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); $partids_by_symb{$ressymb} = $parts; |
|
} |
|
|
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonnet::appenv($scan_record); |
&Apache::lonnet::appenv($scan_record); |
|
|
Line 7496 SCANTRONFORM
|
Line 7489 SCANTRONFORM
|
} |
} |
|
|
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
@resources) eq 'ssi_error') { |
\@resources,\%partids_by_symb) eq 'ssi_error') { |
$ssi_error = 0; # So end of handler error message does not trigger. |
$ssi_error = 0; # So end of handler error message does not trigger. |
$r->print("</form>"); |
$r->print("</form>"); |
&ssi_print_error($r); |
&ssi_print_error($r); |
Line 7514 SCANTRONFORM
|
Line 7507 SCANTRONFORM
|
my $studentrecord = ''; |
my $studentrecord = ''; |
my $counter = -1; |
my $counter = -1; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
($counter,my $recording) = |
($counter,my $recording) = |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
$counter,$studentdata,\%partids_by_symb, |
$counter,$studentdata,$partids_by_symb{$ressymb}, |
\%scantron_config,\%lettdig,$numletts); |
\%scantron_config,\%lettdig,$numletts); |
$studentrecord .= $recording; |
$studentrecord .= $recording; |
} |
} |
if ($studentrecord ne $studentdata) { |
if ($studentrecord ne $studentdata) { |
|
&Apache::lonxml::clear_problem_counter(); |
|
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
|
\@resources,\%partids_by_symb) eq 'ssi_error') { |
|
$ssi_error = 0; # So end of handler error message does not trigger. |
|
$r->print("</form>"); |
|
&ssi_print_error($r); |
|
$r->print(&show_grading_menu_form($symb)); |
|
&Apache::lonnet::remove_lock($lock); |
|
delete($completedstudents{$uname}); |
|
return ''; |
|
} |
$counter = -1; |
$counter = -1; |
$studentrecord = ''; |
$studentrecord = ''; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
($counter,my $recording) = |
($counter,my $recording) = |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
$counter,$studentdata,\%partids_by_symb, |
$counter,$studentdata,$partids_by_symb{$ressymb}, |
\%scantron_config,\%lettdig,$numletts); |
\%scantron_config,\%lettdig,$numletts); |
$studentrecord .= $recording; |
$studentrecord .= $recording; |
} |
} |
Line 7563 SCANTRONFORM
|
Line 7569 SCANTRONFORM
|
if (&Apache::loncommon::connection_aborted($r)) { last; } |
if (&Apache::loncommon::connection_aborted($r)) { last; } |
} continue { |
} continue { |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonnet::delenv('scantron\.'); |
&Apache::lonnet::delenv('scantron.'); |
} |
} |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonnet::remove_lock($lock); |
&Apache::lonnet::remove_lock($lock); |
Line 7576 SCANTRONFORM
|
Line 7582 SCANTRONFORM
|
} |
} |
|
|
sub grade_student_bubbles { |
sub grade_student_bubbles { |
my ($r,$uname,$udom,$scan_record,$scancode,@resources) = @_; |
my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts) = @_; |
foreach my $resource (@resources) { |
if (ref($resources) eq 'ARRAY') { |
my %form = ('submitted' => 'scantron', |
my $count = 0; |
'grade_target' => 'grade', |
foreach my $resource (@{$resources}) { |
'grade_username'=> $uname, |
my $ressymb = $resource->symb(); |
'grade_domain' => $udom, |
my %form = ('submitted' => 'scantron', |
'grade_courseid'=> $env{'request.course.id'}, |
'grade_target' => 'grade', |
'grade_symb' => $resource->symb(), |
'grade_username' => $uname, |
'CODE' => $scancode); |
'grade_domain' => $udom, |
my $result=&ssi_with_retries($resource->src(),$ssi_retries,%form); |
'grade_courseid' => $env{'request.course.id'}, |
return 'ssi_error' if ($ssi_error); |
'grade_symb' => $ressymb, |
last if (&Apache::loncommon::connection_aborted($r)); |
'CODE' => $scancode |
|
); |
|
if (ref($parts) eq 'HASH') { |
|
if (ref($parts->{$ressymb}) eq 'ARRAY') { |
|
foreach my $part (@{$parts->{$ressymb}}) { |
|
$form{'scantron_questnum_start.'.$part} = |
|
1+$env{'form.scantron.first_bubble_line.'.$count}; |
|
$count++; |
|
} |
|
} |
|
} |
|
my $result=&ssi_with_retries($resource->src(),$ssi_retries,%form); |
|
return 'ssi_error' if ($ssi_error); |
|
last if (&Apache::loncommon::connection_aborted($r)); |
|
} |
} |
} |
return; |
return; |
} |
} |
Line 7760 sub checkscantron_results {
|
Line 7780 sub checkscantron_results {
|
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $map=$navmap->getResourceByUrl($sequence); |
my $map=$navmap->getResourceByUrl($sequence); |
my @resources=$navmap->retrieveResources($map,undef,1,0); |
my @resources=$navmap->retrieveResources($map,undef,1,0); |
my ($uname,$udom,%partids_by_symb); |
my ($uname,$udom); |
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
|
my ($analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); |
|
$partids_by_symb{$ressymb} = $parts; |
|
} |
|
my (%scandata,%lastname,%bylast); |
my (%scandata,%lastname,%bylast); |
$r->print(' |
$r->print(' |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="checkscantron">'."\n"); |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="checkscantron">'."\n"); |
Line 7821 sub checkscantron_results {
|
Line 7835 sub checkscantron_results {
|
($username,$domain)=split(/:/,$uname); |
($username,$domain)=split(/:/,$uname); |
my $counter = -1; |
my $counter = -1; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
|
my ($analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'},$username,$domain); |
($counter,my $recording) = |
($counter,my $recording) = |
&verify_scantron_grading($resource,$domain,$username,$cid,$counter, |
&verify_scantron_grading($resource,$domain,$username,$cid,$counter, |
$scandata{$pid},\%partids_by_symb, |
$scandata{$pid},$parts, |
\%scantron_config,\%lettdig,$numletts); |
\%scantron_config,\%lettdig,$numletts); |
$record{$pid} .= $recording; |
$record{$pid} .= $recording; |
} |
} |
Line 7888 sub checkscantron_results {
|
Line 7905 sub checkscantron_results {
|
} |
} |
|
|
sub verify_scantron_grading { |
sub verify_scantron_grading { |
my ($resource,$domain,$username,$cid,$counter,$scandata,$partids_by_symb, |
my ($resource,$domain,$username,$cid,$counter,$scandata,$partids, |
$scantron_config,$lettdig,$numletts) = @_; |
$scantron_config,$lettdig,$numletts) = @_; |
my ($record,%expected,%startpos); |
my ($record,%expected,%startpos); |
return ($counter,$record) if (!ref($resource)); |
return ($counter,$record) if (!ref($resource)); |
return ($counter,$record) if (!$resource->is_problem()); |
return ($counter,$record) if (!$resource->is_problem()); |
my $symb = $resource->symb(); |
my $symb = $resource->symb(); |
return ($counter,$record) if (ref($partids_by_symb) ne 'HASH'); |
return ($counter,$record) if (ref($partids) ne 'ARRAY'); |
return ($counter,$record) if (ref($partids_by_symb->{$symb}) ne 'ARRAY'); |
foreach my $part_id (@{$partids}) { |
foreach my $part_id (@{$partids_by_symb->{$symb}}) { |
|
$counter ++; |
$counter ++; |
$expected{$part_id} = 0; |
$expected{$part_id} = 0; |
if ($env{"form.scantron.sub_bubblelines.$counter"}) { |
if ($env{"form.scantron.sub_bubblelines.$counter"}) { |
Line 7989 sub verify_scantron_grading {
|
Line 8005 sub verify_scantron_grading {
|
} |
} |
} |
} |
} |
} |
foreach my $part_id (@{$partids_by_symb->{$symb}}) { |
foreach my $part_id (@{$partids}) { |
if ($recorded{$part_id} eq '') { |
if ($recorded{$part_id} eq '') { |
for (my $i=0; $i<$expected{$part_id}; $i++) { |
for (my $i=0; $i<$expected{$part_id}; $i++) { |
for (my $j=0; $j<$scantron_config->{'Qlength'}; $j++) { |
for (my $j=0; $j<$scantron_config->{'Qlength'}; $j++) { |