[LON-CAPA-cvs] cvs: loncom /homework grades.pm /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 10 Mar 2006 23:49:36 -0000


albertel		Fri Mar 10 18:49:36 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
    /loncom/xml	lonxml.pm 
  Log:
  - elmintaing more direct manipulations of form.counter
  - some style cleanups to the use of ::ssi
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.329 loncom/homework/grades.pm:1.330
--- loncom/homework/grades.pm:1.329	Wed Mar  8 16:56:49 2006
+++ loncom/homework/grades.pm	Fri Mar 10 18:49:29 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.329 2006/03/08 21:56:49 albertel Exp $
+# $Id: grades.pm,v 1.330 2006/03/10 23:49:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4751,7 +4751,7 @@
     $r->print("<p>Gathering neccessary info.</p>");$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);
     
@@ -5250,28 +5250,29 @@
     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'};
 }
 
@@ -5365,7 +5366,8 @@
  	    next;
  	}
   	($uname,$udom)=split(/:/,$uname);
-  	&Apache::lonnet::delenv('form.counter');
+
+	&Apache::lonxml::clear_problem_counter();
   	&Apache::lonnet::appenv(%$scan_record);
 	
 	my $i=0;
@@ -5393,7 +5395,7 @@
 	$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);
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.400 loncom/xml/lonxml.pm:1.401
--- loncom/xml/lonxml.pm:1.400	Wed Mar  8 19:39:28 2006
+++ loncom/xml/lonxml.pm	Fri Mar 10 18:49:35 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.400 2006/03/09 00:39:28 albertel Exp $
+# $Id: lonxml.pm,v 1.401 2006/03/10 23:49:35 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1038,6 +1038,7 @@
 
 sub store_counter {
     &Apache::lonnet::appenv(('form.counter' => $Apache::lonxml::counter));
+    $Apache::lonxml::counter_changed=0;
     return '';
 }
 
@@ -1060,6 +1061,11 @@
 	    &Apache::lonnet::appenv(('form.counter' => $state));
 	}
     }
+    sub get_problem_counter {
+	if ($Apache::lonxml::counter_changed) { &store_counter() }
+	&Apache::lonnet::transfer_profile_to_env();
+	return $env{'form.counter'};
+    }
 }
 
 sub get_all_text {