[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm lonhomework.pm structuretags.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 24 Jun 2006 01:28:18 -0000


albertel		Fri Jun 23 21:28:18 2006 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm structuretags.pm bridgetask.pm 
  Log:
  - improving handling of some problem globals to longer be left with dangling values
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.252 loncom/homework/lonhomework.pm:1.253
--- loncom/homework/lonhomework.pm:1.252	Tue Jun 20 01:10:00 2006
+++ loncom/homework/lonhomework.pm	Fri Jun 23 21:28:17 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.252 2006/06/20 05:10:00 albertel Exp $
+# $Id: lonhomework.pm,v 1.253 2006/06/24 01:28:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -621,6 +621,13 @@
     return '';
 }
 
+sub unset_permissions {
+    undef($Apache::lonhomework::queuegrade);
+    undef($Apache::lonhomework::modifygrades);
+    undef($Apache::lonhomework::viewgrades);
+    undef($Apache::lonhomework::browse);
+}
+
 sub setupheader {
     my $request=$_[0];
     &Apache::loncommon::content_type($request,'text/html');
@@ -1020,10 +1027,15 @@
 	if ($Apache::lonhomework::browse ne 'F' && 
 	    $env{'request.state'} ne "construct") {
 	    #should know where we are, so ask
-	    $request->internal_redirect('/adm/ambiguous'); return OK;
+	    &unset_permissions();
+	    $request->internal_redirect('/adm/ambiguous');
+	    return OK;
 	}
     }
-    if (&setupheader($request)) { return OK; }
+    if (&setupheader($request)) {
+	&unset_permissions();
+	return OK;
+    }
     &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade");
     &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'});
     my ($symb) = &Apache::lonxml::whichuser();
@@ -1057,6 +1069,7 @@
     #&Apache::lonxml::debug("Spent $td seconds processing");
     # always turn off debug messages
     $Apache::lonxml::debug=0;
+    &unset_permissions();
     return OK;
 
 }
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.357 loncom/homework/structuretags.pm:1.358
--- loncom/homework/structuretags.pm:1.357	Mon Jun 19 23:33:55 2006
+++ loncom/homework/structuretags.pm	Fri Jun 23 21:28:17 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.357 2006/06/20 03:33:55 albertel Exp $
+# $Id: structuretags.pm,v 1.358 2006/06/24 01:28:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -526,7 +526,9 @@
     @Apache::structuretags::whileline=();
     $Apache::lonhomework::scantronmode=0;
     undef($Apache::lonhomework::name);
-
+    undef($Apache::lonhomework::default_type);
+    undef($Apache::lonhomework::type);
+    undef($Apache::lonhomework::problemstatus);
 }
 
 sub reset_problem_globals {
@@ -538,6 +540,11 @@
 #detect if we try to do 2 problems in one file
 #   undef($Apache::lonhomework::parsing_a_problem);
     undef($Apache::lonhomework::name);
+    undef($Apache::lonhomework::default_type);
+    undef($Apache::lonhomework::type);
+    undef($Apache::lonhomework::scantronmode);
+    undef($Apache::lonhomework::problemstatus);
+    undef($Apache::lonhomework::ignore_response_errors);
 }
 
 sub set_problem_state {
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.178 loncom/homework/bridgetask.pm:1.179
--- loncom/homework/bridgetask.pm:1.178	Fri Jun 23 18:32:39 2006
+++ loncom/homework/bridgetask.pm	Fri Jun 23 21:28:17 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.178 2006/06/23 22:32:39 albertel Exp $
+# $Id: bridgetask.pm,v 1.179 2006/06/24 01:28:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -530,8 +530,8 @@
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
 
     my ($status,$accessmsg,$slot);
+    &Apache::structuretags::init_problem_globals('Task');
     if ($target ne 'webgrade') {
-	&Apache::structuretags::init_problem_globals('Task');
 	&Apache::structuretags::initialize_storage();
 	&Apache::lonhomework::showhash(%Apache::lonhomework::history);
 	if ($env{'request.state'} eq 'construct') {
@@ -1221,6 +1221,7 @@
 	$result.=&Apache::response::meta_stores_write('status','string',
 						      'Bridge Task Status');
     }
+    &Apache::structuretags::reset_problem_globals('Task');
     undef($Apache::lonhomework::parsing_a_task);
     return $result;
 }