version 1.456, 2006/07/07 21:55:05
|
version 1.464, 2006/07/18 18:19:51
|
Line 47 use LONCAPA;
|
Line 47 use LONCAPA;
|
|
|
my %perm; |
my %perm; |
my %parmhash; |
my %parmhash; |
|
my $resources_printed; |
|
|
|
|
# Format a header according to a format. |
# Format a header according to a format. |
Line 626 my %page_formats=
|
Line 627 my %page_formats=
|
'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.7 cm'] |
}, |
}, |
'album' => { |
'album' => { |
'1' => [ '8.8 in', '6.8 in','-40 pt in', '-60 pt','1 cm'], |
'1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.83 in','1 cm'], |
'2' => [ '4.4 in', '6.8 in','-0.5 in', '-1.5 in','3.5 in'] |
'2' => [ '4.4 in', '6.8 in','-0.5 in', '-1.5 in','3.5 in'] |
}, |
}, |
}, |
}, |
Line 682 my %page_formats=
|
Line 683 my %page_formats=
|
}, |
}, |
'a4' => { |
'a4' => { |
'book' => { |
'book' => { |
'1' => ['176 mm','272 mm','-40 pt in','-60 pt','-0.5 in'], |
'1' => ['17.6 cm','27.2 cm','-0.55 in','-0.83 in','-0.5 in'], |
'2' => [ '91 mm','272 mm','-40 pt in','-60 pt','-0.5 in'] |
'2' => [ '9.1 cm','27.2 cm','-0.55 in','-0.83 in','-0.5 in'] |
}, |
}, |
'album' => { |
'album' => { |
'1' => ['8.5 in','7.7 in','-40 pt in','-60 pt','0 in'], |
'1' => ['8.5 in','7.7 in','-0.55 in','-0.83 in','0 in'], |
'2' => ['3.9 in','7.7 in','-40 pt in','-60 pt','0 in'] |
'2' => ['3.9 in','7.7 in','-0.55 in','-0.83 in','0 in'] |
}, |
}, |
}, |
}, |
'a5' => { |
'a5' => { |
Line 1055 sub get_page_breaks {
|
Line 1056 sub get_page_breaks {
|
return %page_breaks; |
return %page_breaks; |
} |
} |
|
|
|
# Output a sequence (recursively if neeed) |
|
# from construction space. |
|
# Parameters: |
|
# url = URL of the sequence to print. |
|
# helper - Reference to the helper hash. |
|
# form - Copy of the format hash. |
|
# LaTeXWidth |
|
# Returns: |
|
# Text to add to the printout. |
|
# NOTE if the first element of the outermost sequence |
|
# is itself a sequence, the outermost caller may need to |
|
# prefix the latex with the page headers stuff. |
|
# |
|
sub print_construction_sequence { |
|
my ($currentURL, $helper, %form, $LaTeXwidth) = @_; |
|
my $result; |
|
my $rndseed=time; |
|
if ($helper->{'VARS'}->{'curseed'}) { |
|
$rndseed=$helper->{'VARS'}->{'curseed'}; |
|
} |
|
my $errtext=&Apache::lonratedt::mapread($currentURL); |
|
# |
|
# These make this all support recursing for subsequences. |
|
# |
|
my @order = @Apache::lonratedt::order; |
|
my @resources = @Apache::lonratedt::resources; |
|
for (my $member=0;$member<=$#order;$member++) { |
|
$resources[$order[$member]]=~/^([^:]*):([^:]*):/; |
|
my $urlp=$2; |
|
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { |
|
my $texversion=''; |
|
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { |
|
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
|
$form{'suppress_tries'}=$parmhash{'suppress_tries'}; |
|
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
|
$form{'rndseed'}=$rndseed; |
|
$resources_printed .=$urlp.':'; |
|
$texversion=&Apache::lonnet::ssi($urlp,%form); |
|
} |
|
if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
|
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) && |
|
($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) { |
|
# Don't permanently modify %$form... |
|
my %answerform = %form; |
|
$answerform{'grade_target'}='answer'; |
|
$answerform{'answer_output_mode'}='tex'; |
|
$answerform{'rndseed'}=$rndseed; |
|
$answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; |
|
if ($urlp=~/\/res\//) {$env{'request.state'}='published';} |
|
$resources_printed .= $urlp.':'; |
|
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
|
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
|
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
|
} else { |
|
# If necessary, encapsulate answer in minipage: |
|
|
|
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
|
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; |
|
$body.=&path_to_problem($urlp,$LaTeXwidth); |
|
$body.='\vskip 1 mm '.$answer.'\end{document}'; |
|
$body = &encapsulate_minipage($body); |
|
$texversion.=$body; |
|
} |
|
} |
|
$texversion = &latex_header_footer_remove($texversion); |
|
|
|
if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') { |
|
$texversion=&IndexCreation($texversion,$urlp); |
|
} |
|
if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') { |
|
$texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /; |
|
} |
|
$result.=$texversion; |
|
|
|
} elsif ($urlp=~/\.(sequence|page)$/) { |
|
|
|
# header: |
|
|
|
$result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent '; |
|
|
|
# IF sequence, recurse: |
|
|
|
if ($urlp =~ /\.sequence$/) { |
|
my $sequence_url = $urlp; |
|
my $domain = $env{'user.domain'}; # Constr. space only on local |
|
my $user = $env{'user.name'}; |
|
|
|
$sequence_url =~ s/^\/res\/$domain/\/home/; |
|
$sequence_url =~ s/^(\/home\/$user)/$1\/public_html/; |
|
# $sequence_url =~ s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
|
$result .= &print_construction_sequence($sequence_url, |
|
$helper, %form, |
|
$LaTeXwidth); |
|
} |
|
} |
|
} |
|
if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} |
|
return $result; |
|
} |
|
|
sub output_data { |
sub output_data { |
my ($r,$helper,$rparmhash) = @_; |
my ($r,$helper,$rparmhash) = @_; |
my %parmhash = %$rparmhash; |
my %parmhash = %$rparmhash; |
my $resources_printed = ''; |
$resources_printed = ''; |
my $js = <<ENDPART; |
my $js = <<ENDPART; |
<script type="text/javascript"> |
<script type="text/javascript"> |
var editbrowser; |
var editbrowser; |
Line 1232 ENDPART
|
Line 1333 ENDPART
|
} elsif ($cleanURL!~m|^/adm/| |
} elsif ($cleanURL!~m|^/adm/| |
&& $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') { |
&& $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') { |
#printing content of sequence from the construction space |
#printing content of sequence from the construction space |
my $flag_latex_header_remove = 'NO'; |
|
my $rndseed=time; |
|
if ($helper->{'VARS'}->{'curseed'}) { |
|
$rndseed=$helper->{'VARS'}->{'curseed'}; |
|
} |
|
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
my $errtext=&Apache::lonratedt::mapread($currentURL); |
$result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
for (my $member=0;$member<=$#Apache::lonratedt::order;$member++) { |
$result .= &print_construction_sequence($currentURL, $helper, %form, |
$Apache::lonratedt::resources[$Apache::lonratedt::order[$member]]=~/^([^:]*):([^:]*):/; |
$LaTeXwidth); |
my $urlp=$2; |
$result .= '\end{document}'; |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { |
if (!($result =~ /\\begin\{document\}/)) { |
my $texversion=''; |
$result = &print_latex_header() . $result; |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { |
|
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
|
$form{'suppress_tries'}=$parmhash{'suppress_tries'}; |
|
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
|
$form{'rndseed'}=$rndseed; |
|
$resources_printed .=$urlp.':'; |
|
$texversion=&Apache::lonnet::ssi($urlp,%form); |
|
} |
|
if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
|
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) && |
|
($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) { |
|
# Don't permanently modify %$form... |
|
my %answerform = %form; |
|
$answerform{'grade_target'}='answer'; |
|
$answerform{'answer_output_mode'}='tex'; |
|
$answerform{'rndseed'}=$rndseed; |
|
$answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; |
|
if ($urlp=~/\/res\//) {$env{'request.state'}='published';} |
|
$resources_printed .= $urlp.':'; |
|
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
|
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
|
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
|
} else { |
|
# If necessary, encapsulate answer in minipage: |
|
|
|
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
|
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; |
|
$body.=&path_to_problem($urlp,$LaTeXwidth); |
|
$body.='\vskip 1 mm '.$answer.'\end{document}'; |
|
$body = &encapsulate_minipage($body); |
|
$texversion.=$body; |
|
} |
|
} |
|
if ($flag_latex_header_remove ne 'NO') { |
|
$texversion = &latex_header_footer_remove($texversion); |
|
} else { |
|
$texversion =~ s/\\end{document}//; |
|
} |
|
if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') { |
|
$texversion=&IndexCreation($texversion,$urlp); |
|
} |
|
if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URpL'} eq 'yes') { |
|
$texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /; |
|
} |
|
$result.=$texversion; |
|
$flag_latex_header_remove = 'YES'; |
|
} elsif ($urlp=~/\.(sequence|page)$/) { |
|
$result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent '; |
|
} |
|
} |
} |
if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} |
# End construction space sequence. |
$result .= '\end{document}'; |
|
} elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} |
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} |
Line 1713 ENDPART
|
Line 1759 ENDPART
|
$selectionmade, |
$selectionmade, |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
} |
} |
if ($numberofcolumns == 1) { |
#if ($numberofcolumns == 1) { |
$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; |
$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; |
$result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; |
$result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; |
$result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; |
$result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; |
$result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; |
$result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; |
} |
#} |
|
|
#-- writing .tex file in prtspool |
#-- writing .tex file in prtspool |
my $temp_file; |
my $temp_file; |
Line 1945 sub print_resources {
|
Line 1991 sub print_resources {
|
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 $HeaderLine = $parmhash{'print_header_format'}; |
$HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname); |
$HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname); |
&Apache::lonnet::logthis("Hdr format: $HeaderLine"); |
|
if ($current_output=~/\\documentclass/) { |
if ($current_output=~/\\documentclass/) { |
if ($columns_in_format == 1) { |
if ($columns_in_format == 1) { |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /; |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /; |
Line 2181 sub printHelper {
|
Line 2226 sub printHelper {
|
my $paramHash; |
my $paramHash; |
|
|
if ($resourceTitle) { |
if ($resourceTitle) { |
push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (".&mt('what you just saw on the screen').")", 'current_document', 'PAGESIZE']; |
push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE']; |
} |
} |
|
|
# Useful filter strings |
# Useful filter strings |
Line 2199 sub printHelper {
|
Line 2244 sub printHelper {
|
|
|
|
|
# If we're in a sequence... |
# If we're in a sequence... |
|
my $startnew=&mt('Start new page<br />before selected'); |
if (($helper->{'VARS'}->{'construction'} ne '1') && |
if (($helper->{'VARS'}->{'construction'} ne '1') && |
|
|
$helper->{VARS}->{'postdata'} && |
$helper->{VARS}->{'postdata'} && |
$helper->{VARS}->{'assignment'}) { |
$helper->{VARS}->{'assignment'}) { |
# Allow problems from sequence |
# Allow problems from sequence |
push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('in')." <b><i>$sequenceTitle</i></b>", 'map_problems', 'CHOOSE_PROBLEMS']; |
push @{$printChoices}, [&mt('Selected <b>Problems</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS']; |
# Allow all resources from sequence |
# Allow all resources from sequence |
push @{$printChoices}, ["<b>".&mt('Resources')."</b> ".&mt('in')." <b><i>$sequenceTitle</i></b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; |
push @{$printChoices}, [&mt('Selected <b>Resources</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; |
|
|
my $helperFragment = <<HELPERFRAGMENT; |
my $helperFragment = <<HELPERFRAGMENT; |
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print"> |
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print"> |
<message>(mark them then click "next" button) <br /></message> |
|
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
closeallpages="1"> |
closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isProblem;</filterfunc> |
<filterfunc>return $isProblem;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='Newpage' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
|
|
<state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print"> |
<state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print"> |
<message>(mark them then click "next" button) <br /></message> |
|
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
closeallpages="1"> |
closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isNotMap;</filterfunc> |
<filterfunc>return $isNotMap;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='Newpage' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
HELPERFRAGMENT |
HELPERFRAGMENT |
Line 2242 HELPERFRAGMENT
|
Line 2285 HELPERFRAGMENT
|
if ($perm{'pfo'} && |
if ($perm{'pfo'} && |
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
|
|
push @{$printChoices}, ['<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']; |
push @{$printChoices}, ['<b>Resources</b> from <b>entire course</b>', 'all_resources', 'ALL_RESOURCES']; |
push @{$printChoices}, ['Selected <b>Resources</b> from <b>entire course</b>', 'all_resources', 'ALL_RESOURCES']; |
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
<state name="ALL_PROBLEMS" title="Select Problem(s) to print"> |
<state name="ALL_PROBLEMS" title="Select Problem(s) to print"> |
<message>(mark them then click "next" button) <br /></message> |
|
<resource variable="RESOURCES" toponly='0' multichoice="1" |
<resource variable="RESOURCES" toponly='0' multichoice="1" |
suppressEmptySequences='0' addstatus="1" closeallpages="1"> |
suppressEmptySequences='0' addstatus="1" closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isProblemOrMap;</filterfunc> |
<filterfunc>return $isProblemOrMap;</filterfunc> |
<choicefunc>return $isNotMap;</choicefunc> |
<choicefunc>return $isNotMap;</choicefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='Newpage' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
<state name="ALL_RESOURCES" title="Select Resource(s) to print"> |
<state name="ALL_RESOURCES" title="Select Resource(s) to print"> |
<message>(Mark them then click "next" button) <br /> </message> |
|
<resource variable="RESOURCES" toponly='0' multichoice='1' |
<resource variable="RESOURCES" toponly='0' multichoice='1' |
suppressEmptySequences='0' addstatus='1' closeallpages='1'> |
suppressEmptySequences='0' addstatus='1' closeallpages='1'> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isNotMap; </filterfunc> |
<filterfunc>return $isNotMap; </filterfunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='NewPage' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
ALL_PROBLEMS |
ALL_PROBLEMS |
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('selected students')."</b>", 'problems_for_students', 'CHOOSE_STUDENTS']; |
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}, ["<b>".&mt('Problems')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('anonymous students')."</b>", 'problems_for_anon', 'CHOOSE_ANON1']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>anonymous students</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
} |
} |
|
|
# resource_selector will hold a few states that: |
# resource_selector will hold a few states that: |
Line 2291 ALL_PROBLEMS
|
Line 2332 ALL_PROBLEMS
|
<filterfunc>return $isProblem;</filterfunc> |
<filterfunc>return $isProblem;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='New Page' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
Line 2441 CHOOSE_ANON1
|
Line 2482 CHOOSE_ANON1
|
|
|
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, ["<b>".&mt('Resources')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('selected students')."</b>", 'resources_for_students', 'CHOOSE_STUDENTS1']; |
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}, ["<b>".&mt('Resources')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('anonymous students')."</b>", 'resources_for_anon', 'CHOOSE_ANON2']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>anonymous students</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
} |
} |
|
|
|
|
Line 2455 CHOOSE_ANON1
|
Line 2496 CHOOSE_ANON1
|
<filterfunc>return $isNotMap;</filterfunc> |
<filterfunc>return $isNotMap;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='Newpage' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
<state name="PRINT_FORMATTING" title="Format of the print job"> |
<state name="PRINT_FORMATTING" title="Format of the print job"> |
Line 2548 CHOOSE_ANON2
|
Line 2589 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 ((((&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/') { |
push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from current subdirectory')." <b><i>$subdir</i></b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
|
|
my $f = '$filename'; |
my $f = '$filename'; |
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>$subdir</small></b> to print"> |
<message>(mark them then click "next" button) <br /></message> |
|
<files variable="FILES" multichoice='1'> |
<files variable="FILES" multichoice='1'> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filechoice>return '$subdir';</filechoice> |
<filechoice>return '$subdir';</filechoice> |
Line 2574 CHOOSE_FROM_SUBDIR
|
Line 2615 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'}) { |
push @$printChoices, ["<b>Resources</b> from <b>selected sequence</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'}; |
#Escape apostrophes and backslashes for Perl |
#Escape apostrophes and backslashes for Perl |
Line 2599 CHOOSE_FROM_SUBDIR
|
Line 2640 CHOOSE_FROM_SUBDIR
|
<filterfunc>return $isProblem</filterfunc> |
<filterfunc>return $isProblem</filterfunc> |
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl> |
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='Newpage' variable='FINISHPAGE' /> |
<option text='$startnew' variable='FINISHPAGE' /> |
</resource> |
</resource> |
</state> |
</state> |
CHOOSE_FROM_ANY_SEQUENCE |
CHOOSE_FROM_ANY_SEQUENCE |
Line 2925 sub new {
|
Line 2966 sub new {
|
# $helper->{VARS} to figure out whether the columns are one or two |
# $helper->{VARS} to figure out whether the columns are one or two |
$self->{'formatvar'} = shift; |
$self->{'formatvar'} = shift; |
|
|
# The state to transition to after selection, or after discovering |
|
# the cols are not set to 1 |
|
$self->{NEXTSTATE} = shift; |
$self->{NEXTSTATE} = shift; |
bless($self); |
bless($self); |
return $self; |
return $self; |
Line 2939 sub render {
|
Line 2979 sub render {
|
my $var = $self->{'variable'}; |
my $var = $self->{'variable'}; |
|
|
if (defined $self->{ERROR_MSG}) { |
if (defined $self->{ERROR_MSG}) { |
$result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br />'; |
$result .= '<br /><span class="LC_error">' . $self->{ERROR_MSG} . '</span><br />'; |
} |
} |
|
|
my $width = 18; |
|
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
if (substr($format, 2, 1) ne '1') { |
|
$width = 9; |
# Use format to get sensible defaults for the margins: |
|
|
|
|
|
my ($laystyle, $cols, $papersize) = split(/\|/, $format); |
|
($papersize) = split(/ /, $papersize); |
|
|
|
|
|
if ($laystyle eq 'L') { |
|
$laystyle = 'album'; |
|
} else { |
|
$laystyle = 'book'; |
|
} |
|
|
|
|
|
my %size; |
|
($size{'width_and_units'}, |
|
$size{'height_and_units'}, |
|
$size{'margin_and_units'})= |
|
&Apache::lonprintout::page_format($papersize, $laystyle, $cols); |
|
|
|
foreach my $dimension ('width','height','margin') { |
|
($size{$dimension},$size{$dimension.'_unit'}) = |
|
split(/ +/, $size{$dimension.'_and_units'},2); |
|
|
|
foreach my $unit ('cm','in') { |
|
$size{$dimension.'_options'} .= '<option '; |
|
if ($size{$dimension.'_unit'} eq $unit) { |
|
$size{$dimension.'_options'} .= 'selected="selected" '; |
|
} |
|
$size{$dimension.'_options'} .= '>'.$unit.'</option>'; |
|
} |
} |
} |
|
|
$result .= <<ELEMENTHTML; |
$result .= <<ELEMENTHTML; |
|
|
<p>How should the column be formatted?</p> |
|
|
|
|
<p>How should each column be formatted?</p> |
|
|
<table cellpadding='3'> |
<table cellpadding='3'> |
<tr> |
<tr> |
<td align='right'><b>Width</b>:</td> |
<td align='right'><b>Width</b>:</td> |
<td align='left'><input type='text' name='$var.width' value='$width' size='4'></td> |
<td align='left'><input type='text' name='$var.width' value="$size{'width'}" size='4' /></td> |
<td align='left'> |
<td align='left'> |
<select name='$var.widthunit'> |
<select name='$var.widthunit'> |
<option>cm</option><option>in</option> |
$size{'width_options'} |
</select> |
</select> |
</td> |
</td> |
</tr> |
</tr> |
<tr> |
<tr> |
<td align='right'><b>Height</b>:</td> |
<td align='right'><b>Height</b>:</td> |
<td align='left'><input type='text' name="$var.height" value="25.9" size='4'></td> |
<td align='left'><input type='text' name="$var.height" value="$size{'height'}" size='4' /></td> |
<td align='left'> |
<td align='left'> |
<select name='$var.heightunit'> |
<select name='$var.heightunit'> |
<option>cm</option><option>in</option> |
$size{'height_options'} |
</select> |
</select> |
</td> |
</td> |
</tr> |
</tr> |
<tr> |
<tr> |
<td align='right'><b>Left margin</b>:</td> |
<td align='right'><b>Left margin</b>:</td> |
<td align='left'><input type='text' name='$var.lmargin' value='-1.5' size='4'></td> |
<td align='left'><input type='text' name='$var.lmargin' value="$size{'margin'}" size='4' /></td> |
<td align='left'> |
<td align='left'> |
<select name='$var.lmarginunit'> |
<select name='$var.lmarginunit'> |
<option>cm</option><option>in</option> |
$size{'margin_options'} |
</select> |
</select> |
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
|
|
<p>Hint: Some instructors like to leave scratch space for the student by |
<!--<p>Hint: Some instructors like to leave scratch space for the student by |
making the width much smaller than the width of the page.</p> |
making the width much smaller than the width of the page.</p>--> |
|
|
ELEMENTHTML |
ELEMENTHTML |
|
|
Line 2996 sub preprocess {
|
Line 3067 sub preprocess {
|
my $helper = Apache::lonhelper::getHelper(); |
my $helper = Apache::lonhelper::getHelper(); |
|
|
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
if (substr($format, 2, 1) ne '1') { |
|
$helper->changeState($self->{NEXTSTATE}); |
|
} |
|
|
|
return 1; |
return 1; |
} |
} |
Line 3020 sub postprocess {
|
Line 3088 sub postprocess {
|
# /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed |
# /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed |
# by an optional period, followed by digits, ending the string |
# by an optional period, followed by digits, ending the string |
|
|
if ($width !~ /^-?[0-9]+(\.[0-9]*)?$/) { |
if ($width !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
$error .= "Invalid width; please type only a number.<br />\n"; |
$error .= "Invalid width; please type only a number.<br />\n"; |
} |
} |
if ($height !~ /^-?[0-9]+(\.[0-9]*)?$/) { |
if ($height !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
$error .= "Invalid height; please type only a number.<br />\n"; |
$error .= "Invalid height; please type only a number.<br />\n"; |
} |
} |
if ($lmargin !~ /^-?[0-9]+(\.[0-9]*)?$/) { |
if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
$error .= "Invalid left margin; please type only a number.<br />\n"; |
$error .= "Invalid left margin; please type only a number.<br />\n"; |
} |
} |
|
|