--- loncom/interface/lonprintout.pm 2009/11/30 11:03:07 1.566 +++ loncom/interface/lonprintout.pm 2010/12/05 17:25:10 1.568.4.3 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.566 2009/11/30 11:03:07 foxr Exp $ +# $Id: lonprintout.pm,v 1.568.4.3 2010/12/05 17:25:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1890,7 +1890,7 @@ sub print_construction_sequence { } sub output_data { - my ($r,$helper,$rparmhash) = @_; + my ($r,$helper,$rparmhash,$is_custom) = @_; my %parmhash = %$rparmhash; $ssi_error = 0; # This will be set nonzero by failing ssi's. $resources_printed = ''; @@ -1931,6 +1931,11 @@ ENDPART {'href' => '', 'text' => 'Preparing Printout'}]; + if ($is_custom) { + $brcrum = [{'href' => '', + 'text' => 'Preparing Printout'}]; + } + my $start_page = &Apache::loncommon::start_page('Preparing Printout', $js, {'bread_crumbs' => $brcrum,}); @@ -1992,7 +1997,6 @@ ENDPART &Apache::lonnet::delenv('construct.style'); } - if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { #-- single document - problem, page, html, xml, ... my ($currentURL,$cleanURL); @@ -2119,8 +2123,7 @@ ENDPART $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} $resources_printed .= $currentURL.':'; - my $texversion = &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - $texversion .= &ssi_with_retries($currentURL, $ssi_retry_count, %form); + my $texversion = &ssi_with_retries($currentURL, $ssi_retry_count, %form); if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { my $annotation = &annotate($currentURL); $texversion =~ s/(\\end{document})/$annotation$1/; @@ -2153,7 +2156,6 @@ ENDPART } else { - &Apache::lonnet::logthis("Unsupported type handler"); $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, $helper->{'VARS'}->{'symb'}); } @@ -2303,8 +2305,7 @@ ENDPART $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} $resources_printed .= $urlp.':'; - my $texversion = &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - $texversion .= &ssi_with_retries($urlp, $ssi_retry_count, %form); + my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { my $annotation = &annotate($urlp); $texversion =~ s/(\\end{document)/$annotation$1/; @@ -2808,7 +2809,7 @@ sub print_resources { # so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the # postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself. # - + my $syllabus_first = 0; foreach my $curresline (@{$master_seq}) { if (defined $page_breaks{$curresline}) { if($i != 0) { @@ -2867,6 +2868,9 @@ sub print_resources { } $current_output .= $rendered; } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + if ($i == 1) { + $syllabus_first = 1; + } $printed .= $curresline.':'; my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { @@ -2911,8 +2915,11 @@ sub print_resources { my $header_start = ($columns_in_format == 1) ? '\lhead' : '\fancyhead[LO]'; $header_line = $header_start.'{'.$header_line.'}'; - if ($current_output=~/\\documentclass/) { + if ($current_output=~/\\documentclass/ && (!$syllabus_first)) { $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; + } elsif ($syllabus_first) { + + $current_output =~ s/\\\\ Last updated:/Last updated:/ } else { my $blankpages = '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; @@ -2935,17 +2942,112 @@ sub handler { &init_perm(); + my ($helper,$is_custom); + if ((&Apache::loncommon::needs_gci_custom()) && + ($env{'request.role.domain'} =~ /^\w+citest$/)) { + if ($r->header_only) { + if ($env{'browser.mathml'}) { + &Apache::loncommon::content_type($r,'text/xml'); + } else { + &Apache::loncommon::content_type($r,'text/html'); + } + $r->send_http_header; + return OK; + } + # Send header, nocache + if ($env{'browser.mathml'}) { + &Apache::loncommon::content_type($r,'text/xml'); + } else { + &Apache::loncommon::content_type($r,'text/html'); + } + &Apache::loncommon::no_cache($r); + $r->send_http_header; + $r->rflush(); - - my $helper = printHelper($r); - if (!ref($helper)) { - return $helper; + my ($navmap_error,$resources,@master_seq); + my $navmap = Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + my $brcrum = [{'href' => '', + 'text' => 'Preparing Printout'}]; + + my $start_page = + &Apache::loncommon::start_page('Preparing Printout','', + {'bread_crumbs' => $brcrum,}); + my $endpage = &Apache::loncommon::end_page(); + + my $navmap_error = ''.&mt('An error occurred retrieving information about the course.').'
'.&mt('It is recommended that you re-select the concept test by clicking on the "Review Questions" tab and then clicking on the "Manage Tests" tab again.').'
'; + $r->print($start_page.$navmap_error.$endpage); + return OK; + } else { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $sequence = &Apache::loncommon::get_citest_map($cdom); + my @allres; + if ($sequence) { + @allres=$navmap->retrieveResources('/uploaded/'.$cdom.'/'.$cnum.'/'.$sequence); + foreach my $resource (@allres) { + next if ($resource->is_map()); + my $symb = $resource->symb(); + push(@master_seq,$symb); + } + $resources = join('|||',@master_seq); + my ($sequence,$middle_thingy,$urlp) = + &Apache::lonnet::decode_symb($master_seq[0]); + + my $assignment = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); + + $helper = { + VARS => { + ANON_CODE_STORAGE_NAME => '', + ANSWER_TYPE => 'yes', + CODE_OPTION => '', + EMPTY_PAGES => '', + FINISHPAGE => '', + FORMAT => 'P|1|letter|no', + LATEX_TYPE => 'batchmode', + NUMBER_TO_PRINT_TOTAL => '', + PRINT_ANNOTATIONS => 'no', + PRINT_DISCUSSIONS => 'no', + PRINT_TYPE => 'map_problems', + RESOURCES => $resources, + REUSE_OLD_CODES => '', + SEQUENCE => '', + SINGLE_CODE => '', + SPLIT_PDFS => '', + STUDENTS => '', + TABLE_CONTENTS => 'no', + TABLE_INDEX => 'no', + assignment => $assignment, + construction => '', + curseed => '', + filename => '', + fontsize => 'normalsize', + pagesize => '', + 'pagesize.height' => '9.8', + 'pagesize.heightunit' => 'in', + 'pagesize.lmargin' => '-0.57', + 'pagesize.lmarginunit' => 'in', + 'pagesize.width' => '7.1', + 'pagesize.widthunit' => 'in', + postdata => $urlp, + probstatus => '', + showallfoils => '', + student_sort => '', + style_file => '', + symb => $master_seq[0], + } + }; + $env{'form.assignment'} = $assignment; + $is_custom = 1; + } + } else { + $helper = printHelper($r); + if (!ref($helper)) { + return $helper; + } } - %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'}); - - # If a figure conversion queue file exists for this user.domain @@ -2954,13 +3056,13 @@ sub handler { my $conversion_queuefile = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat"; if(-e $conversion_queuefile) { - unlink $conversion_queuefile; + unlink $conversion_queuefile; } - - &output_data($r,$helper,\%parmhash); + + &output_data($r,$helper,\%parmhash,$is_custom); return OK; -} +} use Apache::lonhelper; @@ -3378,7 +3480,7 @@ ALL_PROBLEMS 'multichoice="1" addstatus="1" closeallpages="1"', 'RESOURCES', 'PRINT_FORMATTING', - '', + $map, $isProblem, '', $symbFilter, $start_new_option); $resource_selector .= <