[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 08 Mar 2006 22:32:13 -0000


albertel		Wed Mar  8 17:32:13 2006 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  - use the new form.counter helpers
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.427 loncom/interface/lonprintout.pm:1.428
--- loncom/interface/lonprintout.pm:1.427	Wed Mar  8 17:28:29 2006
+++ loncom/interface/lonprintout.pm	Wed Mar  8 17:32:11 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.427 2006/03/08 22:28:29 albertel Exp $
+# $Id: lonprintout.pm,v 1.428 2006/03/08 22:32:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1120,12 +1120,14 @@
 		}
 		$form{'rndseed'}=$rndseed;
 		&Apache::lonnet::appenv(%moreenv);
-		&Apache::lonnet::delenv('form.counter');
-		&Apache::lonxml::init_counter();
-		&Apache::lonxml::store_counter();
+
+		&Apache::lonxml::clear_problem_counter();
+
 		$resources_printed .= $currentURL.':';
 		$texversion.=&Apache::lonnet::ssi($currentURL,%form);
-		&Apache::lonnet::delenv('form.counter');
+
+		&Apache::lonxml::clear_problem_counter();
+
 		&Apache::lonnet::delenv('request.filename');
 	    }
 	    # current document with answers.. no need to encap in minipage
@@ -1272,9 +1274,9 @@
 	my $flag_page_in_sequence = 'NO';
 	my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
 	my $prevassignment='';
-	&Apache::lonnet::delenv('form.counter');
-	&Apache::lonxml::init_counter();
-	&Apache::lonxml::store_counter();
+
+	&Apache::lonxml::clear_problem_counter();
+
 	my $pbreakresources = keys %page_breaks;
 	for (my $i=0;$i<=$#master_seq;$i++) {
 
@@ -1297,7 +1299,9 @@
 	    if ($urlp!~m|^/adm/|
 		&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
 		$resources_printed .= $urlp.':';
-		my $pre_counter=$env{'form.counter'};
+
+		&Apache::lonxml::remember_problem_counter();
+
 		$texversion.=&Apache::lonnet::ssi($urlp,%form);
 		if ($urlp=~/\.page$/) {
 		    ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
@@ -1305,10 +1309,7 @@
 		    $texversion =~ s/\\end{document}\d*/\\end{document}/;
 		    $flag_page_in_sequence = 'YES';
 		} 
-		my ($envfile) = ($env{'user.environment'} =~m|/([^/]+)\.id$| );
-		&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
-							 $envfile);
-		my $current_counter=$env{'form.counter'};
+
 		if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
 		   ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
 		    #  Don't permanently pervert the %form hash
@@ -1316,9 +1317,10 @@
 		    $answerform{'grade_target'}='answer';
 		    $answerform{'answer_output_mode'}='tex';
 		    $resources_printed .= $urlp.':';
-		    &Apache::lonnet::appenv(('form.counter' => $pre_counter));
+
+		    &Apache::lonxml::restore_problem_counter();
 		    my $answer=&Apache::lonnet::ssi($urlp,%answerform);
-		    &Apache::lonnet::appenv(('form.counter' => $current_counter));
+
 		    if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
 			$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
 		    } else {
@@ -1380,7 +1382,7 @@
 	    }	    
 	    if (&Apache::loncommon::connection_aborted($r)) { last; }
 	}
-	&Apache::lonnet::delenv('form.counter');
+	&Apache::lonxml::clear_problem_counter();
 	if ($flag_page_in_sequence eq 'YES') {
 	    $result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;
 	}	
@@ -1758,9 +1760,8 @@
     my $i           = 0;
     #goes through all resources, checks if they are available for 
     #current student, and produces output   
-    &Apache::lonnet::delenv('form.counter');
-    &Apache::lonxml::init_counter();
-    &Apache::lonxml::store_counter();
+
+    &Apache::lonxml::clear_problem_counter();
     my %page_breaks  = &get_page_breaks($helper);
     my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'});
     my $columns_in_format = $format_array[1];
@@ -1779,22 +1780,22 @@
 		if ($res_url!~m|^ext/|
 		    && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
 		    $printed .= $curresline.':';
-		    my $pre_counter=$env{'form.counter'};
+
+		    &Apache::lonxml::remember_problem_counter();    
+
 		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
-		    my ($envfile) =
-			( $env{'user.environment'} =~ m|/([^/]+)\.id$| );
-		    &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
-							     $envfile);
-		    my $current_counter=$env{'form.counter'};
+
 		    if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
 		       ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
 			#   Use a copy of the hash so we don't pervert it on future loop passes.
 			my %answerenv = %{$moreenv};
 			$answerenv{'answer_output_mode'}='tex';
 			$answerenv{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
-			&Apache::lonnet::appenv(('form.counter' => $pre_counter));
+			
+			&Apache::lonxml::restore_problem_counter();
+
 			my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%answerenv);
-			&Apache::lonnet::appenv(('form.counter' => $current_counter));
+
 			if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
 			    $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
 			} else {
@@ -1817,11 +1818,7 @@
 		} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
 		    $printed .= $curresline.':';
 		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
-		    my ($envfile) = 
-			( $env{'user.environment'} =~ m|/([^/]+)\.id$| );
-		    &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
-							     $envfile);
-		    my $current_counter=$env{'form.counter'};
+
 		    if ($remove_latex_header eq 'YES') {
 			$rendered = &latex_header_footer_remove($rendered);
 		    } else {