--- loncom/interface/lonprintout.pm 2014/01/20 06:09:58 1.627.2.9
+++ loncom/interface/lonprintout.pm 2013/01/04 01:19:57 1.629
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.627.2.9 2014/01/20 06:09:58 raeburn Exp $
+# $Id: lonprintout.pm,v 1.629 2013/01/04 01:19:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,6 +27,7 @@
#
package Apache::lonprintout;
use strict;
+use POSIX;
use Apache::Constants qw(:common :http);
use Apache::lonxml;
use Apache::lonnet;
@@ -46,6 +47,7 @@ use File::Basename;
use HTTP::Response;
use LONCAPA::map();
+use POSIX qw(ctime);
use Apache::lonlocal;
use Carp;
use LONCAPA;
@@ -492,7 +494,7 @@ RESOURCE_SELECTOR
#
# @return ($open, $close)
#
-# @note If open/close dates are not defined they will be returned as undef
+# @note If open/close dates are not defined they will be retunred 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.
@@ -522,7 +524,7 @@ sub compute_open_window {
# If no overlap...both are -1 as promised.
- if (($earliest_close ne '') && ($latest_open ne '')
+ if (defined($earliest_close) && defined($latest_open)
&& ($earliest_close < $latest_open)) {
$latest_open = -1;
$earliest_close = -1;
@@ -570,14 +572,11 @@ sub printable {
#
# @return (opendate, closedate)
#
-# @note If open/close dates are not defined they will be returned as undef
+# @note If open/close dates are not defined they will be retunred 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;
@@ -596,18 +595,7 @@ 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);
}
@@ -615,6 +603,13 @@ 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);
}
@@ -725,7 +720,7 @@ sub incomplete {
# print_resources.
#
sub master_seq_to_person_seq {
- my ($map, $seq, $who, $code, $nohidemap) = @_;
+ my ($map, $seq, $who, $code) = @_;
my ($username, $userdomain, $usersection) = split(/:/, $who);
@@ -736,14 +731,9 @@ sub master_seq_to_person_seq {
my %seq_hash = map {$_ => 1} @$seq;
my @output_seq;
-
- my $unhidden;
- if ($perm{'pav'} && $perm{'vgr'} && $nohidemap) {
- $unhidden = &Apache::lonnet::clutter($map);
- }
my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain,
- $code,$unhidden);
+ $code);
my ($start,$finish);
if ($map) {
@@ -763,6 +753,7 @@ 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()) {
#
@@ -1056,12 +1047,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?
@@ -1077,44 +1068,40 @@ 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
if($format =~ /\\\\\s\\\\\s/) {
#TODO find sensible caption for page header
- my $testPrintout = '\\\\'.&mt('Authoring Space').' \\\\'.&mt('Test-Printout ');
+ my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');
$format =~ s/\\\\\s\\\\\s/$testPrintout/;
}
#
@@ -1236,7 +1223,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;
@@ -1845,6 +1831,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;
}
@@ -1867,7 +1855,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);
@@ -2174,7 +2161,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'};
@@ -2227,7 +2214,7 @@ sub print_page_in_course {
$texversion.=&path_to_problem($urlp,$LaTeXwidth);
} else {
$texversion.='\vskip 0 mm \noindent\textbf{'.
- &mt("Printing from Authoring Space: No Title").'}\vskip 0 mm ';
+ &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';
$texversion.=&path_to_problem($urlp,$LaTeXwidth);
}
$texversion.='\vskip 1 mm '.$answer.'\end{document}';
@@ -2710,7 +2697,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
@@ -2808,7 +2795,7 @@ ENDPART
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
} else {
$texversion.='\vskip 0 mm \noindent\textbf{'.
- &mt("Printing from Authoring Space: No Title").'}\vskip 0 mm ';
+ &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
}
@@ -3034,7 +3021,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,
@@ -3202,7 +3188,7 @@ ENDPART
$i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
}
my $actual_seq = master_seq_to_person_seq($map, \@master_seq,
- $person, undef, 1);
+ $person);
my ($output,$fullname, $printed)=&print_resources($r,$helper,
$person,$type,
\%moreenv, $actual_seq,
@@ -3319,11 +3305,11 @@ ENDPART
$moreenv{'CODE'}=&num_to_letters($code);
}
my $actual_seq = \@master_seq;
- if ($randomorder || $randompick) {
+ if ($randomorder) {
$env{'form.CODE'} = $moreenv{'CODE'};
$actual_seq = master_seq_to_person_seq($map, \@master_seq,
undef,
- $moreenv{'CODE'}, 1);
+ $moreenv{'CODE'});
delete($env{'form.CODE'});
}
my ($output,$fullname, $printed)=
@@ -3381,7 +3367,7 @@ ENDPART
$texversion.=&path_to_problem ($urlp,$LaTeXwidth);
} else {
$texversion.='\vskip 0 mm \noindent\textbf{'.
- &mt("Printing from Authoring Space: No Title").'}\vskip 0 mm ';
+ &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';
$texversion.=&path_to_problem ($urlp,$LaTeXwidth);
}
$texversion.='\vskip 1 mm '.$answer.'\end{document}';
@@ -3621,8 +3607,6 @@ sub print_resources {
my $current_assignment = "";
my $assignment;
my $courseidinfo = &get_course();
- if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
- if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
foreach my $curresline (@{$master_seq}) {
if (defined $page_breaks{$curresline}) {
@@ -3746,7 +3730,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.'}';
@@ -3778,7 +3762,7 @@ 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);
+ $currentassignment, $courseidinfo, $fullname, $usersection);
my $header_start = ($columns_in_format == 1) ? '\lhead'
: '\fancyhead[LO]';
$header_line = $header_start.'{'.$header_line.'}';
@@ -4067,7 +4051,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);
@@ -4147,13 +4131,13 @@ sub printHelper {
my $start_new_option;
if ($perm{'pav'}) {
$start_new_option =
- "').
+ "before selected').
"' variable='FINISHPAGE' />".
- "').
+ "before selected').
"' variable='EXTRASPACE' type='text' />" .
"".
- "').
+ "check for mm').
"' variable='EXTRASPACE_UNITS' type='checkbox' />"
;
@@ -4318,7 +4302,7 @@ my $suffixXml = <new("START", "Select Printing Options:");
if (!$res_printable) {
- my $now = time;
- my $shownprintstart = &Apache::lonlocal::locallocaltime($res_printstartdate);
- my $shownprintend = &Apache::lonlocal::locallocaltime($res_printenddate);
- my $noprintmsg;
- if (($res_printenddate) && ($res_printenddate < $now)) {
- $noprintmsg = &mt('Printing for current resource no longer available (ended: [_1])',
- $shownprintend);
- } else {
- if (($res_printstartdate) && ($res_printstartdate > $now)) {
- if (($res_printenddate) && ($res_printenddate > $now) && ($res_printenddate > $res_printstartdate)) {
- $noprintmsg = &mt('Printing for current resource is only possible between [_1] and [_2]',
- $shownprintstart,$shownprintend);
- } elsif (!$res_printenddate) {
- $noprintmsg = &mt('Printing for current resource will only be possible starting [_1]',
- $shownprintstart);
- } else {
- $noprintmsg = &mt('Printing for current resource is unavailable');
- }
- }
- }
-
- if ($noprintmsg) {
- $paramHash = Apache::lonhelper::getParamHash();
- $paramHash->{MESSAGE_TEXT} =
- '
'.$noprintmsg.'
';
- Apache::lonhelper::message->new();
- }
+ $paramHash = Apache::lonhelper::getParamHash();
+ $paramHash->{MESSAGE_TEXT} =
+ &mt('[_1]Printing for current resource is only possible between [_2] and [_3]',
+ '
',$res_printstartdate, $res_printenddate.'
');
+ Apache::lonhelper::message->new();
}
$paramHash = Apache::lonhelper::getParamHash();
$paramHash = Apache::lonhelper::getParamHash();
@@ -4922,7 +4884,7 @@ FONT_SELECTION
return "$helper->{VARS}->{'probstatus'}";
Homework Problem
- Exam Problem
+ Bubblesheet Exam ProblemSurvey question
,choice computer="anonsurvey"Anonymous survey question
@@ -5040,6 +5002,9 @@ sub render {
my $PaperType=&mt('Paper type');
my $landscape=&mt('Landscape');
my $portrait=&mt('Portrait');
+ my $pdfFormLabel=&mt('PDF-Formfields');
+ my $with=&mt('with Formfields');
+ my $without=&mt('without Formfields');
$result.='