--- loncom/interface/lonprintout.pm 2008/04/04 16:46:23 1.519.2.4
+++ loncom/interface/lonprintout.pm 2008/04/22 10:24:24 1.530
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.519.2.4 2008/04/04 16:46:23 raeburn Exp $
+# $Id: lonprintout.pm,v 1.530 2008/04/22 10:24:24 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -150,7 +150,7 @@ sub ssi_with_retries {
$ssi_error = 1;
$ssi_last_error_resource = $resource;
$ssi_last_error = $response->code . " " . $response->message;
- $content='\section*{!!! An error occurred !!!}';
+ $content='\section*{!!! An error occurred !!!}';
&Apache::lonnet::logthis("Error in SSI resource: $resource Error: $ssi_last_error");
}
@@ -160,6 +160,7 @@ sub ssi_with_retries {
sub get_student_view_with_retries {
my ($curresline,$retries,$username,$userdomain,$courseid,$target,$moreenv)=@_;
+
my ($content, $response) = &Apache::loncommon::get_student_view_with_retries($curresline,$retries,$username,$userdomain,$courseid,$target,$moreenv);
if (!$response->is_success) {
$ssi_error = 1;
@@ -169,6 +170,7 @@ sub get_student_view_with_retries {
&Apache::lonnet::logthis("Error in SSI (student view) resource: $curresline Error: $ssi_last_error User: $username:$userdomain");
}
return $content;
+
}
#
@@ -627,7 +629,7 @@ sub character_chart {
$result =~ s/&(\#165|yen);/\\textyen /g;
$result =~ s/&(\#166|brvbar);/\\textbrokenbar /g;
$result =~ s/&(\#167|sect);/\\textsection /g;
- $result =~ s/&(\#168|uml);/\\texthighdieresis /g;
+ $result =~ s/&(\#168|uml);/\\"\{\} /g;
$result =~ s/&(\#169|copy);/\\copyright /g;
$result =~ s/&(\#170|ordf);/\\textordfeminine /g;
$result =~ s/&(\#172|not);/\\ensuremath\{\\neg\}/g;
@@ -638,7 +640,7 @@ sub character_chart {
$result =~ s/&(\#177|plusmn);/\\ensuremath\{\\pm\}/g;
$result =~ s/&(\#178|sup2);/\\ensuremath\{^2\}/g;
$result =~ s/&(\#179|sup3);/\\ensuremath\{^3\}/g;
- $result =~ s/&(\#180|acute);/\\textacute /g;
+ $result =~ s/&(\#180|acute);/\\'\{\} /g;
$result =~ s/&(\#181|micro);/\\ensuremath\{\\mu\}/g;
$result =~ s/&(\#182|para);/\\P/g;
$result =~ s/&(\#183|middot);/\\ensuremath\{\\cdot\}/g;
@@ -1141,6 +1143,11 @@ sub print_latex_header {
'\usepackage{wrapfig}'.
'\usepackage{picins}\usepackage{calc}'."\n".
'\usepackage[utf8]{inputenc}'."\n".
+ '\usepackage{amsmath}'.
+ '\usepackage{amssymb}'.
+ '\usepackage{amsfonts}'.
+ '\usepackage{amsthm}'.
+ '\usepackage{amscd}'.
'\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}'."\n".
'\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}'."\n".
'\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}'."\n".
@@ -1487,8 +1494,8 @@ ENDPART
}
if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
- &Apache::lonnet::appenv('construct.style' =>
- $helper->{'VARS'}->{'style_file'});
+ &Apache::lonnet::appenv({'construct.style' =>
+ $helper->{'VARS'}->{'style_file'}});
} elsif ($env{'construct.style'}) {
&Apache::lonnet::delenv('construct\\.style');
}
@@ -1531,7 +1538,7 @@ ENDPART
$rndseed=$helper->{'VARS'}->{'curseed'};
}
$form{'rndseed'}=$rndseed;
- &Apache::lonnet::appenv(%moreenv);
+ &Apache::lonnet::appenv(\%moreenv);
&Apache::lonxml::clear_problem_counter();
@@ -1679,7 +1686,8 @@ ENDPART
my $pbreakresources = keys %page_breaks;
for (my $i=0;$i<=$#master_seq;$i++) {
- &Apache::lonenc::reset_enc();
+ &Apache::lonenc::reset_enc();
+
# Note due to document structure, not allowed to put \newpage
# prior to the first resource
@@ -1689,10 +1697,11 @@ ENDPART
$result.="\\newpage\n";
}
}
- my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
+ my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
$urlp=&Apache::lonnet::clutter($urlp);
$form{'symb'}=$master_seq[$i];
+
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
@@ -2002,7 +2011,7 @@ ENDPART
}
for (my $i=0;$i<=$#list_of_files;$i++) {
- &Apache::lonenc::reset_enc();
+ &Apache::lonenc::reset_enc();
my $urlp = $list_of_files[$i];
$urlp=~s|//|/|;
@@ -2097,88 +2106,84 @@ ENDPART
}
}
-
- # If there's been an unrecoverable SSI error, report it to the user
- # otherwise, we can write the tex file.
- #
-
#-- writing .tex file in prtspool
my $temp_file;
my $identifier = &Apache::loncommon::get_cgi_id();
my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_$identifier.tex";
if (!($#print_array>0)) {
- unless ($temp_file = Apache::File->new('>'.$filename)) {
- $r->log_error("Couldn't open $filename for output $!");
- return SERVER_ERROR;
- }
- print $temp_file $result;
- my $begin=index($result,'\begin{document}',0);
- my $inc=substr($result,0,$begin+16);
+ unless ($temp_file = Apache::File->new('>'.$filename)) {
+ $r->log_error("Couldn't open $filename for output $!");
+ return SERVER_ERROR;
+ }
+ print $temp_file $result;
+ my $begin=index($result,'\begin{document}',0);
+ my $inc=substr($result,0,$begin+16);
} else {
- my $begin=index($result,'\begin{document}',0);
- my $inc=substr($result,0,$begin+16);
- for (my $i=0;$i<=$#print_array;$i++) {
- if ($i==0) {
- $print_array[$i]=$result;
- } else {
- $print_array[$i].='\end{document}';
- $print_array[$i] =
- &latex_corrections($number_of_columns,$print_array[$i],
- $selectionmade,
- $helper->{'VARS'}->{'ANSWER_TYPE'});
-
- my $anobegin=index($print_array[$i],'\setcounter{page}',0);
- substr($print_array[$i],0,$anobegin)='';
- $print_array[$i]=$inc.$print_array[$i];
- }
- my $temp_file;
- my $newfilename=$filename;
- my $num=$i+1;
- $newfilename =~s/\.tex$//;
- $newfilename=sprintf("%s_%03d.tex",$newfilename, $num);
- unless ($temp_file = Apache::File->new('>'.$newfilename)) {
- $r->log_error("Couldn't open $newfilename for output $!");
- return SERVER_ERROR;
- }
- print $temp_file $print_array[$i];
- }
+ my $begin=index($result,'\begin{document}',0);
+ my $inc=substr($result,0,$begin+16);
+ for (my $i=0;$i<=$#print_array;$i++) {
+ if ($i==0) {
+ $print_array[$i]=$result;
+ } else {
+ $print_array[$i].='\end{document}';
+ $print_array[$i] =
+ &latex_corrections($number_of_columns,$print_array[$i],
+ $selectionmade,
+ $helper->{'VARS'}->{'ANSWER_TYPE'});
+
+ my $anobegin=index($print_array[$i],'\setcounter{page}',0);
+ substr($print_array[$i],0,$anobegin)='';
+ $print_array[$i]=$inc.$print_array[$i];
+ }
+ my $temp_file;
+ my $newfilename=$filename;
+ my $num=$i+1;
+ $newfilename =~s/\.tex$//;
+ $newfilename=sprintf("%s_%03d.tex",$newfilename, $num);
+ unless ($temp_file = Apache::File->new('>'.$newfilename)) {
+ $r->log_error("Couldn't open $newfilename for output $!");
+ return SERVER_ERROR;
+ }
+ print $temp_file $print_array[$i];
+ }
}
my $student_names='';
if ($#print_array>0) {
- for (my $i=0;$i<=$#print_array;$i++) {
- $student_names.=$student_names[$i].'_ENDPERSON_';
+ for (my $i=0;$i<=$#print_array;$i++) {
+ $student_names.=$student_names[$i].'_ENDPERSON_';
}
} else {
if ($#student_names>-1) {
- $student_names=$student_names[0].'_ENDPERSON_';
+ $student_names=$student_names[0].'_ENDPERSON_';
} else {
- my $fullname = &get_name($env{'user.name'},$env{'user.domain'});
- $student_names=join(':',$env{'user.name'},$env{'user.domain'},
- $env{'request.course.sec'},$fullname).
- '_ENDPERSON_'.'_END_';
+ my $fullname = &get_name($env{'user.name'},$env{'user.domain'});
+ $student_names=join(':',$env{'user.name'},$env{'user.domain'},
+ $env{'request.course.sec'},$fullname).
+ '_ENDPERSON_'.'_END_';
}
- }
+ }
+
+ # logic for now is too complex to trace if this has been defined
+ # yet.
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ &Apache::lonnet::appenv({'cgi.'.$identifier.'.file' => $filename,
+ 'cgi.'.$identifier.'.layout' => $laystyle,
+ 'cgi.'.$identifier.'.numcol' => $numberofcolumns,
+ 'cgi.'.$identifier.'.paper' => $papersize,
+ 'cgi.'.$identifier.'.selection' => $selectionmade,
+ 'cgi.'.$identifier.'.tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
+ 'cgi.'.$identifier.'.tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},
+ 'cgi.'.$identifier.'.role' => $perm{'pav'},
+ 'cgi.'.$identifier.'.numberoffiles' => $#print_array,
+ 'cgi.'.$identifier.'.studentnames' => $student_names,
+ 'cgi.'.$identifier.'.backref' => $URLback,});
+ &Apache::lonnet::appenv({"cgi.$identifier.user" => $env{'user.name'},
+ "cgi.$identifier.domain" => $env{'user.domain'},
+ "cgi.$identifier.courseid" => $cnum,
+ "cgi.$identifier.coursedom" => $cdom,
+ "cgi.$identifier.resources" => $resources_printed});
- # logic for now is too complex to trace if this has been defined
- # yet.
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- &Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename,
- 'cgi.'.$identifier.'.layout' => $laystyle,
- 'cgi.'.$identifier.'.numcol' => $numberofcolumns,
- 'cgi.'.$identifier.'.paper' => $papersize,
- 'cgi.'.$identifier.'.selection' => $selectionmade,
- 'cgi.'.$identifier.'.tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
- 'cgi.'.$identifier.'.tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},
- 'cgi.'.$identifier.'.role' => $perm{'pav'},
- 'cgi.'.$identifier.'.numberoffiles' => $#print_array,
- 'cgi.'.$identifier.'.studentnames' => $student_names,
- 'cgi.'.$identifier.'.backref' => $URLback,);
- &Apache::lonnet::appenv("cgi.$identifier.user" => $env{'user.name'},
- "cgi.$identifier.domain" => $env{'user.domain'},
- "cgi.$identifier.courseid" => $cnum,
- "cgi.$identifier.coursedom" => $cdom,
- "cgi.$identifier.resources" => $resources_printed);
my $end_page = &Apache::loncommon::end_page();
my $continue_text = &mt('Continue');
# If there's been an unrecoverable SSI error, report it to the user
@@ -2191,15 +2196,15 @@ ENDPART
&mt('You may be able to reprint the individual resources for which this error occurred, as the issue may be temporary.').
'
'.&mt('If the error persists, please contact the [_1] for assistance.',$helpurl).'
'. &mt('We apologize for the inconvenience.').'
'. - ''.&mt('Continue').''.$end_page); + ''.$continue_text.''.$end_page); } else { $r->print(<