--- loncom/interface/lonprintout.pm 2013/06/04 23:12:09 1.633 +++ loncom/interface/lonprintout.pm 2014/02/19 02:12:57 1.640 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.633 2013/06/04 23:12:09 raeburn Exp $ +# $Id: lonprintout.pm,v 1.640 2014/02/19 02:12:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,7 +27,6 @@ # package Apache::lonprintout; use strict; -use POSIX; use Apache::Constants qw(:common :http); use Apache::lonxml; use Apache::lonnet; @@ -47,7 +46,6 @@ use File::Basename; use HTTP::Response; use LONCAPA::map(); -use POSIX qw(ctime); use Apache::lonlocal; use Carp; use LONCAPA; @@ -494,7 +492,7 @@ RESOURCE_SELECTOR # # @return ($open, $close) # -# @note If open/close dates are not defined they will be retunred as undef +# @note If open/close dates are not defined they will be returned as undef # @note It is possible for there to be no overlap in which case -1,-1 # will be returned. # @note The algorithm used is to take the latest open date and the earliest end date. @@ -524,7 +522,7 @@ sub compute_open_window { # If no overlap...both are -1 as promised. - if (defined($earliest_close) && defined($latest_open) + if (($earliest_close ne '') && ($latest_open ne '') && ($earliest_close < $latest_open)) { $latest_open = -1; $earliest_close = -1; @@ -572,11 +570,13 @@ sub printable { # # @return (opendate, closedate) # -# @note If open/close dates are not defined they will be retunred as undef +# @note If open/close dates are not defined they will be returned as undef # @note It is possible for there to be no overlap in which case -1,-1 # will be returned. # @note The algorithm used is to take the latest open date and the earliest end date. -# +# For consistency with &printable() in lonnavmaps.pm determination of start +# 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; @@ -595,7 +595,18 @@ sub get_print_dates { foreach my $part (@parts) { my $partopen = $res->parmval('printstartdate', $part); my $partclose = $res->parmval('printenddate', $part); - + if (!$partopen) { + $partopen = $res->parmval('opendate',$part); + } + if (!$partopen) { + $partopen = $res->parmval('contentopen',$part); + } + if ($partopen) { + push(@open_dates, $partopen); + } + if ($partclose) { + push(@close_dates, $partclose); + } push(@open_dates, $partopen); push(@close_dates, $partclose); } @@ -603,13 +614,6 @@ sub get_print_dates { ($open_date, $close_date) = &compute_open_window(\@open_dates, \@close_dates); - if ($open_date) { - $open_date = POSIX::strftime('%D', localtime($open_date)); - } - if ($close_date) { - $close_date = POSIX::strftime('%D', localtime($close_date)); - } - return ($open_date, $close_date); } @@ -3608,6 +3612,7 @@ sub print_resources { # my $syllabus_first = 0; + my $assessment_first = 0; my $current_assignment = ""; my $assignment; my $courseidinfo = &get_course(); @@ -3629,7 +3634,11 @@ sub print_resources { if ($print_incomplete && !&incomplete($username, $userdomain, $res_url)) { next; } + if ((!$actually_printed) && ($curresline =~ m/$LONCAPA::assess_re/)) { + $assessment_first = 1; + } $actually_printed++; # we're going to print one. + if (&Apache::lonnet::allowed('bre',$res_url)) { if ($res_url!~m|^ext/| && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { @@ -3762,31 +3771,27 @@ sub print_resources { if ($syllabus_first) { $current_output =~ s/\\\\ Last updated:/Last updated:/ } - if (0) { + my $newheader; + unless (($assessment_first) && ($actually_printed > 1)) { 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, $usersection); my $header_start = ($columns_in_format == 1) ? '\lhead' : '\fancyhead[LO]'; - $header_line = $header_start.'{'.$header_line.'}'; + $newheader = $header_start.'{'.$header_line.'}'; } if ($current_output=~/\\documentclass/) { -# $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; - $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$namepostfix}\\vskip 5 mm /; + $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'}; -# $current_output = '\strut\vspace*{-6 mm}\\newline'. -# ©right_line().' \newpage '.$blankpages.$end_of_student. -# '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'. -# $header_line.$namepostfix. '} \vskip 5 mm '.$current_output; $current_output = '\strut\vspace*{-6 mm}\\newline'. ©right_line().' \newpage '.$blankpages.$end_of_student. - '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent' - .$namepostfix. '} \vskip 5 mm '.$current_output; + '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'. + $newheader.$namepostfix. '} \vskip 5 mm '.$current_output; } # @@ -4055,7 +4060,7 @@ sub printHelper { &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); my $navmap = Apache::lonnavmaps::navmap->new(); my $res = $navmap->getBySymb($symb); - $res_printable = $res->resprintable() | $userCanPrint; #printability in course context + $res_printable = $res->resprintable() || $userCanPrint; #printability in course context ($res_printstartdate, $res_printenddate) = &get_print_dates($res); ($course_open, $course_close) = &course_print_dates($res); ($map_open, $map_close) = &map_print_dates($res); @@ -4135,13 +4140,13 @@ sub printHelper { my $start_new_option; if ($perm{'pav'}) { $start_new_option = - "