version 1.3, 2004/04/24 09:01:52
|
version 1.6, 2005/04/07 06:56:23
|
Line 33 use Apache::Constants qw(:common);
|
Line 33 use Apache::Constants qw(:common);
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::grades(); |
use Apache::grades(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonnet; |
|
|
sub get_code_freq { |
sub get_code_freq { |
my ($r)=@_; |
my ($r)=@_; |
my %codes; |
my %codes; |
my %scantron_config= |
my %scantron_config= |
&Apache::grades::get_scantron_config($ENV{'form.scantron_format'}); |
&Apache::grades::get_scantron_config($env{'form.scantron_format'}); |
$r->rflush(); |
$r->rflush(); |
my ($scanlines,$scan_data)=&Apache::grades::scantron_getfile(); |
my ($scanlines,$scan_data)=&Apache::grades::scantron_getfile(); |
for (my $i=0;$i<=$scanlines->{'count'};$i++) { |
for (my $i=0;$i<=$scanlines->{'count'};$i++) { |
Line 48 sub get_code_freq {
|
Line 49 sub get_code_freq {
|
&Apache::grades::scantron_parse_scanline($line,$i, |
&Apache::grades::scantron_parse_scanline($line,$i, |
\%scantron_config, |
\%scantron_config, |
$scan_data,1); |
$scan_data,1); |
$codes{$$scan_record{'scantron.CODE'}}++; |
push(@{$codes{$$scan_record{'scantron.CODE'}}},$$scan_record{'scantron.PaperID'}); |
|
|
} |
} |
return %codes; |
return %codes; |
} |
} |
|
|
sub get_codes { |
|
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}); |
|
return %allcodes; |
|
} |
|
|
|
sub num_matches { |
|
my ($code) = @_; |
|
my $orig=$ENV{'form.curCODE'}; |
|
my @code=split(//,$code); |
|
my @orig=split(//,$orig); |
|
my $same=0; |
|
for (my $i=0;$i<scalar(@code);$i++) { |
|
if ($code[$i] eq $orig[$i]) { $same++; } |
|
} |
|
return $same; |
|
} |
|
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
|
my $html=&Apache::lonxml::xmlbegin(); |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<html> |
$html |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
Line 94 ENDDOCUMENT
|
Line 74 ENDDOCUMENT
|
'form','scantron_format', |
'form','scantron_format', |
'scantron_CODElist']); |
'scantron_CODElist']); |
|
|
if (!($ENV{'request.course.id'}) && |
if (!($env{'request.course.id'}) && |
(&Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) { |
(&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) { |
$r->print('<body>Access not allowed.</body>'); |
$r->print('<body>Access not allowed.</body>'); |
return OK; |
return OK; |
} |
} |
Line 104 ENDDOCUMENT
|
Line 84 ENDDOCUMENT
|
$r->print(<<ENDSCRIPT); |
$r->print(<<ENDSCRIPT); |
<script> |
<script> |
function gochoose(newcode) { |
function gochoose(newcode) { |
opener.document.$ENV{'form.form'}.scantron_CODE_selectedvalue.value=newcode; |
opener.document.$env{'form.form'}.scantron_CODE_selectedvalue.value=newcode; |
var slct=opener.document.$ENV{'form.form'}.scantron_CODE_resolution; |
var slct=opener.document.$env{'form.form'}.scantron_CODE_resolution; |
var i; |
var i; |
for (i=0;i<slct.length;i++) { |
for (i=0;i<slct.length;i++) { |
if (slct[i].value=='use_found') { slct[i].checked=true; } |
if (slct[i].value=='use_found') { slct[i].checked=true; } |
Line 116 function gochoose(newcode) {
|
Line 96 function gochoose(newcode) {
|
ENDSCRIPT |
ENDSCRIPT |
|
|
|
|
$r->print("<p>The CODE on the paper is <tt><b>".$ENV{'form.curCODE'}. |
$r->print("<p>The CODE on the paper is <tt><b>".$env{'form.curCODE'}. |
"</b></tt>. Please Select a new one.</p>\n".'<form>'); |
"</b></tt>. Please Select a new one.</p>\n".'<form>'); |
my %codes=&get_codes(); |
my %codes=&Apache::grades::get_codes(); |
my %code_freq=&get_code_freq($r); |
my %code_freq=&get_code_freq($r); |
my $num_matches=&num_matches($ENV{'form.curCODE'}); |
my $num_matches=length($env{'form.curCODE'}); |
for (my $i=$num_matches;$i>=0;$i--) { |
for (my $i=$num_matches;$i>=0;$i--) { |
my $to_print="<p> CODEs with $i matches</p>"; |
my $to_print="<p> CODEs with $i matches</p>"; |
$to_print.='<table border="1"><tr><td></td><td>CODE</td><td># of exams using this CODE</td>'; |
$to_print.='<table border="1"><tr><td></td><td>CODE</td><td>exams using this CODE</td>'; |
my $print; |
my $print; |
foreach my $code (sort(keys(%codes))) { |
foreach my $code (sort(keys(%codes))) { |
if (&num_matches($code) != $i) { next; } |
if (&Apache::grades::num_matches($env{'form.curCODE'},$code) != $i) { next; } |
$print=1; |
$print=1; |
my $count=$code_freq{$code}; |
my ($count,$list); |
if (!$count) { $count=0; } |
if (!ref($code_freq{$code})) { |
|
$count=0; |
|
} else { |
|
$count=scalar(@{$code_freq{$code}}); |
|
$list=' - '.join(', ',@{$code_freq{$code}}); |
|
} |
$to_print.='<tr><td>'. |
$to_print.='<tr><td>'. |
'<input type="button" value="'.&mt('Select'). |
'<input type="button" value="'.&mt('Select'). |
'" onClick="gochoose(\''.$code.'\')" /></td>'. |
'" onClick="gochoose(\''.$code.'\')" /></td>'. |
'<td><tt>'.$code.'</tt></td><td> <tt>'.$count. |
'<td><tt>'.$code.'</tt></td><td>'.$count. |
'</tt></td></tr>'; |
$list.'</td></tr>'; |
delete($codes{$code}); |
delete($codes{$code}); |
} |
} |
$to_print.='</table>'; |
$to_print.='</table>'; |