--- loncom/interface/lonprintout.pm 2008/02/26 10:46:14 1.515 +++ loncom/interface/lonprintout.pm 2008/03/23 19:48:49 1.522 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.515 2008/02/26 10:46:14 foxr Exp $ +# $Id: lonprintout.pm,v 1.522 2008/03/23 19:48:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -38,6 +38,7 @@ use Apache::edit; use Apache::File(); use Apache::lonnavmaps; use Apache::admannotations; +use Apache::lonenc; use HTTP::Response; use LONCAPA::map(); @@ -144,30 +145,17 @@ sub ssi_with_retries { my ($resource, $retries, %form) = @_; - my $ok = 0; # True if we got a good response. - my $content; - my $response; - - # Try to get the ssi done. within the retries count: - - do { - ($content, $response) = &Apache::lonnet::ssi($resource, %form); - $ok = $response->is_success; - $retries--; - } while (!$ok && ($retries > 0)); - - # Two cases: ok is true we have valid data, if not, retries have been exhausted - # if ok is true, $response->content is what we want to return.. otherwise - # set the error information: - - if ($ok) { - return $content; - } else { + my ($content, $response) = &Apache::loncommon::ssi_with_retries($resource, $retries, %form); + if (!$response->is_success) { $ssi_error = 1; $ssi_last_error_resource = $resource; - $ssi_last_error = $response->code." ". $response->message; - return ''; # Nothing we can add to the printout that makes sense. + $ssi_last_error = $response->code . " " . $response->message; + + &Apache::lonnet::logthis("Error in SSI resource: $resource Error: $ssi_last_error"); } + + return $content; + } # @@ -1139,6 +1127,7 @@ sub print_latex_header { '\usepackage[dvips]{graphicx}\usepackage{epsfig}'."\n". '\usepackage{wrapfig}'. '\usepackage{picins}\usepackage{calc}'."\n". + '\usepackage[utf8]{inputenc}'."\n". '\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". @@ -1485,8 +1474,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'); } @@ -1529,7 +1518,7 @@ ENDPART $rndseed=$helper->{'VARS'}->{'curseed'}; } $form{'rndseed'}=$rndseed; - &Apache::lonnet::appenv(%moreenv); + &Apache::lonnet::appenv(\%moreenv); &Apache::lonxml::clear_problem_counter(); @@ -1677,6 +1666,9 @@ ENDPART my $pbreakresources = keys %page_breaks; for (my $i=0;$i<=$#master_seq;$i++) { + &Apache::lonenc::reset_enc(); + + # Note due to document structure, not allowed to put \newpage # prior to the first resource @@ -1685,11 +1677,13 @@ ENDPART $result.="\\newpage\n"; } } - my ($sequence,undef,$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;} if ($i==0) {$prevassignment=$assignment;} my $texversion=''; @@ -1996,6 +1990,9 @@ ENDPART $rndseed=$helper->{'VARS'}->{'curseed'}; } for (my $i=0;$i<=$#list_of_files;$i++) { + + &Apache::lonenc::reset_enc(); + my $urlp = $list_of_files[$i]; $urlp=~s|//|/|; if ($urlp=~/\//) { @@ -2095,27 +2092,24 @@ ENDPART # if ($ssi_error) { + + my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk'); my $end_page = &Apache::loncommon::end_page(); - $r->print(<print('
-

An unrecoverable error occured:

+

'.&mt('An unrecoverable error occured:').'

- I was not able to render one of the print resources ($ssi_last_error_resource) -due to an unrecoverable error communicating with a server: -
-$ssi_last_error; + '.&mt('One of the resources ([_1]) you chose to print could not be rendered due to an unrecoverable error when communicating with a server:',$ssi_last_error_resource).'
+'.$ssi_last_error.'

-

-I recommend that you try printing again later as this may mean the server was just -temporarily unavailable, or is down for maintenance. If this error persists, then -please contact your LonCAPA support folks for assistance and diagnosis. -
-
-We apologize for the inconvenience. -

-$end_page -ERROR_END +

'. +&mt('It is recommended that you try printing again later, as this error may mean the server was just temporarily unavailable, or is down for maintenance.').'
'. +&mt('If the error persists, please contact the [_1] for assistance.',$helpurl). +'

'. +&mt('We apologize for the inconvenience.'). +'

'. +$end_page); } else { #-- writing .tex file in prtspool @@ -2180,7 +2174,7 @@ ERROR_END # 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, + &Apache::lonnet::appenv({'cgi.'.$identifier.'.file' => $filename, 'cgi.'.$identifier.'.layout' => $laystyle, 'cgi.'.$identifier.'.numcol' => $numberofcolumns, 'cgi.'.$identifier.'.paper' => $papersize, @@ -2190,12 +2184,12 @@ ERROR_END '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.'.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); + "cgi.$identifier.resources" => $resources_printed}); my $end_page = &Apache::loncommon::end_page(); $r->print(<declareVar("showallfoils"); $helper->declareVar("STUDENTS"); + + + + # The page breaks can get loaded initially from the course environment: # But we only do this in the initial state so that they are allowed to change. # @@ -3220,19 +3218,24 @@ RNDSEED addMessage("Problem Type:"); - $paramHash = &Apache::lonhelper::getParamHash(); - $paramHash->{'variable'} = 'probstatus'; # Already declared: # # Initial value from construction space: # if (!$helper->{VARS}->{'probstatus'} && $env{'form.problemtype'}) { $helper->{VARS}->{'probstatus'} = $env{'form.problemtype'}; # initial value } - $paramHash->{CHOICES} = [ - ['Homework problem', 'problem'], - ['Exam Problem', 'exam'], - ['Survey question', 'survey']]; - Apache::lonhelper::dropdown->new(); + $xmlfrag = << "PROBTYPE"; + + + return "$helper->{VARS}->{'probstatus'}"; + + Homework Problem + Exam Problem + Survey question + +PROBTYPE + &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); + addMessage(""); }