--- loncom/interface/lonprintout.pm 2009/07/23 10:42:41 1.557.2.4 +++ loncom/interface/lonprintout.pm 2009/07/03 16:13:13 1.558 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.557.2.4 2009/07/23 10:42:41 foxr Exp $ +# $Id: lonprintout.pm,v 1.558 2009/07/03 16:13:13 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -104,7 +104,7 @@ sub fetch_raw_resource { sub annotate { my ($symb) = @_; - my $annotation_text = &Apache::loncommon::get_annotation($symb, 1); + my $annotation_text = &Apache::admannotations::get_annotation($symb, 1); my $result = ""; @@ -197,7 +197,7 @@ sub include_pdf { # -# ssi_with_retries- Does the server side include of a resource. +# ssi_with_retries - Does the server side include of a resource. # if the ssi call returns an error we'll retry it up to # the number of times requested by the caller. # If we still have a proble, no text is appended to the @@ -230,10 +230,6 @@ sub include_pdf { sub ssi_with_retries { my ($resource, $retries, %form) = @_; - my $target = $form{'grade_target'}; - my $aom = $form{'answer_output_mode'}; - - my ($content, $response) = &Apache::loncommon::ssi_with_retries($resource, $retries, %form); if (!$response->is_success) { @@ -948,7 +944,6 @@ sub old_character_chart { $result =~ s/&(rdquo|#8221);/\'\'/g; - return $result; } @@ -1310,180 +1305,6 @@ sub unsupported { return $result; } -# -# Map from helper layout style to the book/album: -# -sub map_laystyle { - my ($laystyle) = @_; - if ($laystyle eq 'L') { - $laystyle='album'; - } else { - $laystyle='book'; - } - return $laystyle; -} - -sub print_page_in_course { - my ($helper, $rparmhash, $currentURL, $resources) = @_; - my %parmhash = %$rparmhash; - my @page_resources = @$resources; - my $mode = $helper->{'VARS'}->{'LATEX_TYPE'}; - my $symb = $helper->{'VARS'}->{'symb'}; - - - my $format_from_helper = $helper->{'VARS'}->{'FORMAT'}; - - - my @temporary_array=split /\|/,$format_from_helper; - my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array; - $laystyle = &map_laystyle($laystyle); - my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle, - $numberofcolumns); - my $LaTeXwidth=&recalcto_mm($textwidth); - - - if ($mode ne '') {$mode='\\'.$mode} - my $result.= &print_latex_header($mode); - if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { - $currentURL=~s|^(/adm/wrapper/)?ext/|http://|; - my $title=&Apache::lonnet::gettitle($symb); - $title = &Apache::lonxml::latex_special_symbols($title); - } else { - $result.=$currentURL; - } - $result .= '\\\\'; - - if ($helper->{'VARS'}->{'style_file'}=~/\w/) { - &Apache::lonnet::appenv({'construct.style' => - $helper->{'VARS'}->{'style_file'}}); - } elsif ($env{'construct.style'}) { - &Apache::lonnet::delenv('construct.style'); - } - - # First is the overall page description. This is then followed by the - # components of the page. Each of which must be printed independently. - - my $the_page = shift(@page_resources); - - foreach my $resource (@page_resources) { - my $resource_src = $resource->src(); # Essentially the URL of the resource. - $result .= $resource->title() . '\\\\'; - - # Recurse if a .page: - - if ($resource_src =~ /.page$/i) { - my $navmap = Apache::lonnavmaps::navmap->new(); - my @page_resources = $navmap->retrieveResources($resource_src); - $result .= &print_page_in_course($helper, $rparmhash, - $resource_src, \@page_resources); - } - # these resources go through the XML transformer: - - elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm\xhtml|xhtm)$/) { - my $urlp = &Apache::lonnet::clutter($resource_src); - my %form; - my %moreenv; - - &Apache::lonxml::remember_problem_counter(); - $moreenv{'request.filename'}=$urlp; - if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';} - - $form{'grade_target'} = 'tex'; - $form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); - $form{'pdfFormFiels'} = $pdfFormFields; # - $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; - - $form{'problem_split'}=$parmhash{'problem_stream_switch'}; - $form{'suppress_tries'}=$parmhash{'suppress_tries'}; - $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; - $form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'}; - $form{'print_annotations'}=$helper->{'VARS'}->{'PRINT_ANNOTATIONS'}; - if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') || - ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) { - $form{'problem_split'}='yes'; - } - my $rndseed = time; - if ($helper->{'VARS'}->{'curseed'}) { - $rndseed=$helper->{'VARS'}->{'curseed'}; - } - $form{'rndseed'}=$rndseed; - &Apache::lonnet::appenv(\%moreenv); - - &Apache::lonxml::clear_problem_counter(); - - my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); - - # There seems to be an extraneous \vskip 1mm \\\\ : - - $texversion =~ s/^\\vskip 1mm \\\\\\\\//; - - # current document with answers.. no need to encap in minipage - # since there's only one answer. - - if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || - ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { - my %answerform = %form; - - - $answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; - $answerform{'grade_target'}='answer'; - $answerform{'answer_output_mode'}='tex'; - $answerform{'rndseed'}=$rndseed; - if ($helper->{'VARS'}->{'probstatus'} eq 'exam') { - $answerform{'problemtype'}='exam'; - } - $resources_printed .= $urlp.':'; - my $answer=&ssi_with_retries($urlp,$ssi_retry_count, %answerform); - - if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { - $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; - } else { - $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - if ($helper->{'VARS'}->{'construction'} ne '1') { - my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); - $title = &Apache::lonxml::latex_special_symbols($title); - $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; - $texversion.=&path_to_problem($urlp,$LaTeXwidth); - } else { - $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; - my $URLpath=$urlp; - $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/; - $texversion.=&path_to_problem($URLpath,$LaTeXwidth); - } - $texversion.='\vskip 1 mm '.$answer.'\end{document}'; - } - - - - - - } - # Print annotations. - - - if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { - my $annotation .= &annotate($currentURL); - $texversion =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/; - } - - if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') { - $texversion=&IndexCreation($texversion,$currentURL); - } - if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') { - $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$currentURL| \\strut\\\\\\strut /; - - } - $result .= $texversion; - if ($currentURL=~m/\.page\s*$/) { - ($result,$numberofcolumns) = &page_cleanup($result); - } - } - } - - $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}'; - return $result; -} - # # List of recently generated print files @@ -1728,8 +1549,16 @@ sub output_data { ENDPART - - my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js); + # Breadcrumbs + #FIXME: Choose better/different breadcrumbs?!? Links? + my $brcrum = [{'href' => '', + 'text' => 'Helper'}, #FIXME: Different origin possible than print out helper? + {'href' => '', + 'text' => 'Preparing Printout'}]; + + my $start_page = &Apache::loncommon::start_page('Preparing Printout', + $js, + {'bread_crumbs' => $brcrum,}); my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); $r->print($start_page."\n

\n$msg\n

\n"); @@ -1751,8 +1580,11 @@ ENDPART my $number_of_columns = 1; #used only for pages to determine the width of the cell my @temporary_array=split /\|/,$format_from_helper; my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array; - - $laystyle = &map_laystyle($laystyle); + if ($laystyle eq 'L') { + $laystyle='album'; + } else { + $laystyle='book'; + } my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns); my $assignment = $env{'form.assignment'}; my $LaTeXwidth=&recalcto_mm($textwidth); @@ -1901,8 +1733,6 @@ ENDPART } elsif ($cleanURL!~m|^/adm/| && $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') { #printing content of sequence from the construction space - - $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; # $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); $result .= &print_construction_sequence($currentURL, $helper, %form, @@ -1938,18 +1768,7 @@ ENDPART } elsif ($cleanURL =~ /\.pdf$/i) { $result .= &include_pdf($cleanURL); $result .= '\end{document}'; - } elsif ($cleanURL =~ /\.page$/i) { # Print page in non construction space contexts. - - # Determine the set of resources in the map of the page: - - my $navmap = Apache::lonnavmaps::navmap->new(); - my @page_resources = $navmap->retrieveResources($cleanURL); - $result .= &print_page_in_course($helper, $rparmhash, - $cleanURL, \@page_resources); - - } else { - &Apache::lonnet::logthis("Unsupported type handler"); $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, $helper->{'VARS'}->{'symb'}); } @@ -2020,7 +1839,6 @@ ENDPART &Apache::lonxml::remember_problem_counter(); $texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); if ($urlp=~/\.page$/) { - ($texversion,my $number_of_columns_page) = &page_cleanup($texversion); if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} $texversion =~ s/\\end{document}\d*/\\end{document}/; @@ -2609,6 +2427,7 @@ sub print_resources { if ($res_url!~m|^ext/| && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { $printed .= $curresline.':'; + &Apache::lonxml::remember_problem_counter(); my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); @@ -3375,6 +3194,7 @@ CHOOSE_ANON2 )) && $helper->{VARS}->{'assignment'} eq "" ) { + my $pretty_dir = &Apache::lonnet::hreflocation($subdir); push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from current subdirectory [_3]','','',''.$pretty_dir.'','',''), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; my $xmlfrag = <