--- loncom/interface/lonprintout.pm 2023/01/17 23:02:49 1.627.2.32.2.4 +++ loncom/interface/lonprintout.pm 2023/02/08 15:15:24 1.687 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.627.2.32.2.4 2023/01/17 23:02:49 raeburn Exp $ +# $Id: lonprintout.pm,v 1.687 2023/02/08 15:15:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -309,7 +309,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 @@ -452,7 +452,7 @@ sub generate_common_choosers { my $randomly_ordered_warning = &get_randomly_ordered_warning($helper, $map); - # code for a few states used for printout launched from both + # code for a few states used for printout launched from both # /adm/navmpas and from a resource by a privileged user: # - To allow resources to be selected for printing. # - To determine pagination between assignments. @@ -711,7 +711,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(); @@ -879,7 +878,7 @@ sub master_seq_to_person_seq { } my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain, - $code,$unhidden); + $code, $unhidden); my ($start,$finish); if ($map) { @@ -899,13 +898,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})) { @@ -980,7 +979,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; @@ -1192,12 +1192,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? @@ -1213,38 +1213,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 @@ -1477,7 +1473,7 @@ sub latex_header_footer_remove { # sub encapsulate_minipage { my ($text,$problem_split) = @_; - if (!($problem.split =~ /yes/i)) { + if (!($problem_split =~ /yes/i)) { $text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}'; } return $text; @@ -1981,6 +1977,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; } @@ -2003,7 +2001,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); @@ -2215,8 +2212,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); @@ -2228,7 +2225,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}'; @@ -2300,7 +2297,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); @@ -2314,7 +2311,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'}; @@ -2850,7 +2847,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 @@ -2989,9 +2986,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') { @@ -3173,7 +3171,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, @@ -3188,9 +3185,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') { @@ -3306,8 +3304,12 @@ ENDPART my $map; if ($helper->{VARS}->{'symb'}) { - ($map, my $id, my $resource) = - &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); + unless ((($print_type eq 'all_problems_students') || + ($print_type eq 'incomplete_problems_selpeople_course')) && + $perm{'pfo'}) { + ($map, my $id, my $resource) = + &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'}); + } } #loop over students @@ -3456,7 +3458,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); @@ -3598,7 +3600,7 @@ ENDPART } } if ($env{'request.enc'}) { - $url = &Apache::lonenc::encrypted($url); + $url = &Apache::lonenc::encrypted($url); } if ($url ne '') { my $symb = $helper->{VARS}{'symb'}; @@ -3804,8 +3806,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}) { @@ -3889,7 +3889,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; } @@ -3930,7 +3930,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.'}'; @@ -3962,8 +3962,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",$moreenv->{'problem_split'}); + 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; @@ -3977,13 +3977,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'}; @@ -3992,6 +3992,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. @@ -4296,7 +4297,7 @@ sub printHelper { if (ref($navmap)) { my $res; if ($symb ne '') { - $res = $navmap->getBySymb($symb); + $res = $navmap->getBySymb($symb); } elsif ($map ne '') { $res = $navmap->getResourceByUrl($map); } @@ -4306,7 +4307,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; @@ -4651,7 +4652,7 @@ ALL_PROBLEMS # with one state, and use REGEXPs at inclusion time to set state names # and next states for better mix and match capability # - + my $resource_selector=< $randomly_ordered_warning @@ -4749,7 +4750,7 @@ CHOOSE_ANON2 # FIXME: That RE should come from a library somewhere. if (($perm{'pav'} - && ($subdir ne '') + && ($subdir ne '') && $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/' && (defined($helper->{'VARS'}->{'construction'}) || @@ -4959,9 +4960,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(); @@ -5186,7 +5187,7 @@ FONT_SELECTION return "$helper->{VARS}->{'probstatus'}"; Homework Problem - Exam Problem + Bubblesheet Exam Problem Survey question ,choice computer="anonsurvey"Anonymous survey question @@ -5304,6 +5305,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').'

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