--- loncom/interface/lonprintout.pm 2024/11/10 20:41:18 1.702
+++ loncom/interface/lonprintout.pm 2025/01/15 23:10:25 1.706
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.702 2024/11/10 20:41:18 raeburn Exp $
+# $Id: lonprintout.pm,v 1.706 2025/01/15 23:10:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -812,16 +812,17 @@ sub map_print_dates {
# Parameters:
# $username - Name of user for whom we are checking.
# $domain - Domain of user we are checking.
+# $section - Section for user for whom we are checking.
# $map - map name.
# Returns:
# 0 - map is not incomplete.
# 1 - map is incomplete.
#
sub incomplete {
- my ($username, $domain, $map) = @_;
+ my ($username, $domain, $section, $map) = @_;
- my $navmap = Apache::lonnavmaps::navmap->new($username, $domain);
+ my $navmap = Apache::lonnavmaps::navmap->new($username, $domain, $section);
if (defined($navmap)) {
@@ -878,7 +879,7 @@ sub master_seq_to_person_seq {
}
my $navmap = Apache::lonnavmaps::navmap->new($username, $userdomain,
- $code, $unhidden);
+ $usersection, $code, $unhidden);
my ($start,$finish);
if ($map) {
@@ -1861,8 +1862,8 @@ sub old_character_chart {
my %page_formats=
('letter' => {
'book' => {
- '1' => [ '7.1 in','9.7 in', '-0.57 in','-0.57 in','0.1 in'],
- '2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.1 in']
+ '1' => [ '7.1 in','9.7 in', '-0.57 in','-0.57 in','-0.5 in'],
+ '2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','-0.5 in']
},
'album' => {
'1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.55 in','-0.5 in'],
@@ -1985,7 +1986,8 @@ sub get_course {
}
sub page_format_transformation {
- my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist,$selectionmade) = @_;
+ my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,
+ $indexlist,$selectionmade,$mostrecent) = @_;
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin);
if ($selectionmade eq '4') {
@@ -1999,8 +2001,12 @@ sub page_format_transformation {
}
($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin);
-
- my $name = &get_name();
+ my $name;
+ if ($mostrecent ne '') {
+ $name = $mostrecent;
+ } else {
+ $name = &get_name();
+ }
my $courseidinfo = &get_course();
my $header_text = $parmhash{'print_header_format'};
$header_text = &format_page_header($textwidth, $header_text, $assignment,
@@ -2022,13 +2028,13 @@ sub page_format_transformation {
$text =~ s/\\begin\{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\n\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\n\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\n\\pagestyle{fancy}$fancypagestatement\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}\n /;
if ($papersize eq 'a4') {
$paperwidth = '29.7cm';
- $paperheight = '21cm';
+ $paperheight = '21.0cm';
} elsif ($numberofcolumns eq '1') {
if ($papersize eq 'letter') {
- $paperwidth = '11in';
+ $paperwidth = '11.0in';
$paperheight = '8.5in';
} elsif ($papersize eq 'legal') {
- $paperwidth = '14in';
+ $paperwidth = '14.0in';
$paperheight = '8.5in';
}
}
@@ -2039,11 +2045,11 @@ sub page_format_transformation {
$text =~ s/\\pagestyle\{fancy}\\rhead\{}\\chead\{}\s*\\begin\{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /;
}
if ($papersize eq 'a4') {
- $paperwidth = '21cm';
+ $paperwidth = '21.0cm';
$paperheight = '29.7cm';
} elsif ($papersize eq 'letter') {
$paperwidth = '8.5in';
- $paperheight = '11.5in';
+ $paperheight = '11.0in';
} elsif ($papersize eq 'legal') {
$paperwidth = '8.5in';
$paperheight = '14.0in';
@@ -2768,6 +2774,7 @@ sub print_construction_sequence {
# 6 Print selected problems from a folder.
# 7 Print print selected resources from some scope.
# 8 Print resources for selected students.
+# 9 Print for anonymous CODEs
#
#BZ 5209
# 2 map_incomplete_problems_seq Print incomplete problems from the current
@@ -2860,7 +2867,7 @@ ENDPART
my $LaTeXwidth=&recalcto_mm($textwidth);
my @print_array=();
my @student_names=();
-
+ my $lastprinted;
# Common settings for the %form hash:
# In some cases these settings get overridden by specific cases, but the
@@ -3388,6 +3395,9 @@ ENDPART
# &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname);
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
$flag_latex_header_remove = 'YES';
+ if ($printed) {
+ $lastprinted = $fullname;
+ }
if (&Apache::loncommon::connection_aborted($r)) { last; }
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
@@ -3397,6 +3407,7 @@ ENDPART
($print_type eq 'resources_for_anon') ||
($print_type eq 'select_sequences_problems_for_anon') ||
($print_type eq 'select_sequences_resources_for_anon')) {
+ $selectionmade = 9;
my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
@@ -3510,6 +3521,9 @@ ENDPART
&mt('last assignment').' '.$fullname);
$flag_latex_header_remove = 'YES';
$count++;
+ if ($printed) {
+ $lastprinted = $fullname;
+ }
if (&Apache::loncommon::connection_aborted($r)) { last; }
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
@@ -3589,13 +3603,18 @@ ENDPART
# Only post process if that has not been turned off e.g. by a raw latex resource.
if ($do_postprocessing) {
+ my $mostrecent;
+ if ((($selectionmade == 5) || ($selectionmade == 8) || ($selectionmade == 9)) &&
+ (($numberofcolumns == 1) || ($laystyle eq 'album' && $papersize eq 'a4'))) {
+ $mostrecent = $lastprinted;
+ }
$result = &page_format_transformation($papersize,
$laystyle,$numberofcolumns,
$print_type,$result,
$helper->{VARS}->{'assignment'},
$helper->{'VARS'}->{'TABLE_CONTENTS'},
$helper->{'VARS'}->{'TABLE_INDEX'},
- $selectionmade);
+ $selectionmade,$mostrecent);
$result = &latex_corrections($number_of_columns,$result,$selectionmade,
$helper->{'VARS'}->{'ANSWER_TYPE'});
#if ($numberofcolumns == 1) {
@@ -3849,7 +3868,7 @@ sub print_resources {
if ( !($type eq 'problems' &&
($curresline!~ m/$LONCAPA::assess_page_re/)) ) {
- if ($print_incomplete && !&incomplete($username, $userdomain, $res_url)) {
+ if ($print_incomplete && !&incomplete($username, $userdomain, $usersection, $res_url)) {
next;
}
$actually_printed++; # we're going to print one.
@@ -3867,7 +3886,6 @@ sub print_resources {
$rendered = &print_latex_header().$rendered;
}
}
-;
if ($remove_latex_header eq 'YES') {
$rendered = &latex_header_footer_remove($rendered);
} else {
@@ -3882,7 +3900,7 @@ sub print_resources {
$answerenv{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
-
+
&Apache::lonxml::restore_problem_counter();
my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%answerenv);
@@ -4218,7 +4236,6 @@ sub printHelper {
}
}
-
}
# Detect whether we're coming from construction space
@@ -4386,7 +4403,7 @@ sub printHelper {
# Give that as a choice.
if ($resourceTitle && $res_printable) {
- push @{$printChoices}, ["$resourceTitle (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE'];
+ push(@{$printChoices}, ["$resourceTitle (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE']);
}
# Useful filter strings
@@ -4440,14 +4457,14 @@ sub printHelper {
my $resourcesymb = $page_resources[0]->symb();
my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb);
if ($page_ispage) {
- push @{$printChoices},
+ push(@{$printChoices},
[&mt('Selected [_1]Problems[_2] from page [_3]', '', '', ''.$page_title.''),
'map_problems_in_page',
- 'CHOOSE_PROBLEMS_PAGE'];
- push @{$printChoices},
+ 'CHOOSE_PROBLEMS_PAGE']);
+ push(@{$printChoices},
[&mt('Selected [_1]Resources[_2] from page [_3]', '', '', ''.$page_title.''),
'map_resources_in_page',
- 'CHOOSE_RESOURCES_PAGE'];
+ 'CHOOSE_RESOURCES_PAGE']);
}
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS_PAGE',
'Select Problem(s) to print',
@@ -4531,19 +4548,19 @@ sub printHelper {
} else {
$optionText = &mt('Selected [_1]Problems[_2] from folder [_3]','','',''.$sequenceTitle.'');
}
- push @{$printChoices},
+ push(@{$printChoices},
[$optionText,
'map_problems',
- 'CHOOSE_PROBLEMS'];
+ 'CHOOSE_PROBLEMS']);
# Allow all resources from sequence
if ($helper->{VARS}->{'postdata'} eq '/adm/navmaps') {
$optionText = &mt('Selected [_1]Resources[_2] [_3]not in a folder[_4]','','','','');
} else {
$optionText = &mt('Selected [_1]Resources[_2] from folder [_3]','','',''.$sequenceTitle.'');
}
- push @{$printChoices}, [$optionText,
+ push(@{$printChoices}, [$optionText,
'map_problems_pages',
- 'CHOOSE_PROBLEMS_HTML'];
+ 'CHOOSE_PROBLEMS_HTML']);
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS',
'Select Problem(s) to print',
'multichoice="1" toponly="1" addstatus="1" closeallpages="1" modallink="1" nocurrloc="'.$nocurrloc.'"',
@@ -4587,9 +4604,9 @@ sub printHelper {
# Selected problems/resources from entire course:
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from [_3]entire course[_4]','','','',''), 'all_problems', 'ALL_PROBLEMS'];
- push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from [_3]entire course[_4]','','','',''), 'all_resources', 'ALL_RESOURCES'];
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from [_3]entire course[_4] for [_5]selected people[_6]','','','','','',''), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS'];
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from [_3]entire course[_4]','','','',''), 'all_problems', 'ALL_PROBLEMS']);
+ push(@{$printChoices}, [&mt('Selected [_1]Resources[_2] from [_3]entire course[_4]','','','',''), 'all_resources', 'ALL_RESOURCES']);
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from [_3]entire course[_4] for [_5]selected people[_6]','','','','','',''), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS']);
my $suffixXml = <
Select sorting order of printout
@@ -4636,19 +4653,19 @@ ALL_PROBLEMS
# either for selected students or for coded assignments.
if ($page_ispage) {
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from page [_3] for [_4]selected people[_5]',
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from page [_3] for [_4]selected people[_5]',
'', '', ''.$page_title.'', '', ''),
- 'problems_for_students_from_page', 'CHOOSE_TGT_STUDENTS_PAGE'];
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from page [_3] for [_4]CODEd assignments[_5]',
+ 'problems_for_students_from_page', 'CHOOSE_TGT_STUDENTS_PAGE']);
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from page [_3] for [_4]CODEd assignments[_5]',
'', '', ''.$page_title.'', '', ''),
- 'problems_for_anon_page', 'CHOOSE_ANON1_PAGE'];
+ 'problems_for_anon_page', 'CHOOSE_ANON1_PAGE']);
}
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]selected people[_5]',
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]selected people[_5]',
'','',''.$sequenceTitle.'','',''),
- 'problems_for_students', 'CHOOSE_STUDENTS'];
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]CODEd assignments[_5]',
+ 'problems_for_students', 'CHOOSE_STUDENTS']);
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]CODEd assignments[_5]',
'','',''.$sequenceTitle.'','',''),
- 'problems_for_anon', 'CHOOSE_ANON1'];
+ 'problems_for_anon', 'CHOOSE_ANON1']);
}
my ($randomly_ordered_warning,$codechoice,$code_selection,$namechoice) =
@@ -4658,8 +4675,8 @@ ALL_PROBLEMS
# Assignment printing:
- push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3] for [_4]selected people[_5]','','',''.$sequenceTitle.'','',''), 'resources_for_students', 'CHOOSE_STUDENTS1'];
- push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3] for [_4]CODEd assignments[_5]','','',''.$sequenceTitle.'','',''), 'resources_for_anon', 'CHOOSE_ANON2'];
+ push(@{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3] for [_4]selected people[_5]','','',''.$sequenceTitle.'','',''), 'resources_for_students', 'CHOOSE_STUDENTS1']);
+ push(@{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3] for [_4]CODEd assignments[_5]','','',''.$sequenceTitle.'','',''), 'resources_for_anon', 'CHOOSE_ANON2']);
}
# resource_selector will hold a few states that:
@@ -4780,7 +4797,7 @@ CHOOSE_ANON2
&& $helper->{VARS}->{'assignment'} eq ""
) {
my $pretty_dir = &Apache::lonnet::hreflocation($subdir);
- push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from current subdirectory [_3]','','',''.$pretty_dir.'','',''), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
+ push(@{$printChoices}, [&mt('Selected [_1]Problems[_2] from current subdirectory [_3]','','',''.$pretty_dir.'','',''), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']);
my $xmlfrag = <