[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Tue, 26 Jul 2005 10:50:35 -0000
foxr Tue Jul 26 06:50:35 2005 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Defect 4258 - Printing with answers only prints first problem.. the
remainder only show answers.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.379 loncom/interface/lonprintout.pm:1.380
--- loncom/interface/lonprintout.pm:1.379 Mon Jul 25 06:27:51 2005
+++ loncom/interface/lonprintout.pm Tue Jul 26 06:50:32 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.379 2005/07/25 10:27:51 foxr Exp $
+# $Id: lonprintout.pm,v 1.380 2005/07/26 10:50:32 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -998,13 +998,15 @@
if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) &&
($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) {
- $form{'grade_target'}='answer';
- $form{'answer_output_mode'}='tex';
- $form{'rndseed'}=$rndseed;
- $form{'problem_split'}=$parmhash{'problem_stream_switch'};
+ # Don't permanently modify %$form...
+ my %answerform = %form;
+ $answerform{'grade_target'}='answer';
+ $answerform{'answer_output_mode'}='tex';
+ $answerform{'rndseed'}=$rndseed;
+ $answerform{'problem_split'}=$parmhash{'problem_stream_switch'};
if ($urlp=~/\/res\//) {$env{'request.state'}='published';}
$resources_printed .= $urlp.':';
- my $answer=&Apache::lonnet::ssi($urlp,%form);
+ my $answer=&Apache::lonnet::ssi($urlp,%answerform);
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
} else {
@@ -1105,10 +1107,12 @@
my $current_counter=$env{'form.counter'};
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
- $form{'grade_target'}='answer';
- $form{'answer_output_mode'}='tex';
+ # Don't permanently pervert the %form hash
+ my %answerform = %form;
+ $answerform{'grade_target'}='answer';
+ $answerform{'answer_output_mode'}='tex';
$resources_printed .= $urlp.':';
- my $answer=&Apache::lonnet::ssi($urlp,%form);
+ 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/;
@@ -1312,12 +1316,14 @@
my $texversion=&Apache::lonnet::ssi($urlp,%form);
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
- $form{'grade_target'}='answer';
- $form{'answer_output_mode'}='tex';
- $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
- $form{'rndseed'}=$rndseed;
+ # Don't permanently pervert %form:
+ my %answerform = %form;
+ $answerform{'grade_target'}='answer';
+ $answerform{'answer_output_mode'}='tex';
+ $answerform{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
+ $answerform{'rndseed'}=$rndseed;
$resources_printed .= $urlp.':';
- my $answer=&Apache::lonnet::ssi($urlp,%form);
+ my $answer=&Apache::lonnet::ssi($urlp,%answerform);
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
} else {
@@ -1527,9 +1533,11 @@
my $current_counter=$env{'form.counter'};
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
- $moreenv->{'answer_output_mode'}='tex';
- $moreenv->{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
- my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%{$moreenv});
+ # 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'};
+ 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/;