--- loncom/interface/lonprintout.pm 2016/08/10 00:56:37 1.627.2.17 +++ loncom/interface/lonprintout.pm 2017/01/30 19:45:05 1.657 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.627.2.17 2016/08/10 00:56:37 raeburn Exp $ +# $Id: lonprintout.pm,v 1.657 2017/01/30 19:45:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -578,7 +578,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(); @@ -746,7 +745,7 @@ sub master_seq_to_person_seq { } my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain, - $code,$unhidden); + $code, $unhidden); my ($start,$finish); if ($map) { @@ -766,13 +765,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})) { @@ -1059,12 +1058,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? @@ -1080,38 +1079,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 @@ -1239,7 +1234,6 @@ sub is_code_valid { my ($code_type, $code_length) = ('letter', 6); # defaults. my @lines = &Apache::grades::get_scantronformat_file(); foreach my $line (@lines) { - next if (($line =~ /^\#/) || ($line eq '')); my ($name, $type, $length) = (split(/:/, $line))[0,2,4]; if($name eq $code_option) { $code_length = $length; @@ -1848,6 +1842,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; } @@ -1870,7 +1866,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); @@ -1981,8 +1976,8 @@ sub latex_corrections { if ($result =~ m/&(\w+|#\d+);/) { $result = &character_chart($result); } - $result =~ s/(\\end{tabular})\s*\\vskip 0 mm/$1/g; - $result =~ s/(\\begin{enumerate})\s*\\noindent/$1/g; + $result =~ s/(\\end\{tabular})\s*\\vskip 0 mm/$1/g; + $result =~ s/(\\begin\{enumerate})\s*\\noindent/$1/g; return $result; } @@ -2177,7 +2172,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'}; @@ -2591,7 +2586,7 @@ sub print_construction_sequence { $result .= $texversion; } } - if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} + if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin\{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} return $result; } @@ -2713,7 +2708,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 @@ -2748,7 +2743,7 @@ ENDPART $cleanURL=$currentURL; } $selectionmade = 1; - + if ($cleanURL!~m|^/adm/| && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { my $rndseed=time; @@ -2961,6 +2956,7 @@ ENDPART my $texversion=''; if ($urlp!~m|^/adm/| && $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + my $extension = $1; $resources_printed .= $urlp.':'; &Apache::lonxml::remember_problem_counter(); if ($flag_latex_header_remove eq 'NO') { @@ -2969,7 +2965,7 @@ ENDPART (($i==0) && (($urlp=~/\.page$/) || ($print_type eq 'map_problems_in_page') || - ($print_type eq 'map_resources_in_page')))) { + (($print_type eq 'map_resources_in_page') && ($extension !~ /^x?html?$/))))) { $flag_latex_header_remove = 'YES'; } } @@ -3036,7 +3032,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, @@ -3321,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); @@ -3402,7 +3397,7 @@ ENDPART #this chunk is responsible for printing the path to problem my $newurlp=&path_to_problem($urlp,$LaTeXwidth); - $texversion =~ s/(\\begin\{minipage}{\\textwidth})/$1 $newurlp/; + $texversion =~ s/(\\begin\{minipage}\{\\textwidth})/$1 $newurlp/; if ($flag_latex_header_remove ne 'NO') { $texversion = &latex_header_footer_remove($texversion); } else { @@ -3453,7 +3448,11 @@ ENDPART $URLback=$helper->{'VARS'}->{'filename'}; } elsif ($helper->{VARS}{'symb'}) { my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); - $URLback = &Apache::lonnet::clutter($url); + $url = &Apache::lonnet::clutter($url); + if ($env{'request.enc'}) { + $url = &Apache::lonenc::encrypted($url); + } + $URLback = $url.($url =~ /\?/) ? '&':'?'.'symb='.$helper->{VARS}{'symb'}; } # # Final adjustment of the font size: @@ -3537,7 +3536,7 @@ ENDPART 'cgi.'.$identifier.'.role' => $perm{'pav'}, 'cgi.'.$identifier.'.numberoffiles' => $#print_array, 'cgi.'.$identifier.'.studentnames' => $student_names, - 'cgi.'.$identifier.'.backref' => $URLback,}); + 'cgi.'.$identifier.'.backref' => &escape($URLback),}); &Apache::lonnet::appenv({"cgi.$identifier.user" => $env{'user.name'}, "cgi.$identifier.domain" => $env{'user.domain'}, "cgi.$identifier.courseid" => $cnum, @@ -3637,8 +3636,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}) { @@ -3763,7 +3760,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.'}'; @@ -3795,8 +3792,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"); } if ($remove_latex_header eq "NO") { $current_output = &print_latex_header() . $current_output; @@ -3810,13 +3807,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'}; @@ -3825,6 +3822,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. @@ -4486,6 +4484,7 @@ ALL_PROBLEMS my @lines = &Apache::grades::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 && @@ -4720,9 +4719,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(); @@ -4947,7 +4946,7 @@ FONT_SELECTION return "$helper->{VARS}->{'probstatus'}"; Homework Problem - Exam Problem + Bubblesheet Exam Problem Survey question ,choice computer="anonsurvey"Anonymous survey question @@ -5065,6 +5064,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').'

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