--- loncom/interface/lonpickcode.pm 2004/04/24 08:31:57 1.2 +++ loncom/interface/lonpickcode.pm 2005/02/17 08:29:43 1.5 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a CODE from the list of possible CODEs # -# $Id: lonpickcode.pm,v 1.2 2004/04/24 08:31:57 albertel Exp $ +# $Id: lonpickcode.pm,v 1.5 2005/02/17 08:29:43 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,41 +48,20 @@ sub get_code_freq { &Apache::grades::scantron_parse_scanline($line,$i, \%scantron_config, $scan_data,1); - $codes{$$scan_record{'scantron.CODE'}}++; + push(@{$codes{$$scan_record{'scantron.CODE'}}},$$scan_record{'scantron.PaperID'}); } 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;$isend_http_header; return OK if $r->header_only; - + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network with CAPA @@ -104,8 +83,8 @@ ENDDOCUMENT $r->print(< function gochoose(newcode) { - opener.document.$ENV{'form.form'}.scan_CODE_selectedvalue.value=newcode; - var slct=opener.document.$ENV{'form.form'}.scan_CODE_resolution; + opener.document.$ENV{'form.form'}.scantron_CODE_selectedvalue.value=newcode; + var slct=opener.document.$ENV{'form.form'}.scantron_CODE_resolution; var i; for (i=0;iprint("

The CODE on the paper is ".$ENV{'form.curCODE'}. ". Please Select a new one.

\n".'
'); - my %codes=&get_codes(); + my %codes=&Apache::grades::get_codes(); 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--) { my $to_print="

CODEs with $i matches

"; - $to_print.=''; + $to_print.='
CODE# of exams using this CODE
'; my $print; 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; - my $count=$code_freq{$code}; - if (!$count) { $count=0; } + my ($count,$list); + if (!ref($code_freq{$code})) { + $count=0; + } else { + $count=scalar(@{$code_freq{$code}}); + $list=' - '.join(', ',@{$code_freq{$code}}); + } $to_print.=''. - ''; + ''; delete($codes{$code}); } $to_print.='
CODEexams using this CODE
'. ''.$code.' '.$count. - '
'.$code.''.$count. + $list.'
';