version 1.184, 2004/03/30 20:46:24
|
version 1.192, 2004/04/29 07:21:16
|
Line 3422 sub scantron_uploads {
|
Line 3422 sub scantron_uploads {
|
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
&Apache::loncommon::propath($cdom,$cname)); |
&Apache::loncommon::propath($cdom,$cname)); |
|
$result.="<option></option>"; |
foreach my $filename (@files) { |
foreach my $filename (@files) { |
($filename)=split(/&/,$filename); |
($filename)=split(/&/,$filename); |
if ($filename!~/^scantron_orig_/) { next ; } |
if ($filename!~/^scantron_orig_/) { next ; } |
Line 3435 sub scantron_uploads {
|
Line 3436 sub scantron_uploads {
|
sub scantron_scantab { |
sub scantron_scantab { |
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
my $result='<select name="scantron_format">'."\n"; |
my $result='<select name="scantron_format">'."\n"; |
|
$result.='<option></option>'."\n"; |
foreach my $line (<$fh>) { |
foreach my $line (<$fh>) { |
my ($name,$descrip)=split(/:/,$line); |
my ($name,$descrip)=split(/:/,$line); |
if ($name =~ /^\#/) { next; } |
if ($name =~ /^\#/) { next; } |
Line 3445 sub scantron_scantab {
|
Line 3447 sub scantron_scantab {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub scantron_CODElist { |
|
my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
|
my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum); |
|
my $namechoice='<option></option>'; |
|
foreach my $name (@names) { |
|
if ($name =~ /^error: 2 /) { next; } |
|
$namechoice.='<option value="'.$name.'">'.$name.'</option>'; |
|
} |
|
$namechoice='<select name="scantron_CODElist">'.$namechoice.'</select>'; |
|
return $namechoice; |
|
} |
|
|
|
sub scantron_CODEunique { |
|
my $result='<nobr> |
|
<input type="radio" name="scantron_CODEunique" |
|
value="Yes" checked="on" /> Yes |
|
</nobr> |
|
<nobr> |
|
<input type="radio" name="scantron_CODEunique" |
|
value="No" /> No |
|
</nobr>'; |
|
return $result; |
|
} |
|
|
sub scantron_selectphase { |
sub scantron_selectphase { |
my ($r) = @_; |
my ($r) = @_; |
my ($symb,$url)=&get_symb_and_url($r); |
my ($symb,$url)=&get_symb_and_url($r); |
Line 3454 sub scantron_selectphase {
|
Line 3481 sub scantron_selectphase {
|
my $grading_menu_button=&show_grading_menu_form($symb,$url); |
my $grading_menu_button=&show_grading_menu_form($symb,$url); |
my $file_selector=&scantron_uploads(); |
my $file_selector=&scantron_uploads(); |
my $format_selector=&scantron_scantab(); |
my $format_selector=&scantron_scantab(); |
|
my $CODE_selector=&scantron_CODElist(); |
|
my $CODE_unique=&scantron_CODEunique(); |
my $result; |
my $result; |
#FIXME allow instructor to be able to download the scantron file |
#FIXME allow instructor to be able to download the scantron file |
# and to upload it, |
# and to upload it, |
Line 3461 sub scantron_selectphase {
|
Line 3490 sub scantron_selectphase {
|
<table width="100%" border="0"> |
<table width="100%" border="0"> |
<tr> |
<tr> |
<td bgcolor="#777777"> |
<td bgcolor="#777777"> |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantro_process"> |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantron_process"> |
<input type="hidden" name="command" value="scantron_validate" /> |
<input type="hidden" name="command" value="scantron_validate" /> |
$default_form_data |
$default_form_data |
<table width="100%" border="0"> |
<table width="100%" border="0"> |
Line 3480 sub scantron_selectphase {
|
Line 3509 sub scantron_selectphase {
|
<td> Format of data file: </td><td> $format_selector </td> |
<td> Format of data file: </td><td> $format_selector </td> |
</tr> |
</tr> |
<tr bgcolor="#ffffe6"> |
<tr bgcolor="#ffffe6"> |
|
<td> Saved CODEs to validate against: </td><td> $CODE_selector</td> |
|
</tr> |
|
<tr bgcolor="#ffffe6"> |
|
<td> Each CODE is only to be used once:</td><td> $CODE_unique </td> |
|
</tr> |
|
<tr bgcolor="#ffffe6"> |
|
<td> Options: </td> |
<td> |
<td> |
<!-- FIXME this is lazy, a single parse of the set should let me know what this is --> |
<input type="checkbox" name="scantron_options_redo" value="redo_skipped"/> Do only skipped records <br /> |
Last line to expect an answer on: </td><td> |
<input type="checkbox" name="scantron_options_ignore" value="ignore_corrections"/> Remove any exisiting corrections |
<input type="text" name="scantron_maxbubble" /> |
|
</td> |
</td> |
</tr> |
</tr> |
<tr bgcolor="#ffffe6"> |
<tr bgcolor="#ffffe6"> |
Line 3547 UPLOAD
|
Line 3582 UPLOAD
|
</tr> |
</tr> |
SCANTRONFORM |
SCANTRONFORM |
} |
} |
|
$r->print(<<SCANTRONFORM); |
|
<tr> |
|
<td bgcolor="#777777"> |
|
<form action='/adm/grades' name='scantron_download'> |
|
<input type="hidden" name="command" value="scantron_download" /> |
|
<table width="100%" border="0"> |
|
<tr bgcolor="#e6ffff"> |
|
<td colspan="2"> |
|
<b>Download a scoring office file</b> |
|
</td> |
|
</tr> |
|
<tr bgcolor="#ffffe6"> |
|
<td> Filename of scoring office file: </td><td> $file_selector </td> |
|
</tr> |
|
<tr bgcolor="#ffffe6"> |
|
<td> |
|
Records to download |
|
</td> |
|
<td> |
|
<input type="radio" name="scantron_options" value="download_skipped"/> Skipped Records <br /> |
|
<input type="radio" name="scantron_options" value="download_corrected"/> Corrected Records <br /> |
|
<input checked="on" type="radio" name="scantron_options" value="dowload_orig"/> Original Records |
|
</td> |
|
</tr> |
|
<tr bgcolor="#ffffe6"> |
|
<td colspan="2"> |
|
<input type="submit" value="Validate Scantron Records" /> |
|
</td> |
|
</tr> |
|
</table> |
|
</form> |
|
</td> |
|
</tr> |
|
SCANTRONFORM |
|
|
$r->print(<<SCANTRONFORM); |
$r->print(<<SCANTRONFORM); |
</table> |
</table> |
Line 3603 sub scantron_fixup_scanline {
|
Line 3672 sub scantron_fixup_scanline {
|
my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_; |
my ($scantron_config,$scan_data,$line,$whichline,$field,$args)=@_; |
if ($field eq 'ID') { |
if ($field eq 'ID') { |
if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) { |
if (length($args->{'newid'}) > $$scantron_config{'IDlength'}) { |
return ($line,1,'New value to large'); |
return ($line,1,'New value too large'); |
} |
} |
if (length($args->{'newid'}) < $$scantron_config{'IDlength'}) { |
if (length($args->{'newid'}) < $$scantron_config{'IDlength'}) { |
$args->{'newid'}=sprintf('%-'.$$scantron_config{'IDlength'}.'s', |
$args->{'newid'}=sprintf('%-'.$$scantron_config{'IDlength'}.'s', |
Line 3615 sub scantron_fixup_scanline {
|
Line 3684 sub scantron_fixup_scanline {
|
&scan_data($scan_data,"$whichline.user", |
&scan_data($scan_data,"$whichline.user", |
$args->{'username'}.':'.$args->{'domain'}); |
$args->{'username'}.':'.$args->{'domain'}); |
} |
} |
|
} elsif ($field eq 'CODE') { |
|
if ($args->{'CODE_ignore_dup'}) { |
|
&scan_data($scan_data,"$whichline.CODE_ignore_dup",'1'); |
|
} |
|
&scan_data($scan_data,"$whichline.useCODE",'1'); |
|
if ($args->{'CODE'} ne 'use_unfound') { |
|
if (length($args->{'CODE'}) > $$scantron_config{'CODElength'}) { |
|
return ($line,1,'New CODE value too large'); |
|
} |
|
if (length($args->{'CODE'}) < $$scantron_config{'CODElength'}) { |
|
$args->{'CODE'}=sprintf('%-'.$$scantron_config{'CODElength'}.'s',$args->{'CODE'}); |
|
} |
|
substr($line,$$scantron_config{'CODEstart'}-1, |
|
$$scantron_config{'CODElength'})=$args->{'CODE'}; |
|
} |
} elsif ($field eq 'answer') { |
} elsif ($field eq 'answer') { |
my $length=$scantron_config->{'Qlength'}; |
my $length=$scantron_config->{'Qlength'}; |
my $off=$scantron_config->{'Qoff'}; |
my $off=$scantron_config->{'Qoff'}; |
Line 3645 sub scan_data {
|
Line 3729 sub scan_data {
|
} |
} |
|
|
sub scantron_parse_scanline { |
sub scantron_parse_scanline { |
my ($line,$whichline,$scantron_config,$scan_data)=@_; |
my ($line,$whichline,$scantron_config,$scan_data,$justCODE)=@_; |
my %record; |
my %record; |
my $questions=substr($line,$$scantron_config{'Qstart'}-1); |
my $questions=substr($line,$$scantron_config{'Qstart'}-1); |
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); |
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); |
if ($$scantron_config{'CODElocation'} ne 0) { |
if ($$scantron_config{'CODElocation'} ne 0) { |
if ($$scantron_config{'CODElocation'} < 0) { |
if ($$scantron_config{'CODElocation'} < 0) { |
$record{'scantron.CODE'}=substr($data,$$scantron_config{'CODEstart'}-1, |
$record{'scantron.CODE'}=substr($data, |
|
$$scantron_config{'CODEstart'}-1, |
$$scantron_config{'CODElength'}); |
$$scantron_config{'CODElength'}); |
|
if (&scan_data($scan_data,"$whichline.useCODE")) { |
|
$record{'scantron.useCODE'}=1; |
|
} |
|
if (&scan_data($scan_data,"$whichline.CODE_ignore_dup")) { |
|
$record{'scantron.CODE_ignore_dup'}=1; |
|
} |
} else { |
} else { |
#FIXME interpret first N questions |
#FIXME interpret first N questions |
} |
} |
} |
} |
|
if ($justCODE) { return \%record; } |
$record{'scantron.ID'}=substr($data,$$scantron_config{'IDstart'}-1, |
$record{'scantron.ID'}=substr($data,$$scantron_config{'IDstart'}-1, |
$$scantron_config{'IDlength'}); |
$$scantron_config{'IDlength'}); |
$record{'scantron.PaperID'}= |
$record{'scantron.PaperID'}= |
Line 3748 sub scantron_process_corrections {
|
Line 3840 sub scantron_process_corrections {
|
'ID',{'newid'=>$newid, |
'ID',{'newid'=>$newid, |
'username'=>$ENV{'form.scantron_username'}, |
'username'=>$ENV{'form.scantron_username'}, |
'domain'=>$ENV{'form.scantron_domain'}}); |
'domain'=>$ENV{'form.scantron_domain'}}); |
|
} elsif ($ENV{'form.scantron_corrections'} =~ /^(duplicate|incorrect)CODE$/) { |
|
my $resolution=$ENV{'form.scantron_CODE_resolution'}; |
|
my $newCODE; |
|
my %args; |
|
if ($resolution eq 'use_unfound') { |
|
$newCODE='use_unfound'; |
|
} elsif ($resolution eq 'use_found') { |
|
$newCODE=$ENV{'form.scantron_CODE_selectedvalue'}; |
|
} elsif ($resolution eq 'use_typed') { |
|
$newCODE=$ENV{'form.scantron_CODE_newvalue'}; |
|
} |
|
if ($ENV{'form.scantron_corrections'} eq 'duplicateCODE') { |
|
$args{'CODE_ignore_dup'}=1; |
|
} |
|
$args{'CODE'}=$newCODE; |
|
($line,$err,$errmsg)= |
|
&scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which, |
|
'CODE',\%args); |
} elsif ($ENV{'form.scantron_corrections'} =~ /^(missing|double)bubble$/) { |
} elsif ($ENV{'form.scantron_corrections'} =~ /^(missing|double)bubble$/) { |
foreach my $question (split(',',$ENV{'form.scantron_questions'})) { |
foreach my $question (split(',',$ENV{'form.scantron_questions'})) { |
($line,$err,$errmsg)= |
($line,$err,$errmsg)= |
Line 3772 sub scantron_validate_file {
|
Line 3882 sub scantron_validate_file {
|
my ($symb,$url)=&get_symb_and_url($r); |
my ($symb,$url)=&get_symb_and_url($r); |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
my $default_form_data=&defaultFormData($symb,$url); |
my $default_form_data=&defaultFormData($symb,$url); |
|
if ($ENV{'form.scantron_options_ignore'} eq 'ignore_corrections') { |
|
my $result=&scantron_remove('corrected'); |
|
&Apache::lonnet::logthis("result was $result"); |
|
if ($result ne 'ok' && $result ne 'not_found' ) { |
|
$r->print("An error occured ($result) when trying to Remove the existing corrections."); |
|
} |
|
$ENV{'form.scantron_options_ignore'}='done'; |
|
} |
if ($ENV{'form.scantron_corrections'}) { |
if ($ENV{'form.scantron_corrections'}) { |
&scantron_process_corrections($r); |
&scantron_process_corrections($r); |
} |
} |
|
$r->print("<p>Gathering neccessary info.</p>");$r->rflush(); |
|
my $max_bubble=&scantron_get_maxbubble($r); |
#get the student pick code ready |
#get the student pick code ready |
$r->print(&Apache::loncommon::studentbrowser_javascript()); |
$r->print(&Apache::loncommon::studentbrowser_javascript()); |
my $result= <<SCANTRONFORM; |
my $result= <<SCANTRONFORM; |
Line 3783 sub scantron_validate_file {
|
Line 3902 sub scantron_validate_file {
|
<input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" /> |
<input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" /> |
<input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" /> |
<input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" /> |
<input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" /> |
<input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" /> |
<input type="hidden" name="scantron_maxbubble" value="$ENV{'form.scantron_maxbubble'}" /> |
<input type="hidden" name="scantron_maxbubble" value="$max_bubble'" /> |
|
<input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" /> |
|
<input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" /> |
|
<input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_options_redo'}" /> |
|
<input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_options_ignore'}" /> |
$default_form_data |
$default_form_data |
SCANTRONFORM |
SCANTRONFORM |
$r->print($result); |
$r->print($result); |
Line 3830 SCANTRONFORM
|
Line 3953 SCANTRONFORM
|
return ''; |
return ''; |
} |
} |
|
|
|
sub scantron_remove { |
|
my ($which)=@_; |
|
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
|
my $file='scantron_'; |
|
if ($which eq 'corrected') { |
|
$file.='corrected_'; |
|
} else { |
|
return 'refused'; |
|
} |
|
$file.=$ENV{'form.scantron_selectfile'}; |
|
&Apache::lonnet::logthis("removeing $file"); |
|
my $result=&Apache::lonnet::removeuserfile($cname,$cdom,$file); |
|
my @keys=&Apache::lonnet::getkeys('nohist_scantrondata',$cdom,$cname); |
|
&Apache::lonnet::logthis('got keys '.join(':',@keys)); |
|
&Apache::lonnet::logthis("cdom $cdom cname $cname"); |
|
my @todelete; |
|
my $filename=$ENV{'form.scantron_selectfile'}; |
|
&Apache::lonnet::logthis('filename '.$filename); |
|
foreach my $key (@keys) { |
|
if ($key=~/^\Q$filename\E_/) { |
|
push(@todelete,$key); |
|
} |
|
} |
|
&Apache::lonnet::logthis('todelete '.join(':',@todelete)); |
|
if (@todelete) { |
|
&Apache::lonnet::del('nohist_scantrondata',\@todelete,$cdom,$cname); |
|
} |
|
return $result; |
|
} |
|
|
sub scantron_getfile { |
sub scantron_getfile { |
#FIXME really would prefer a scantron directory but tokenwrapper |
#FIXME really would prefer a scantron directory but tokenwrapper |
# doesn't allow access to subdirs of userfiles |
# doesn't allow access to subdirs of userfiles |
Line 3941 sub scantron_validate_ID {
|
Line 4095 sub scantron_validate_ID {
|
$line,'duplicateID',$username); |
$line,'duplicateID',$username); |
return(1); |
return(1); |
} |
} |
#FIXME store away line we prviously saw the ID on to use above |
#FIXME store away line we previously saw the ID on to use above |
$found{'ids'}{$found}++; |
$found{'ids'}{$found}++; |
$found{'usernames'}{$username}++; |
$found{'usernames'}{$username}++; |
} else { |
} else { |
Line 3988 sub scantron_get_correction {
|
Line 4142 sub scantron_get_correction {
|
$r->print('<input type="hidden" name="scantron_corrections" value="'.$error.'" />'."\n"); |
$r->print('<input type="hidden" name="scantron_corrections" value="'.$error.'" />'."\n"); |
$r->print('<input type="hidden" name="scantron_line" value="'.$i.'" />'."\n"); |
$r->print('<input type="hidden" name="scantron_line" value="'.$i.'" />'."\n"); |
if ($error =~ /ID$/) { |
if ($error =~ /ID$/) { |
if ($error eq 'unknownID') { |
if ($error eq 'incorrectID') { |
$r->print("The encoded ID is not in the classlist</p>\n"); |
$r->print("The encoded ID is not in the classlist</p>\n"); |
} elsif ($error eq 'duplicateID') { |
} elsif ($error eq 'duplicateID') { |
$r->print("The encoded ID has also been used by a previous paper $arg</p>\n"); |
$r->print("The encoded ID has also been used by a previous paper $arg</p>\n"); |
Line 4006 sub scantron_get_correction {
|
Line 4160 sub scantron_get_correction {
|
'scantron_username','scantron_domain')); |
'scantron_username','scantron_domain')); |
$r->print(": <input type='text' name='scantron_username' value='' />"); |
$r->print(": <input type='text' name='scantron_username' value='' />"); |
$r->print("\n@". |
$r->print("\n@". |
&Apache::loncommon::select_dom_form($ENV{'request.role..domain'},'scantron_domain')); |
&Apache::loncommon::select_dom_form($ENV{'request.role.domain'},'scantron_domain')); |
|
|
$r->print('</li>'); |
$r->print('</li>'); |
|
} elsif ($error =~ /CODE$/) { |
|
if ($error eq 'incorrectCODE') { |
|
$r->print("</p><p>The encoded CODE is not in the list of possible CODEs</p>\n"); |
|
} elsif ($error eq 'duplicateCODE') { |
|
$r->print("</p><p>The encoded CODE has also been used by a previous paper $arg, and CODEs were supposed to be unique</p>\n"); |
|
} |
|
$r->print("<p>The CODE on the form is <tt>". |
|
$$scan_record{'scantron.CODE'}."</tt><br />\n"); |
|
$r->print("<p>The ID on the form is <tt>". |
|
$$scan_record{'scantron.ID'}."</tt><br />\n"); |
|
$r->print("The name on the paper is ". |
|
$$scan_record{'scantron.LastName'}.",". |
|
$$scan_record{'scantron.FirstName'}."</p>"); |
|
$r->print("<p>How should I handle this? <br /> \n"); |
|
$r->print("\n<br /> "); |
|
$r->print("<input type='radio' name='scantron_CODE_resolution' value='use_unfound' checked='on' /> Use the CODE <b><tt>".$$scan_record{'scantron.CODE'}."</tt></b> that is was on the paper, ignoring the error."); |
|
$r->print("\n<br />"); |
|
$r->print(<<ENDSCRIPT); |
|
<script type="text/javascript"> |
|
function change_radio(field) { |
|
var slct=document.scantronupload.scantron_CODE_resolution; |
|
var i; |
|
for (i=0;i<slct.length;i++) { |
|
if (slct[i].value==field) { slct[i].checked=true; } |
|
} |
|
} |
|
</script> |
|
ENDSCRIPT |
|
my $href="/adm/pickcode?". |
|
"form=".&Apache::lonnet::escape("scantronupload"). |
|
"&scantron_format=".&Apache::lonnet::escape($ENV{'form.scantron_format'}). |
|
"&scantron_CODElist=".&Apache::lonnet::escape($ENV{'form.scantron_CODElist'}). |
|
"&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}). |
|
"&scantron_selectfile=".&Apache::lonnet::escape($ENV{'form.scantron_selectfile'}); |
|
$r->print("<input type='radio' name='scantron_CODE_resolution' value='use_found' /> <a target='_blank' href='$href'>Select</a> a CODE from the list of all CODEs and use it. Selected CODE is <input readonly='true' type='text' size='8' name='scantron_CODE_selectedvalue' onfocus=\"javascript:change_radio('use_found')\" onchange=\"javascript:change_radio('use_found')\" />"); |
|
$r->print("\n<br />"); |
|
$r->print("<input type='radio' name='scantron_CODE_resolution' value='use_typed' /> Use <input type='text' size='8' name='scantron_CODE_newvalue' onfocus=\"javascript:change_radio('use_typed')\" onkeypress=\"javascript:change_radio('use_typed')\" /> as the CODE."); |
|
$r->print("\n<br /><br />"); |
} elsif ($error eq 'doublebubble') { |
} elsif ($error eq 'doublebubble') { |
#FIXME Need to print out who this is along with the paper info |
#FIXME Need to print out who this is along with the paper info |
$r->print("<p>There have been multiple bubbles scanned for a some question(s)</p>\n"); |
$r->print("<p>There have been multiple bubbles scanned for a some question(s)</p>\n"); |
Line 4060 sub scantron_bubble_selector {
|
Line 4252 sub scantron_bubble_selector {
|
sub scantron_validate_CODE { |
sub scantron_validate_CODE { |
my ($r,$currentphase) = @_; |
my ($r,$currentphase) = @_; |
#FIXME doesn't do anything yet |
#FIXME doesn't do anything yet |
|
my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); |
|
if ($scantron_config{'CODElocation'} && |
|
$scantron_config{'CODEstart'} && |
|
$scantron_config{'CODElength'}) { |
|
if (!defined($ENV{'form.scantron_CODElist'})) { |
|
&FIXME_blow_up() |
|
} |
|
} else { |
|
return (0,$currentphase+1); |
|
} |
|
|
|
my %usedCODEs; |
|
|
|
my $old_name=$ENV{'form.scantron_CODElist'}; |
|
my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
|
my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum); |
|
my %allcodes=map {(&Apache::lonprintout::num_to_letters($_),1)} split(',',$result{$old_name}); |
|
|
|
my ($scanlines,$scan_data)=&scantron_getfile(); |
|
for (my $i=0;$i<=$scanlines->{'count'};$i++) { |
|
my $line=&scantron_get_line($scanlines,$i); |
|
if ($line=~/^[\s\cz]*$/) { next; } |
|
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, |
|
$scan_data); |
|
my $CODE=$$scan_record{'scantron.CODE'}; |
|
my $error=0; |
|
if (!exists($allcodes{$CODE}) && !$$scan_record{'scantron.useCODE'}) { |
|
&scantron_get_correction($r,$i,$scan_record, |
|
\%scantron_config, |
|
$line,'incorrectCODE',$CODE); |
|
return(1); |
|
} |
|
if (exists($usedCODEs{$CODE}) && $ENV{'form.scantron_CODEunique'} |
|
&& !$$scan_record{'scantron.CODE_ignore_dup'}) { |
|
&scantron_get_correction($r,$i,$scan_record, |
|
\%scantron_config, |
|
$line,'duplicateCODE',$CODE); |
|
return(1); |
|
} |
|
$usedCODEs{$CODE}++; |
|
} |
return (0,$currentphase+1); |
return (0,$currentphase+1); |
} |
} |
|
|
Line 4086 sub scantron_validate_doublebubble {
|
Line 4320 sub scantron_validate_doublebubble {
|
return (0,$currentphase+1); |
return (0,$currentphase+1); |
} |
} |
|
|
|
sub scantron_get_maxbubble { |
|
my ($r)=@_; |
|
if (defined($ENV{'form.scantron_maxbubble'}) && |
|
$ENV{'form.scantron_maxbubble'}) { |
|
return $ENV{'form.scantron_maxbubble'}; |
|
} |
|
my $navmap=Apache::lonnavmaps::navmap->new(); |
|
my (undef,undef,$sequence)= |
|
&Apache::lonnet::decode_symb($ENV{'form.selectpage'}); |
|
my $map=$navmap->getResourceByUrl($sequence); |
|
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
|
&Apache::lonnet::delenv('form.counter'); |
|
foreach my $resource (@resources) { |
|
my $result=&Apache::lonnet::ssi($resource->src()); |
|
} |
|
&Apache::lonnet::delenv('scantron\.'); |
|
my $envfile=$ENV{'user.environment'}; |
|
$envfile=~/\/([^\/]+)\.id$/; |
|
$envfile=$1; |
|
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
|
$envfile); |
|
$ENV{'form.scantron_maxbubble'}=$ENV{'form.counter'}-1; |
|
return $ENV{'form.scantron_maxbubble'}; |
|
} |
|
|
sub scantron_validate_missingbubbles { |
sub scantron_validate_missingbubbles { |
my ($r,$currentphase) = @_; |
my ($r,$currentphase) = @_; |
#get student info |
#get student info |
Line 4095 sub scantron_validate_missingbubbles {
|
Line 4354 sub scantron_validate_missingbubbles {
|
#get scantron line setup |
#get scantron line setup |
my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); |
my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); |
my ($scanlines,$scan_data)=&scantron_getfile(); |
my ($scanlines,$scan_data)=&scantron_getfile(); |
my $max_bubble=$ENV{'form.scantron_maxbubble'}; |
my $max_bubble=&scantron_get_maxbubble(); |
if (!$max_bubble) { $max_bubble=2**31; } |
if (!$max_bubble) { $max_bubble=2**31; } |
for (my $i=0;$i<=$scanlines->{'count'};$i++) { |
for (my $i=0;$i<=$scanlines->{'count'};$i++) { |
my $line=&scantron_get_line($scanlines,$i); |
my $line=&scantron_get_line($scanlines,$i); |
Line 4274 sub scantron_upload_scantron_data_save {
|
Line 4533 sub scantron_upload_scantron_data_save {
|
unless ($fname) { return 'error: no uploaded file'; } |
unless ($fname) { return 'error: no uploaded file'; } |
$fname='scantron_orig_'.$fname; |
$fname='scantron_orig_'.$fname; |
if (length($ENV{'form.upfile'}) < 2) { |
if (length($ENV{'form.upfile'}) < 2) { |
$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'})."</tt>, contained no information. Please check that you entered the correct filename."); |
$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename."); |
} else { |
} else { |
my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname); |
my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname); |
if ($result =~ m|^/uploaded/|) { |
if ($result =~ m|^/uploaded/|) { |
$r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>"); |
$r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>"); |
} else { |
} else { |
$r->print("<font color='red'>Error:</font> An error (".$result.") occured when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'})."</tt>"); |
$r->print("<font color='red'>Error:</font> An error (".$result.") occured when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>"); |
} |
} |
} |
} |
if ($symb) { |
if ($symb) { |