version 1.475, 2006/08/03 00:26:39
|
version 1.495, 2007/01/15 11:53:50
|
Line 23
|
Line 23
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
# |
# |
# /home/httpd/html/adm/gpl.txt |
# /home/httpd/html/adm/gpl.txt |
# |
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# |
# |
Line 39 use Apache::grades;
|
Line 38 use Apache::grades;
|
use Apache::edit; |
use Apache::edit; |
use Apache::File(); |
use Apache::File(); |
use Apache::lonnavmaps; |
use Apache::lonnavmaps; |
use Apache::lonratedt; |
use LONCAPA::map(); |
use POSIX qw(strftime); |
use POSIX qw(strftime); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Carp; |
use Carp; |
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
use LONCAPA; |
|
|
my %perm; |
my %perm; |
my %parmhash; |
my %parmhash; |
my $resources_printed; |
my $resources_printed; |
|
|
|
# |
|
# printf_style_subst item format_string repl |
|
# |
|
# Does printf style substitution for a format string that |
|
# can have %[n]item in it.. wherever, %[n]item occurs, |
|
# rep is substituted in format_string. Note that |
|
# [n] is an optional integer length. If provided, |
|
# repl is truncated to at most [n] characters prior to |
|
# substitution. |
|
# |
|
sub printf_style_subst { |
|
my ($item, $format_string, $repl) = @_; |
|
my $result = ""; |
|
while ($format_string =~ /(%)(\d*)\Q$item\E/g ) { |
|
my $fmt = $1; |
|
my $size = $2; |
|
my $subst = $repl; |
|
if ($size ne "") { |
|
$subst = substr($subst, 0, $size); |
|
|
|
# Here's a nice edge case.. supose the end of the |
|
# substring is a \. In that case may have just |
|
# chopped off a TeX escape... in that case, we append |
|
# " " for the trailing character, and let the field |
|
# spill over a bit (sigh). |
|
# We don't just chop off the last character in order to deal |
|
# with one last pathology, and that would be if substr had |
|
# trimmed us to e.g. \\\ |
|
|
|
|
|
if ($subst =~ /\\$/) { |
|
$subst .= " "; |
|
} |
|
} |
|
my $item_pos = pos($format_string); |
|
$result .= substr($format_string, 0, $item_pos - length($size) -2) . $subst; |
|
$format_string = substr($format_string, pos($format_string)); |
|
} |
|
|
|
# Put the residual format string into the result: |
|
|
|
$result .= $format_string; |
|
|
|
return $result; |
|
} |
|
|
|
|
# Format a header according to a format. |
# Format a header according to a format. |
# |
# |
Line 60 my $resources_printed;
|
Line 104 my $resources_printed;
|
# %n - Student name. |
# %n - Student name. |
# |
# |
sub format_page_header { |
sub format_page_header { |
my ($format, $assignment, $course, $student) = @_; |
my ($width, $format, $assignment, $course, $student) = @_; |
|
|
|
$width = &recalcto_mm($width); # Get width in mm. |
# Default format? |
# Default format? |
|
|
if ($format eq '') { |
if ($format eq '') { |
|
# For the default format, we may need to truncate |
|
# elements.. To do this we need to get the page width. |
|
# we assume that each character is about 2mm in width. |
|
# (correct for the header text size??). We ignore |
|
# any formatting (e.g. boldfacing in this). |
|
# |
|
# - Allow the student/course to be one line. |
|
# but only truncate the course. |
|
# - Allow the assignment to be 2 lines (wrapped). |
|
# |
|
my $chars_per_line = $width/2; # Character/textline. |
|
|
|
|
|
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}"; |
$format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}"; |
|
|
} else { |
} else { |
$format =~ s/%a/$assignment/g; |
# An open question is how to handle long user formatted page headers... |
$format =~ s/%c/$course/g; |
# A possible future is to support e.g. %na so that the user can control |
$format =~ s/%n/$student/g; |
# 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!!! |
|
|
|
|
} |
} |
|
|
|
|
Line 94 sub num_to_letters {
|
Line 175 sub num_to_letters {
|
sub letters_to_num { |
sub letters_to_num { |
my ($letters) = @_; |
my ($letters) = @_; |
my @letters = split('', uc($letters)); |
my @letters = split('', uc($letters)); |
my %substitution; |
my %substitution; |
my $digit = 0; |
my $digit = 0; |
foreach my $letter ('A'..'J') { |
foreach my $letter ('A'..'J') { |
$substitution{$letter} = $digit; |
$substitution{$letter} = $digit; |
Line 409 sub character_chart {
|
Line 490 sub character_chart {
|
$result =~ s/&\#147;/\`\`/g; |
$result =~ s/&\#147;/\`\`/g; |
$result =~ s/&\#148;/\'\'/g; |
$result =~ s/&\#148;/\'\'/g; |
$result =~ s/&\#149;/\\ensuremath\{\\bullet\}/g; |
$result =~ s/&\#149;/\\ensuremath\{\\bullet\}/g; |
$result =~ s/&\#150;/--/g; |
$result =~ s/&(\#150|\#8211);/--/g; |
$result =~ s/&\#151;/---/g; |
$result =~ s/&\#151;/---/g; |
$result =~ s/&\#152;/\\ensuremath\{\\sim\}/g; |
$result =~ s/&\#152;/\\ensuremath\{\\sim\}/g; |
$result =~ s/&\#153;/\\texttrademark /g; |
$result =~ s/&\#153;/\\texttrademark /g; |
Line 616 sub character_chart {
|
Line 697 sub character_chart {
|
$result =~ s/&(clubs|\#9827);/\\ensuremath\{\\clubsuit\}/g; |
$result =~ s/&(clubs|\#9827);/\\ensuremath\{\\clubsuit\}/g; |
$result =~ s/&(hearts|\#9829);/\\ensuremath\{\\heartsuit\}/g; |
$result =~ s/&(hearts|\#9829);/\\ensuremath\{\\heartsuit\}/g; |
$result =~ s/&(diams|\#9830);/\\ensuremath\{\\diamondsuit\}/g; |
$result =~ s/&(diams|\#9830);/\\ensuremath\{\\diamondsuit\}/g; |
|
# Chemically useful 'things' contributed by Hon Kie (bug 4652). |
|
$result =~ s/&\#8636;/\\ensuremath\{\\leftharpoonup\}/g; |
|
$result =~ s/&\#8637;/\\ensuremath\{\\leftharpoondown\}/g; |
|
$result =~ s/&\#8640;/\\ensuremath\{\\rightharpoonup\}/g; |
|
$result =~ s/&\#8641;/\\ensuremath\{\\rightharpoondown\}/g; |
|
$result =~ s/&\#8652;/\\ensuremath\{\\rightleftharpoons\}/g; |
|
$result =~ s/&\#8605;/\\ensuremath\{\\leadsto\}/g; |
|
$result =~ s/&\#8617;/\\ensuremath\{\\hookleftarrow\}/g; |
|
$result =~ s/&\#8618;/\\ensuremath\{\\hookrightarrow\}/g; |
|
$result =~ s/&\#8614;/\\ensuremath\{\\mapsto\}/g; |
|
$result =~ s/&\#8599;/\\ensuremath\{\\nearrow\}/g; |
|
$result =~ s/&\#8600;/\\ensuremath\{\\searrow\}/g; |
|
$result =~ s/&\#8601;/\\ensuremath\{\\swarrow\}/g; |
|
$result =~ s/&\#8598;/\\ensuremath\{\\nwarrow\}/g; |
return $result; |
return $result; |
} |
} |
|
|
Line 624 sub character_chart {
|
Line 719 sub character_chart {
|
my %page_formats= |
my %page_formats= |
('letter' => { |
('letter' => { |
'book' => { |
'book' => { |
'1' => [ '7.1 in','9.8 in', '-0.57 in','-0.57 in','0.7 cm'], |
'1' => [ '7.1 in','9.8 in', '-0.57 in','-0.57 in','0.275 in'], |
'2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.7 cm'] |
'2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.275 in'] |
}, |
}, |
'album' => { |
'album' => { |
'1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.83 in','1 cm'], |
'1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.55 in','1.0 in'], |
'2' => [ '4.4 in', '6.8 in','-0.5 in', '-1.5 in','3.5 in'] |
'2' => [ '4.8 in', '6.8 in','-0.5 in', '-1.0 in','3.5 in'] |
}, |
}, |
}, |
}, |
'legal' => { |
'legal' => { |
Line 684 my %page_formats=
|
Line 779 my %page_formats=
|
}, |
}, |
'a4' => { |
'a4' => { |
'book' => { |
'book' => { |
'1' => ['17.6 cm','27.2 cm','-0.55 in','-0.83 in','-0.5 in'], |
'1' => ['17.6 cm','27.2 cm','-1.397 cm','-2.11 cm','-1.27 cm'], |
'2' => [ '9.1 cm','27.2 cm','-0.55 in','-0.83 in','-0.5 in'] |
'2' => [ '9.1 cm','27.2 cm','-1.397 c,','-2.11 cm','-1.27 cm'] |
}, |
}, |
'album' => { |
'album' => { |
'1' => ['8.5 in','7.7 in','-0.55 in','-0.83 in','0 in'], |
'1' => ['21.59 cm','19.558 cm','-1.27 cm','-2.11 cm','0 cm'], |
'2' => ['3.9 in','7.7 in','-0.55 in','-0.83 in','0 in'] |
'2' => ['9.91 cm','19.558 cm','-1.397 cm','-2.11 cm','0 cm'] |
}, |
}, |
}, |
}, |
'a5' => { |
'a5' => { |
Line 761 sub page_format_transformation {
|
Line 856 sub page_format_transformation {
|
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
my $header_text = $parmhash{'print_header_format'}; |
my $header_text = $parmhash{'print_header_format'}; |
$header_text = &format_page_header($header_text, $assignment, |
$header_text = &format_page_header($textwidth, $header_text, $assignment, |
$courseidinfo, $name); |
$courseidinfo, $name); |
my $topmargintoinsert = ''; |
my $topmargintoinsert = ''; |
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';} |
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';} |
Line 812 sub details_for_menu {
|
Line 907 sub details_for_menu {
|
if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; } |
if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; } |
my $name_of_resource = &Apache::lonnet::gettitle($postdata); |
my $name_of_resource = &Apache::lonnet::gettitle($postdata); |
my $symbolic = &Apache::lonnet::symbread($postdata); |
my $symbolic = &Apache::lonnet::symbread($postdata); |
|
return if ( $symbolic eq ''); |
|
|
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic); |
$map=&Apache::lonnet::clutter($map); |
$map=&Apache::lonnet::clutter($map); |
my $name_of_sequence = &Apache::lonnet::gettitle($map); |
my $name_of_sequence = &Apache::lonnet::gettitle($map); |
Line 827 sub details_for_menu {
|
Line 924 sub details_for_menu {
|
return ($name_of_resource,$name_of_sequence,$name_of_map); |
return ($name_of_resource,$name_of_sequence,$name_of_map); |
} |
} |
|
|
|
sub copyright_line { |
|
return '\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\vspace*{-2 mm}\newline\noindent{\tiny Printed from LON-CAPA\copyright MSU{\hfill} Licensed under GNU General Public License } '; |
|
} |
|
my $end_of_student = "\n".'\special{ps:ENDOFSTUDENTSTAMP}'."\n"; |
|
|
sub latex_corrections { |
sub latex_corrections { |
my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_; |
my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_; |
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; |
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; |
$result =~ s/\$number_of_columns/$number_of_columns/g; |
my $copyright = ©right_line(); |
if ($selectionmade eq '1' || $answer_mode eq 'only') { |
if ($selectionmade eq '1' || $answer_mode eq 'only') { |
$result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License \newpage \n\\special{ps:ENDOFSTUDENTSTAMP}\n $1/; |
$result =~ s/(\\end{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/; |
} else { |
} else { |
$result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License \newpage \n\\special{ps:ENDOFSTUDENTSTAMP}\n $1/; |
$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; |
$result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g; |
#-- LaTeX corrections |
#-- LaTeX corrections |
Line 1077 sub print_construction_sequence {
|
Line 1179 sub print_construction_sequence {
|
if ($helper->{'VARS'}->{'curseed'}) { |
if ($helper->{'VARS'}->{'curseed'}) { |
$rndseed=$helper->{'VARS'}->{'curseed'}; |
$rndseed=$helper->{'VARS'}->{'curseed'}; |
} |
} |
my $errtext=&Apache::lonratedt::mapread($currentURL); |
my $errtext=&LONCAPA::map::mapread($currentURL); |
# |
# |
# These make this all support recursing for subsequences. |
# These make this all support recursing for subsequences. |
# |
# |
my @order = @Apache::lonratedt::order; |
my @order = @LONCAPA::map::order; |
my @resources = @Apache::lonratedt::resources; |
my @resources = @LONCAPA::map::resources; |
for (my $member=0;$member<=$#order;$member++) { |
for (my $member=0;$member<=$#order;$member++) { |
$resources[$order[$member]]=~/^([^:]*):([^:]*):/; |
$resources[$order[$member]]=~/^([^:]*):([^:]*):/; |
my $urlp=$2; |
my $urlp=$2; |
Line 1114 sub print_construction_sequence {
|
Line 1216 sub print_construction_sequence {
|
# If necessary, encapsulate answer in minipage: |
# If necessary, encapsulate answer in minipage: |
|
|
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$body.=&path_to_problem($urlp,$LaTeXwidth); |
$body.=&path_to_problem($urlp,$LaTeXwidth); |
$body.='\vskip 1 mm '.$answer.'\end{document}'; |
$body.='\vskip 1 mm '.$answer.'\end{document}'; |
$body = &encapsulate_minipage($body); |
$body = &encapsulate_minipage($body); |
Line 1309 ENDPART
|
Line 1413 ENDPART
|
} else { |
} else { |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
$texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
$texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth); |
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth); |
} else { |
} else { |
$texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; |
$texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; |
Line 1430 ENDPART
|
Line 1536 ENDPART
|
} else { |
} else { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$body .= &path_to_problem ($urlp,$LaTeXwidth); |
$body .= &path_to_problem ($urlp,$LaTeXwidth); |
$body .='\vskip 1 mm '.$answer; |
$body .='\vskip 1 mm '.$answer; |
$body = &encapsulate_minipage($body); |
$body = &encapsulate_minipage($body); |
Line 1454 ENDPART
|
Line 1562 ENDPART
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
$prevassignment=$assignment; |
$prevassignment=$assignment; |
my $header_text = $parmhash{'print_header_format'}; |
my $header_text = $parmhash{'print_header_format'}; |
$header_text = &format_page_header($header_text, |
$header_text = &format_page_header($textwidth, $header_text, |
$assignment, |
$assignment, |
$courseidinfo, |
$courseidinfo, |
$name); |
$name); |
Line 1885 sub print_resources {
|
Line 1993 sub print_resources {
|
my $printed = ''; |
my $printed = ''; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my ($username,$userdomain,$usersection) = split /:/,$person; |
my $fullname = &get_name($username,$userdomain); |
my $fullname = &get_name($username,$userdomain); |
my $namepostfix; |
my $namepostfix = "\\\\"; # Both anon and not anon should get the same vspace. |
if ($person =~ 'anon') { |
if ($person =~ 'anon') { |
$namepostfix="\\\\Name: "; |
$namepostfix .="Name: "; |
$fullname = "CODE - ".$moreenv->{'CODE'}; |
$fullname = "CODE - ".$moreenv->{'CODE'}; |
} |
} |
# Fullname may have special latex characters that need \ prefixing: |
# Fullname may have special latex characters that need \ prefixing: |
Line 1899 sub print_resources {
|
Line 2007 sub print_resources {
|
|
|
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
my %page_breaks = &get_page_breaks($helper); |
my %page_breaks = &get_page_breaks($helper); |
my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'}); |
my $columns_in_format = (split(/\|/,$helper->{'VARS'}->{'FORMAT'}))[1]; |
my $columns_in_format = $format_array[1]; |
|
# |
# |
# end each student with a |
# end each student with a |
# Special that allows the post processor to even out the page |
# Special that allows the post processor to even out the page |
Line 1948 sub print_resources {
|
Line 2055 sub print_resources {
|
|
|
|
|
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($curresline); |
$body .=&path_to_problem($res_url,$LaTeXwidth); |
$title = &Apache::lonxml::latex_special_symbols($title); |
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
|
$body .=&path_to_problem($res_url,$LaTeXwidth); |
$body .='\vskip 1 mm '.$ansrendered; |
$body .='\vskip 1 mm '.$ansrendered; |
$body = &encapsulate_minipage($body); |
$body = &encapsulate_minipage($body); |
$rendered = $header.$body; |
$rendered = $header.$body; |
Line 1990 sub print_resources {
|
Line 2099 sub print_resources {
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $HeaderLine = $parmhash{'print_header_format'}; |
my $header_line = |
$HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname); |
&format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
if ($current_output=~/\\documentclass/) { |
$currentassignment, $courseidinfo, $fullname); |
if ($columns_in_format == 1) { |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /; |
: '\fancyhead[LO]'; |
} else { |
$header_line = $header_start.'{'.$header_line.'}'; |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{$HeaderLine$namepostfix}}\\vskip 5 mm /; |
|
|
|
} |
if ($current_output=~/\\documentclass/) { |
|
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; |
} else { |
} else { |
my $blankpages = ''; |
my $blankpages = |
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} |
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; |
if ($columns_in_format == 1) { |
|
$current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; |
$current_output = '\strut\vspace*{-6 mm}\\newline'. |
} else { |
©right_line().' \newpage '.$blankpages.$end_of_student. |
$current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; |
'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'. |
} |
$header_line.$namepostfix.'} \vskip 5 mm '.$current_output; |
} |
} |
# |
# |
# Close the student bracketing. |
# Close the student bracketing. |
Line 2112 sub printHelper {
|
Line 2221 sub printHelper {
|
$helper->declareVar('FINISHPAGE'); |
$helper->declareVar('FINISHPAGE'); |
$helper->declareVar('PRINT_TYPE'); |
$helper->declareVar('PRINT_TYPE'); |
$helper->declareVar("showallfoils"); |
$helper->declareVar("showallfoils"); |
|
$helper->declareVar("STUDENTS"); |
|
|
# The page breaks can get loaded initially from the course environment: |
# The page breaks can get loaded initially from the course environment: |
# But we only do this in the initial state so that they are allowed to change. |
# But we only do this in the initial state so that they are allowed to change. |
Line 2123 sub printHelper {
|
Line 2233 sub printHelper {
|
{'pagebreaks' => 'scalar', |
{'pagebreaks' => 'scalar', |
'lastprinttype' => 'scalar'}); |
'lastprinttype' => 'scalar'}); |
|
|
|
# This will persistently load in the data we want from the |
|
# very first screen. |
|
|
if($helper->{VARS}->{PRINT_TYPE} eq $env{'form.lastprinttype'}) { |
if($helper->{VARS}->{PRINT_TYPE} eq $env{'form.lastprinttype'}) { |
if (!defined ($env{"form.CURRENT_STATE"})) { |
if (!defined ($env{"form.CURRENT_STATE"})) { |
Line 2137 sub printHelper {
|
Line 2249 sub printHelper {
|
|
|
} |
} |
|
|
|
|
# This will persistently load in the data we want from the |
|
# very first screen. |
|
# Detect whether we're coming from construction space |
# Detect whether we're coming from construction space |
if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) { |
if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) { |
$helper->{VARS}->{'filename'} = "~$1/$2"; |
$helper->{VARS}->{'filename'} = "~$1/$2"; |
Line 2147 sub printHelper {
|
Line 2257 sub printHelper {
|
} else { |
} else { |
if ($env{'form.postdata'}) { |
if ($env{'form.postdata'}) { |
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'}); |
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'}); |
|
if ( $helper->{VARS}->{'symb'} eq '') { |
|
$helper->{VARS}->{'postdata'} = $env{'form.postdata'}; |
|
} |
} |
} |
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
$helper->{VARS}->{'symb'} = $env{'form.symb'}; |
$helper->{VARS}->{'symb'} = $env{'form.symb'}; |
Line 2174 sub printHelper {
|
Line 2287 sub printHelper {
|
my $symb = $helper->{VARS}->{'symb'}; |
my $symb = $helper->{VARS}->{'symb'}; |
my ($map, $id, $url); |
my ($map, $id, $url); |
my $subdir; |
my $subdir; |
|
my $is_published=0; # True when printing from resource space. |
|
|
# Get the resource name from construction space |
# Get the resource name from construction space |
if ($helper->{VARS}->{'construction'}) { |
if ($helper->{VARS}->{'construction'}) { |
Line 2182 sub printHelper {
|
Line 2296 sub printHelper {
|
$subdir = substr($helper->{VARS}->{'filename'}, |
$subdir = substr($helper->{VARS}->{'filename'}, |
0, rindex($helper->{VARS}->{'filename'}, '/') + 1); |
0, rindex($helper->{VARS}->{'filename'}, '/') + 1); |
} else { |
} else { |
($map, $id, $url) = &Apache::lonnet::decode_symb($symb); |
if ($symb ne '') { |
$helper->{VARS}->{'postdata'} = |
($map, $id, $url) = &Apache::lonnet::decode_symb($symb); |
&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); |
$helper->{VARS}->{'postdata'} = |
|
&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); |
|
} else { |
|
$url = $helper->{VARS}->{'postdata'}; |
|
$is_published=1; # From resource space. |
|
} |
|
$url = &Apache::lonnet::clutter($url); |
|
|
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename |
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename |
my $postdata = $helper->{VARS}->{'postdata'}; |
my $postdata = $helper->{VARS}->{'postdata'}; |
Line 2205 sub printHelper {
|
Line 2325 sub printHelper {
|
|
|
# "Delete everything after the last slash." |
# "Delete everything after the last slash." |
$subdir =~ s|/[^/]+$||; |
$subdir =~ s|/[^/]+$||; |
if (not $helper->{VARS}->{'construction'}) { |
|
$subdir=$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$subdir; |
|
} |
|
# "Remove all duplicate slashes." |
|
$subdir =~ s|/+|/|g; |
|
|
|
# What can be printed is a very dynamic decision based on |
# What can be printed is a very dynamic decision based on |
# lots of factors. So we need to dynamically build this list. |
# lots of factors. So we need to dynamically build this list. |
Line 2250 sub printHelper {
|
Line 2365 sub printHelper {
|
"' variable='FINISHPAGE' />"; |
"' variable='FINISHPAGE' />"; |
} |
} |
|
|
if (($helper->{'VARS'}->{'construction'} ne '1') && |
if (($helper->{'VARS'}->{'construction'} ne '1' ) && |
|
|
$helper->{VARS}->{'postdata'} && |
$helper->{VARS}->{'postdata'} && |
$helper->{VARS}->{'assignment'}) { |
$helper->{VARS}->{'assignment'}) { |
Line 2288 HELPERFRAGMENT
|
Line 2403 HELPERFRAGMENT
|
|
|
# If the user has pfo (print for otheres) allow them to print all |
# If the user has pfo (print for otheres) allow them to print all |
# problems and resources in the entier course, optionally for selected students |
# problems and resources in the entier course, optionally for selected students |
if ($perm{'pfo'} && |
if ($perm{'pfo'} && !$is_published && |
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
|
|
push @{$printChoices}, ['Selected <b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS']; |
push @{$printChoices}, ['Selected <b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS']; |
Line 2316 HELPERFRAGMENT
|
Line 2431 HELPERFRAGMENT
|
ALL_PROBLEMS |
ALL_PROBLEMS |
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected people</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
} |
} |
|
|
Line 2363 RESOURCE_SELECTOR
|
Line 2478 RESOURCE_SELECTOR
|
|
|
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS); |
<state name="CHOOSE_STUDENTS" title="Select Students and Resources"> |
<state name="CHOOSE_STUDENTS" title="Select Students and Resources"> |
<message><b>Select sort order</b> </message> |
<message><b>Select sorting order of printout</b> </message> |
<choices variable='student_sort'> |
<choices variable='student_sort'> |
<choice computer='0'>Sort by section then student</choice> |
<choice computer='0'>Sort by section then student</choice> |
<choice computer='1'>Sort by students across sections.</choice> |
<choice computer='1'>Sort by students across sections.</choice> |
Line 2491 CHOOSE_ANON1
|
Line 2606 CHOOSE_ANON1
|
|
|
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected people</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
} |
} |
|
|
Line 2601 CHOOSE_ANON2
|
Line 2716 CHOOSE_ANON2
|
} |
} |
|
|
# FIXME: That RE should come from a library somewhere. |
# FIXME: That RE should come from a library somewhere. |
if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') { |
if (($perm{'pav'} |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
&& $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/' |
|
&& (defined($helper->{'VARS'}->{'construction'}) |
|
|| |
|
(&Apache::lonnet::allowed('bre',$subdir) eq 'F' |
|
&& |
|
$helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/) |
|
)) |
|
&& $helper->{VARS}->{'assignment'} eq "" |
|
) { |
|
|
my $f = '$filename'; |
my $pretty_dir = &Apache::lonnet::hreflocation($subdir); |
|
push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$pretty_dir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
my $xmlfrag = <<CHOOSE_FROM_SUBDIR; |
my $xmlfrag = <<CHOOSE_FROM_SUBDIR; |
<state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$subdir</small></b> to print"> |
<state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$pretty_dir</small></b> to print"> |
|
|
<files variable="FILES" multichoice='1'> |
<files variable="FILES" multichoice='1'> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
Line 2627 CHOOSE_FROM_SUBDIR
|
Line 2751 CHOOSE_FROM_SUBDIR
|
|
|
# Allow the user to select any sequence in the course, feed it to |
# Allow the user to select any sequence in the course, feed it to |
# another resource selector for that sequence |
# another resource selector for that sequence |
if (!$helper->{VARS}->{'construction'}) { |
if (!$helper->{VARS}->{'construction'} && !$is_published) { |
push @$printChoices, ["Selected <b>Resources</b> from <b>selected folder</b> in course", |
push @$printChoices, ["Selected <b>Resources</b> from <b>selected folder</b> in course", |
'select_sequences', 'CHOOSE_SEQUENCE']; |
'select_sequences', 'CHOOSE_SEQUENCE']; |
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'}; |
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'}; |