--- loncom/homework/grades.pm 2006/03/07 02:50:15 1.328 +++ loncom/homework/grades.pm 2006/03/13 20:26:51 1.333 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.328 2006/03/07 02:50:15 banghart Exp $ +# $Id: grades.pm,v 1.333 2006/03/13 20:26:51 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1497,6 +1497,7 @@ sub handback_box { sub show_problem { my ($request,$symb,$uname,$udom,$removeform,$viewon,$mode) = @_; my $rendered; + &Apache::lonxml::remember_problem_counter(); if ($mode eq 'both' or $mode eq 'text') { $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom, $env{'request.course.id'}); @@ -1508,6 +1509,7 @@ sub show_problem { } my $companswer; if ($mode eq 'both' or $mode eq 'answer') { + &Apache::lonxml::restore_problem_counter(); $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom, $env{'request.course.id'}); } @@ -1594,6 +1596,7 @@ sub submission { } elsif ($env{'form.vAns'} eq 'yes') { $mode='answer'; } + &Apache::lonxml::clear_problem_counter(); $request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode)); } @@ -1692,6 +1695,7 @@ KEYWORDS } elsif ($env{'form.vAns'} eq 'all') { $mode='answer'; } + &Apache::lonxml::clear_problem_counter(); $request->print(&show_problem($request,$symb,$uname,$udom,1,1,$mode)); } @@ -3755,6 +3759,7 @@ sub displayPage { '
Gathering neccessary info.
");$r->rflush(); #get the student pick code ready $r->print(&Apache::loncommon::studentbrowser_javascript()); - my $max_bubble=&scantron_get_maxbubble($r); + my $max_bubble=&scantron_get_maxbubble(); my $result=&scantron_form_start($max_bubble).$default_form_data; $r->print($result); @@ -4989,7 +5003,7 @@ sub scantron_get_correction { #the previous one or the current one $r->print("An error was detected ($error)");
- if ( defined($$scan_record{'scantron.PaperID'}) ) {
+ if ( $$scan_record{'scantron.PaperID'} =~ /\S/) {
$r->print(" for PaperID ".
$$scan_record{'scantron.PaperID'}." \n");
} else {
@@ -5070,8 +5084,10 @@ ENDSCRIPT
"&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(" Selected CODE is ");
- $r->print("\n
");
+ if ($env{'form.scantron_CODElist'} =~ /\S/) {
+ $r->print(" Selected CODE is ");
+ $r->print("\n
");
+ }
$r->print(" as the CODE.");
$r->print("\n
");
} elsif ($error eq 'doublebubble') {
@@ -5245,28 +5261,29 @@ sub scantron_validate_doublebubble {
return (0,$currentphase+1);
}
-sub scantron_get_maxbubble {
- my ($r)=@_;
+sub scantron_get_maxbubble {
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');
+
+ &Apache::lonxml::clear_problem_counter();
+
foreach my $resource (@resources) {
- my $result=&Apache::lonnet::ssi($resource->src().'?symb='.&Apache::lonnet::escape($resource->symb()));
+ my $result=&Apache::lonnet::ssi($resource->src(),
+ ('symb' => $resource->symb()));
}
&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;
+ $env{'form.scantron_maxbubble'} =
+ &Apache::lonxml::get_problem_counter()-1;
+
return $env{'form.scantron_maxbubble'};
}
@@ -5360,7 +5377,8 @@ SCANTRONFORM
next;
}
($uname,$udom)=split(/:/,$uname);
- &Apache::lonnet::delenv('form.counter');
+
+ &Apache::lonxml::clear_problem_counter();
&Apache::lonnet::appenv(%$scan_record);
my $i=0;
@@ -5388,7 +5406,7 @@ SCANTRONFORM
$completedstudents{$uname}={'line'=>$line};
if (&Apache::loncommon::connection_aborted($r)) { last; }
} continue {
- &Apache::lonnet::delenv('form.counter');
+ &Apache::lonxml::clear_problem_counter();
&Apache::lonnet::delenv('scantron\.');
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);