--- loncom/interface/lonprintout.pm 2019/02/21 20:40:12 1.627.2.27 +++ loncom/interface/lonprintout.pm 2018/01/15 00:51:42 1.661 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.627.2.27 2019/02/21 20:40:12 raeburn Exp $ +# $Id: lonprintout.pm,v 1.661 2018/01/15 00:51:42 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,8 +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 +1059,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 +1080,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 @@ -1240,7 +1235,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; @@ -1849,6 +1843,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 +1867,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); @@ -1962,7 +1957,7 @@ sub latex_corrections { $result =~ s/(\\end\{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/; } $result =~ s/\$number_of_columns/$number_of_columns/g; - $result =~ s/(\\end\{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]\{\\hrulefill})/$2$1/g; + $result =~ s/(\\end\{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; $result =~ s/(\\end\{longtable}\s*)\\strut\\newline/$1/g; #-- LaTeX corrections my $first_comment = index($result,'