--- loncom/interface/lonprintout.pm 2022/02/10 07:42:45 1.627.2.32 +++ loncom/interface/lonprintout.pm 2022/06/11 14:38:27 1.678 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.627.2.32 2022/02/10 07:42:45 raeburn Exp $ +# $Id: lonprintout.pm,v 1.678 2022/06/11 14:38:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -307,7 +307,7 @@ CHOOSE_STUDENTS # prompt_text - Text to use to prompt user. # resource_options - Resource tag options e.g. # "multichoice='1', toponly='1', addstatus='1', -# modallink='1'" +# modallink='1'" # that control the selection and appearance of the # resource selector. # variable - Name of the variable to hold the choice @@ -579,7 +579,6 @@ sub printable { # date for printing checks printstartdate param first, then, if not set, # opendate param, then, if not set, contentopen param. - sub get_print_dates { my $res = shift; my $partsref = $res->parts(); @@ -747,7 +746,7 @@ sub master_seq_to_person_seq { } my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain, - $code,$unhidden); + $code, $unhidden); my ($start,$finish); if ($map) { @@ -767,13 +766,13 @@ sub master_seq_to_person_seq { # Iterate on the resource..select the items that are randomly selected # and that are in the seq_has. Presumably the iterator will take care # of the random ordering part of the deal. + # my $curres; while ($curres = $iterator->next()) { # # Only process resources..that are not removed by randomout... # and are selected for printint as well. # - if (ref($curres) && ! $curres->randomout()) { my $currsymb = $curres->symb(); if (exists($seq_hash{$currsymb})) { @@ -848,7 +847,8 @@ sub set_font_size { if ($font_size ne '') { $text =~ s/\\begin\{document}/\\begin{document}{\\$font_size/; - $text =~ s/\\end\{document}/}\\end{document}/; + $text =~ s/\\end\{document}/}\\end{document}/; + } return $text; @@ -1060,12 +1060,12 @@ sub printf_style_subst { # %s - The section if it is supplied. # sub format_page_header { - my ($width, $format, $assignment, $course, $student) = @_; + my ($width, $format, $assignment, $course, $student, $section) = @_; $width = &recalcto_mm($width); # Get width in mm. - my $chars_per_line = int($width/2); # Character/textline. + my $chars_per_line = int($width/1.6); # Character/textline. # Default format? @@ -1081,38 +1081,34 @@ sub format_page_header { # - Allow the assignment to be 2 lines (wrapped). # - my $firstline = "$student $course"; - if (length($firstline) > $chars_per_line) { - my $lastchar = $chars_per_line - length($student) - 1; - if ($lastchar > 0) { - $course = substr($course, 0, $lastchar); - } else { # Nothing left of course: - $course = ''; - } - } - if (length($assignment) > $chars_per_line) { - $assignment = substr($assignment, 0, $chars_per_line); - } + - $format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}"; + my $name_length = int($chars_per_line *3 /4); + my $sec_length = int($chars_per_line / 5); - } else { - # An open question is how to handle long user formatted page headers... - # A possible future is to support e.g. %na so that the user can control - # the truncation of the elements that can appear in the header. - # - $format = &printf_style_subst("a", $format, $assignment); - $format = &printf_style_subst("c", $format, $course); - $format = &printf_style_subst("n", $format, $student); - - # If the user put %'s in the format string, they must be escaped - # to \% else LaTeX will think they are comments and terminate - # the line.. which is bad!!! + $format = "%$name_length".'n'; - } + if ($section) { + $format .= ' - Sec: '."%$sec_length".'s'; + } - return $format; + $format .= '\\\\%c \\\\ %a'; + + } + # An open question is how to handle long user formatted page headers... + # A possible future is to support e.g. %na so that the user can control + # the truncation of the elements that can appear in the header. + # + $format = &printf_style_subst("a", $format, $assignment); + $format = &printf_style_subst("c", $format, $course); + $format = &printf_style_subst("n", $format, $student); + $format = &printf_style_subst("s", $format, $section); + + + # If the user put %'s in the format string, they must be escaped + # to \% else LaTeX will think they are comments and terminate + # the line.. which is bad!!! # If the user has role author, $course and $assignment are empty so # there is '\\ \\ ' in the page header. That's cause a error in LaTeX @@ -1344,8 +1340,8 @@ sub latex_header_footer_remove { # necessity is determined by the problem_split param. # sub encapsulate_minipage { - my ($text) = @_; - if (!($env{'form.problem.split'} =~ /yes/i)) { + my ($text,$problem_split) = @_; + if (!($problem_split =~ /yes/i)) { $text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}'; } return $text; @@ -1849,6 +1845,8 @@ sub get_course { my $courseidinfo; if (defined($env{'request.course.id'})) { $courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); + my $sec = $env{'request.course.sec'}; + } return $courseidinfo; } @@ -1871,7 +1869,6 @@ sub page_format_transformation { my $name = &get_name(); my $courseidinfo = &get_course(); - if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } my $header_text = $parmhash{'print_header_format'}; $header_text = &format_page_header($textwidth, $header_text, $assignment, $courseidinfo, $name); @@ -2083,8 +2080,8 @@ sub unsupported { } if ($mode ne '') {$mode='\\'.$mode} my $result = &print_latex_header($mode); - if ($cleanURL=~m|^(/adm/wrapper/)?ext/|) { - $cleanURL=~s|^(/adm/wrapper/)?ext/|http://|; + if ($cleanURL=~m|^(/adm/wrapper)?/ext/|) { + $cleanURL=~s|^(/adm/wrapper)?/ext/|http://|; $cleanURL=~s|^http://https://|https://|; if ($shown eq $currentURL) { $shown = &Apache::lonxml::latex_special_symbols($cleanURL); @@ -2096,7 +2093,7 @@ sub unsupported { if ($shown eq $currentURL) { $result.=&Apache::lonxml::latex_special_symbols($currentURL); } else { - $result.=$shown; + $result.=$shown; } } $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}'; @@ -2168,7 +2165,7 @@ sub print_page_in_course { } elsif ($resource->ext()) { $result.=&latex_header_footer_remove(&unsupported($current_url,$mode,$resource->symb)); } elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { - # these resources go through the XML transformer: + # these resources go through the XML transformer: $result .= &Apache::lonxml::latex_special_symbols($resource->title()) . '\\\\'; my $urlp = &Apache::lonnet::clutter($resource_src); @@ -2182,7 +2179,7 @@ sub print_page_in_course { $form{'grade_target'} = 'tex'; $form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); - $form{'pdfFormFields'} = 'no'; # + $form{'pdfFormFields'} = $pdfFormFields; # $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; $form{'problem_split'}=$parmhash{'problem_stream_switch'}; @@ -2553,7 +2550,7 @@ sub print_construction_sequence { my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $body.=&path_to_problem($urlp,$LaTeXwidth); $body.='\vskip 1 mm '.$answer.'\end{document}'; - $body = &encapsulate_minipage($body); + $body = &encapsulate_minipage($body,$answerform{'problem_split'}); $texversion.=$body; } } @@ -2718,7 +2715,7 @@ ENDPART my %form; $form{'grade_target'} = 'tex'; $form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); - $form{'pdfFormFields'} = 'no'; + $form{'pdfFormFields'} = $pdfFormFields; # If form.showallfoils is set, then request all foils be shown: # privilege will be enforced both by not allowing the @@ -2857,9 +2854,10 @@ ENDPART $result = &print_latex_header() . $result; } # End construction space sequence. - } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard|ext\.tool)$/) { $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} + if ($currentURL=~/\/ext\.tool$/) {$currentURL=~s/^\/adm\/wrapper//;} $resources_printed .= $currentURL.':'; my $texversion = &ssi_with_retries($currentURL, $ssi_retry_count, %form); if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { @@ -3017,7 +3015,7 @@ ENDPART my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $body .= &path_to_problem ($urlp,$LaTeXwidth); $body .='\vskip 1 mm '.$answer; - $body = &encapsulate_minipage($body); + $body = &encapsulate_minipage($body,$answerform{'problem_split'}); $texversion .= $body; } else { $texversion=''; @@ -3041,7 +3039,6 @@ ENDPART if (($selectionmade == 4) and ($assignment ne $prevassignment)) { my $name = &get_name(); my $courseidinfo = &get_course(); - if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } $prevassignment=$assignment; my $header_text = $parmhash{'print_header_format'}; $header_text = &format_page_header($textwidth, $header_text, @@ -3056,9 +3053,10 @@ ENDPART } $result .= $texversion; $flag_latex_header_remove = 'YES'; - } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard|ext\.tool)$/) { $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} + if ($urlp=~/\/ext\.tool$/) {$urlp=~s/^\/adm\/wrapper//;} $resources_printed .= $urlp.':'; my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { @@ -3243,7 +3241,7 @@ ENDPART my @lines = &Apache::lonnet::get_scantronformat_file(); my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10); foreach my $line (@lines) { - chomp($line); + next if (($line =~ /^\#/) || ($line eq '')); my ($name,$type,$length,$bubbles_per_item) = (split(/:/,$line))[0,2,4,17]; if ($name eq $code_option) { @@ -3318,7 +3316,7 @@ ENDPART my $count=0; my $nohidemap; if ($perm{'pav'} && $perm{'vgr'}) { - $nohidemap = 1; + $nohidemap = 1; } foreach my $code (sort(@allcodes)) { my $file_num=int($count/$number_per_page); @@ -3460,7 +3458,7 @@ ENDPART } } if ($env{'request.enc'}) { - $url = &Apache::lonenc::encrypted($url); + $url = &Apache::lonenc::encrypted($url); } if ($url ne '') { my $symb = $helper->{VARS}{'symb'}; @@ -3663,8 +3661,6 @@ sub print_resources { my $assignment; my $courseidinfo = &get_course(); my $possprint = scalar(@{$master_seq}); - if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } - if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} foreach my $curresline (@{$master_seq}) { if (defined $page_breaks{$curresline}) { @@ -3732,7 +3728,7 @@ sub print_resources { my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $body .=&path_to_problem($res_url,$LaTeXwidth); $body .='\vskip 1 mm '.$ansrendered; - $body = &encapsulate_minipage($body); + $body = &encapsulate_minipage($body,$answerenv{'problem_split'}); $rendered = $header.$body; } } @@ -3748,7 +3744,7 @@ sub print_resources { $rendered =~ s/\\end\{document}//; } $current_output .= $rendered; - } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard|ext\.tool)$/) { if ($i == 1) { $syllabus_first = 1; } @@ -3789,7 +3785,7 @@ sub print_resources { if (($assignment ne $current_assignment) && ($assignment ne "")) { my $header_line = &format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, $assignment, $courseidinfo, - $fullname); + $fullname, $usersection); my $header_start = ($columns_in_format == 1) ? '\lhead' : '\fancyhead[LO]'; $header_line = $header_start.'{'.$header_line.'}'; @@ -3821,8 +3817,8 @@ sub print_resources { } elsif ($print_incomplete) { $message = &mt('No incomplete resources'); } - if ($message) { - $current_output = &encapsulate_minipage("\\vskip -10mm \n$message\n \\vskip 100 mm { }\n"); + if ($message) { + $current_output = &encapsulate_minipage("\\vskip -10mm \n$message\n \\vskip 100 mm { }\n",$moreenv->{'problem_split'}); } if ($remove_latex_header eq "NO") { $current_output = &print_latex_header() . $current_output; @@ -3836,13 +3832,13 @@ sub print_resources { } my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); my $header_line = - &format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, - $currentassignment, $courseidinfo, $fullname); + &format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, + $currentassignment, $courseidinfo, $fullname, $usersection); my $header_start = ($columns_in_format == 1) ? '\lhead' : '\fancyhead[LO]'; my $newheader = $header_start.'{'.$header_line.'}'; - if ($current_output=~/\\documentclass/) { $current_output =~ s/\\begin\{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$newheader$namepostfix}\\vskip 5 mm /; + } else { my $blankpages = '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; @@ -3851,6 +3847,7 @@ sub print_resources { ©right_line().' \newpage '.$blankpages.$end_of_student. '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'. $newheader.$namepostfix. '} \vskip 5 mm '.$current_output; + } # # Close the student bracketing. @@ -4082,7 +4079,6 @@ sub printHelper { } if ($env{'form.url'}) { $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'}); - } if ($helper->{VARS}->{'symb'} ne '') { $helper->{VARS}->{'symb'}= @@ -4130,7 +4126,7 @@ sub printHelper { ($course_open, $course_close) = &course_print_dates($res); ($map_open, $map_close) = &map_print_dates($res); } else { - $res_error = 1; + $res_error = 1; } } else { $res_error = 1; @@ -4525,6 +4521,7 @@ ALL_PROBLEMS my @lines = &Apache::lonnet::get_scantronformat_file(); my $codechoice=''; foreach my $line (@lines) { + next if (($line =~ /^\#/) || ($line eq '')); my ($name,$description,$code_type,$code_length)= (split(/:/,$line))[0,1,2,4]; if ($code_length > 0 && @@ -4778,9 +4775,9 @@ CHOOSE_FROM_ANY_SEQUENCE if ($noprintmsg) { $paramHash = Apache::lonhelper::getParamHash(); - $paramHash->{MESSAGE_TEXT} = + $paramHash->{MESSAGE_TEXT} = '

'.$noprintmsg.'

'; - Apache::lonhelper::message->new(); + Apache::lonhelper::message->new(); } } $paramHash = Apache::lonhelper::getParamHash(); @@ -5005,7 +5002,7 @@ FONT_SELECTION return "$helper->{VARS}->{'probstatus'}"; Homework Problem - Exam Problem + Bubblesheet Exam Problem Survey question ,choice computer="anonsurvey"Anonymous survey question @@ -5123,6 +5120,9 @@ sub render { my $PaperType=&mt('Paper type'); my $landscape=&mt('Landscape'); my $portrait=&mt('Portrait'); + my $pdfFormLabel=&mt('PDF Form Fields'); + my $with=&mt('with Form Fields'); + my $without=&mt('without Form Fields'); $result.='

'.&mt('Layout Options').'

' @@ -5131,6 +5131,7 @@ sub render { .''.$PageLayout.'' .''.$NumberOfColumns.'' .''.$PaperType.'' + .''.$pdfFormLabel.'' .&Apache::loncommon::end_data_table_header_row() .&Apache::loncommon::start_data_table_row() .'' @@ -5171,6 +5172,12 @@ sub render { $result .= < + + + HTML $result.=&Apache::loncommon::end_data_table_row() .&Apache::loncommon::end_data_table();