[LON-CAPA-cvs] cvs: loncom /homework grades.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 29 Apr 2004 04:47:47 -0000
albertel Thu Apr 29 00:47:47 2004 EDT
Modified files:
/loncom/homework grades.pm
Log:
- no longer need to type in the last line bubbled line number
- can now use a code that isn't listed in the list of codes
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.190 loncom/homework/grades.pm:1.191
--- loncom/homework/grades.pm:1.190 Sat Apr 24 05:01:52 2004
+++ loncom/homework/grades.pm Thu Apr 29 00:47:47 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.190 2004/04/24 09:01:52 albertel Exp $
+# $Id: grades.pm,v 1.191 2004/04/29 04:47:47 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3422,6 +3422,7 @@
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
&Apache::loncommon::propath($cdom,$cname));
+ $result.="<option></option>";
foreach my $filename (@files) {
($filename)=split(/&/,$filename);
if ($filename!~/^scantron_orig_/) { next ; }
@@ -3435,6 +3436,7 @@
sub scantron_scantab {
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
my $result='<select name="scantron_format">'."\n";
+ $result.='<option></option>'."\n";
foreach my $line (<$fh>) {
my ($name,$descrip)=split(/:/,$line);
if ($name =~ /^\#/) { next; }
@@ -3451,6 +3453,7 @@
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>';
@@ -3512,13 +3515,6 @@
<td> Each CODE is only to be used once:</td><td> $CODE_unique </td>
</tr>
<tr bgcolor="#ffffe6">
- <td>
-<!-- FIXME this is lazy, a single parse of the set should let me know what this is -->
- Last line to expect an answer on: </td><td>
- <input type="text" name="scantron_maxbubble" />
- </td>
- </tr>
- <tr bgcolor="#ffffe6">
<td> Options: </td>
<td>
<input type="checkbox" name="scantron_options_redo" value="redo_skipped"/> Redo skipped records <br />
@@ -3689,17 +3685,20 @@
$args->{'username'}.':'.$args->{'domain'});
}
} elsif ($field eq 'CODE') {
- 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'};
- if ($args->{'CODE'}=~/^\s*$/) {
- &scan_data($scan_data,"$whichline.CODE",$args->{'CODE'});
+ if ($args->{'CODE'} eq 'use_unfound') {
+ &scan_data($scan_data,"$whichline.useCODE",'1');
+ } else {
+ 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'};
+# if ($args->{'CODE'}=~/^\s*$/) {
+# &scan_data($scan_data,"$whichline.CODE",$args->{'CODE'});
+# }
}
} elsif ($field eq 'answer') {
my $length=$scantron_config->{'Qlength'};
@@ -3737,8 +3736,12 @@
my $data=substr($line,0,$$scantron_config{'Qstart'}-1);
if ($$scantron_config{'CODElocation'} ne 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'});
+ if (&scan_data($scan_data,"$whichline.useCODE")) {
+ $record{'scantron.useCODE'}=1;
+ }
} else {
#FIXME interpret first N questions
}
@@ -3839,7 +3842,7 @@
my $resolution=$ENV{'form.scantron_CODE_resolution'};
my $newCODE;
if ($resolution eq 'use_unfound') {
- &FIXME_blow_up();
+ $newCODE='use_unfound';
} elsif ($resolution eq 'use_found') {
$newCODE=$ENV{'form.scantron_CODE_selectedvalue'};
} elsif ($resolution eq 'use_typed') {
@@ -3876,6 +3879,8 @@
if ($ENV{'form.scantron_corrections'}) {
&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
$r->print(&Apache::loncommon::studentbrowser_javascript());
my $result= <<SCANTRONFORM;
@@ -3883,7 +3888,7 @@
<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_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_optiond_redo'}" />
@@ -4206,7 +4211,7 @@
if ($scantron_config{'CODElocation'} &&
$scantron_config{'CODEstart'} &&
$scantron_config{'CODElength'}) {
- if (!$ENV{'form.scantron_CODElist'}) {
+ if (!defined($ENV{'form.scantron_CODElist'})) {
&FIXME_blow_up()
}
} else {
@@ -4229,7 +4234,7 @@
$scan_data);
my $CODE=$$scan_record{'scantron.CODE'};
my $error=0;
- if (!exists($allcodes{$CODE})) {
+ if (!exists($allcodes{$CODE}) && !$$scan_record{'scantron.useCODE'}) {
&scantron_get_correction($r,$i,$scan_record,
\%scantron_config,
$line,'incorrectCODE',$CODE);
@@ -4269,6 +4274,31 @@
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 {
my ($r,$currentphase) = @_;
#get student info
@@ -4278,7 +4308,7 @@
#get scantron line setup
my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
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; }
for (my $i=0;$i<=$scanlines->{'count'};$i++) {
my $line=&scantron_get_line($scanlines,$i);