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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 08 Mar 2006 21:49:26 -0000


albertel		Wed Mar  8 16:49:26 2006 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  - add some functions to make form.counter easier to live with
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.397 loncom/xml/lonxml.pm:1.398
--- loncom/xml/lonxml.pm:1.397	Sun Feb  5 13:30:56 2006
+++ loncom/xml/lonxml.pm	Wed Mar  8 16:49:26 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.397 2006/02/05 18:30:56 albertel Exp $
+# $Id: lonxml.pm,v 1.398 2006/03/08 21:49:26 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1031,6 +1031,28 @@
     return '';
 }
 
+{
+    my $state;
+    sub clear_problem_counter {
+	&Apache::lonnet::logthis(" cpc called from ".(join(':',caller(0))));
+	undef($state);
+	&Apache::lonnet::delenv('form.counter');
+	&Apache::lonxml::init_counter();
+	&Apache::lonxml::store_counter();
+    }
+
+    sub remember_problem_counter {
+	&Apache::lonnet::transfer_profile_to_env();
+	$state = $env{'form.counter'};
+    }
+
+    sub restore_problem_counter {
+	if (defined($state)) {
+	    &Apache::lonnet::appenv(('form.counter' => $state));
+	}
+    }
+}
+
 sub get_all_text {
     my($tag,$pars,$style)= @_;
     my $gotfullstack=1;