version 1.554, 2009/06/02 12:20:14
|
version 1.572, 2010/02/28 22:38:45
|
Line 1
|
Line 1
|
|
# |
# The LearningOnline Network |
# The LearningOnline Network |
# Printout |
# Printout |
# |
# |
Line 26
|
Line 27
|
# |
# |
# |
# |
package Apache::lonprintout; |
package Apache::lonprintout; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonxml; |
use Apache::lonxml; |
Line 70 my $ssi_last_error; # The error text fr
|
Line 70 my $ssi_last_error; # The error text fr
|
my $ssi_retry_count = 5; # Some arbitrary value. |
my $ssi_retry_count = 5; # Some arbitrary value. |
|
|
|
|
|
# Font size: |
|
|
|
my $font_size = 'normalsize'; # Default is normalsize... |
|
|
|
#---------------------------- Helper helpers. ------------------------- |
|
|
|
# Returns the text needd for a student chooser. |
|
# that text must still be parsed by the helper xml parser. |
|
# Parameters: |
|
# this_state - State name of the chooser. |
|
# sort_choice - variable to hold the sorting choice. |
|
# variable - Name of variable to hold students. |
|
# next_state - State after chooser. |
|
|
|
|
|
sub generate_student_chooser { |
|
my ($this_state, |
|
$sort_choice, |
|
$variable, |
|
$next_state) = @_; |
|
my $result = <<CHOOSE_STUDENTS; |
|
<state name="$this_state" title="Select Students and Resources"> |
|
<message><b>Select sorting order of printout</b> </message> |
|
|
|
<choices variable="$sort_choice"> |
|
<choice computer='0'>Sort by section then student</choice> |
|
<choice computer='1'>Sort by students across sections.</choice> |
|
</choices> |
|
|
|
<message><br /><hr /><br /> </message> |
|
<student multichoice='1' |
|
variable="$variable" |
|
nextstate="$next_state" |
|
coursepersonnel="1" /> |
|
</state> |
|
|
|
CHOOSE_STUDENTS |
|
|
|
return $result; |
|
} |
|
|
|
# Generate the text needed for a resource chooser given the top level of |
|
# the sequence/page |
|
# |
|
# Parameters: |
|
# this_state - State name of the chooser. |
|
# prompt_text - Text to use to prompt user. |
|
# resource_options - Resource tag options e.g. |
|
# "multichoice='1', toponly='1', addstatus='1'" |
|
# that control the selection and appearance of the |
|
# resource selector. |
|
# variable - Name of the variable to hold the choice |
|
# next_state - Name of the next state the helper should transition |
|
# to |
|
# top_url - Top level URL within which to make the selector. |
|
# If empty the top level sequence is shown. |
|
# filter - How to filter the resources. |
|
# value_func - <valuefunc> function. |
|
# choice_func - If not empty generates a <choicefunc> with this function. |
|
# start_new_option |
|
# - Fragment appended after valuefunc. |
|
# |
|
# |
|
sub generate_resource_chooser { |
|
my ($this_state, |
|
$prompt_text, |
|
$resource_options, |
|
$variable, |
|
$next_state, |
|
$top_url, |
|
$filter, |
|
$choice_func, |
|
$value_func, |
|
$start_new_option) = @_; |
|
|
|
my $result = <<CHOOSE_RESOURCES; |
|
<state name="$this_state" title="$prompt_text"> |
|
<resource variable="$variable" $resource_options |
|
closeallpages="1"> |
|
<nextstate>$next_state</nextstate> |
|
<filterfunc>return $filter;</filterfunc> |
|
CHOOSE_RESOURCES |
|
if ($choice_func ne '') { |
|
$result .= "<choicefunc>return $choice_func;</choicefunc>"; |
|
} |
|
if ($top_url ne '') { |
|
$result .= "<mapurl>$top_url</mapurl>"; |
|
} |
|
$result .= <<CHOOSE_RESOURCES; |
|
<valuefunc>return $value_func;</valuefunc> |
|
$start_new_option |
|
</resource> |
|
</state> |
|
CHOOSE_RESOURCES |
|
|
|
return $result; |
|
} |
|
# |
|
# Generate the helper XML for a code choice helper dialog: |
|
# |
|
# Paramters: |
|
# $helper - Reference to the helper. |
|
# $state - Name of the state for the chooser. |
|
# $next_state - Name fo the state to follow the chooser. |
|
# $bubble_types - Populates the bubble sheet type dropt down. |
|
# $code_selections - Provides set of code choices that have been used |
|
# $saved_codes - Provides the list of saved codes. |
|
# |
|
# Returns; |
|
# The Xml of the code chooser. |
|
# |
|
sub generate_code_selector { |
|
my ($helper, |
|
$state, |
|
$next_state, |
|
$bubble_types, |
|
$code_selections, |
|
$saved_codes) = @_; # Unpack the parameters. |
|
|
|
my $result = <<CHOOSE_ANON1; |
|
<state name="$state" title="Specify CODEd Assignments"> |
|
<nextstate>$next_state</nextstate> |
|
<message><h4>Fill out one of the forms below</h4></message> |
|
<message><br /><hr /> <br /></message> |
|
<message><h3>Generate new CODEd Assignments</h3></message> |
|
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message> |
|
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
|
<validator> |
|
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
|
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
|
!\$helper->{'VARS'}{'SINGLE_CODE'} && |
|
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
|
return "You need to specify the number of assignments to print"; |
|
} |
|
return undef; |
|
</validator> |
|
</string> |
|
<message></td></tr><tr><td></message> |
|
<message><b>Names to save the CODEs under for later:</b></message> |
|
<message></td><td></message> |
|
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
|
<message></td></tr><tr><td></message> |
|
<message><b>Bubble sheet type:</b></message> |
|
<message></td><td></message> |
|
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
|
$bubble_types |
|
</dropdown> |
|
<message></td></tr><tr><td colspan="2"></td></tr><tr><td></message> |
|
<message></td></tr><tr><td></table></message> |
|
<message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message> |
|
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
|
<string variable="SINGLE_CODE" size="10"> |
|
<validator> |
|
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
|
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
|
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
|
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
|
\$helper->{'VARS'}{'CODE_OPTION'}); |
|
} else { |
|
return undef; # Other forces control us. |
|
} |
|
</validator> |
|
</string> |
|
<message></td></tr><tr><td></message> |
|
$code_selections |
|
<message></td></tr></table></message> |
|
<message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message> |
|
<message><b>Select saved CODEs:</b></message> |
|
<message></td><td></message> |
|
<dropdown variable="REUSE_OLD_CODES"> |
|
$saved_codes |
|
</dropdown> |
|
<message></td></tr></table></message> |
|
</state> |
|
CHOOSE_ANON1 |
|
|
|
return $result; |
|
} |
|
|
|
#----------------------------------------------------------------------- |
|
|
|
|
# Fetch the contents of a resource, uninterpreted. |
# Fetch the contents of a resource, uninterpreted. |
# This is used here to fetch a latex file to be included |
# This is used here to fetch a latex file to be included |
Line 100 sub fetch_raw_resource {
|
Line 281 sub fetch_raw_resource {
|
sub annotate { |
sub annotate { |
my ($symb) = @_; |
my ($symb) = @_; |
|
|
my $annotation_text = &Apache::admannotations::get_annotation($symb, 1); |
my $annotation_text = &Apache::loncommon::get_annotation($symb, 1); |
|
|
|
|
my $result = ""; |
my $result = ""; |
Line 114 sub annotate {
|
Line 295 sub annotate {
|
return $result; |
return $result; |
} |
} |
|
|
|
# |
|
# Set a global document font size: |
|
# This is done by replacing \begin{document} |
|
# with \begin{document}{\some-font-directive |
|
# and \end{document} with |
|
# }\end{document |
|
# |
|
sub set_font_size { |
|
|
|
my ($text) = @_; |
|
|
|
$text =~ s/\\begin{document}/\\begin{document}{\\$font_size/; |
|
$text =~ s/\\end{document}/}\\end{document}/; |
|
return $text; |
|
|
|
|
|
} |
|
|
# include_pdf - PDF files are included into the |
# include_pdf - PDF files are included into the |
# output as follows: |
# output as follows: |
# - The PDF, if necessary, is replicated. |
# - The PDF, if necessary, is replicated. |
Line 175 sub include_pdf {
|
Line 374 sub include_pdf {
|
|
|
|
|
# |
# |
# ssi_with_retries - Does the server side include of a resource. |
# ssi_with_retries- Does the server side include of a resource. |
# if the ssi call returns an error we'll retry it up to |
# if the ssi call returns an error we'll retry it up to |
# the number of times requested by the caller. |
# the number of times requested by the caller. |
# If we still have a proble, no text is appended to the |
# If we still have a proble, no text is appended to the |
Line 208 sub include_pdf {
|
Line 407 sub include_pdf {
|
sub ssi_with_retries { |
sub ssi_with_retries { |
my ($resource, $retries, %form) = @_; |
my ($resource, $retries, %form) = @_; |
|
|
|
my $target = $form{'grade_target'}; |
|
my $aom = $form{'answer_output_mode'}; |
|
|
|
|
|
|
my ($content, $response) = &Apache::loncommon::ssi_with_retries($resource, $retries, %form); |
my ($content, $response) = &Apache::loncommon::ssi_with_retries($resource, $retries, %form); |
if (!$response->is_success) { |
if (!$response->is_success) { |
Line 296 sub printf_style_subst {
|
Line 499 sub printf_style_subst {
|
sub format_page_header { |
sub format_page_header { |
my ($width, $format, $assignment, $course, $student, $section) = @_; |
my ($width, $format, $assignment, $course, $student, $section) = @_; |
|
|
|
|
|
|
$width = &recalcto_mm($width); # Get width in mm. |
$width = &recalcto_mm($width); # Get width in mm. |
|
my $chars_per_line = int($width/1.6); # Character/textline. |
|
|
# Default format? |
# Default format? |
|
|
if ($format eq '') { |
if ($format eq '') { |
Line 311 sub format_page_header {
|
Line 517 sub format_page_header {
|
# but only truncate the course. |
# but only truncate the course. |
# - Allow the assignment to be 2 lines (wrapped). |
# - Allow the assignment to be 2 lines (wrapped). |
# |
# |
my $chars_per_line = $width/2; # Character/textline. |
|
|
|
|
|
|
|
|
|
my $name_length = int($chars_per_line *3 /4); |
my $name_length = int($chars_per_line *3 /4); |
my $sec_length = int($chars_per_line / 5); |
my $sec_length = int($chars_per_line / 5); |
Line 349 sub format_page_header {
|
Line 554 sub format_page_header {
|
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout '); |
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout '); |
$format =~ s/\\\\\s\\\\\s/$testPrintout/; |
$format =~ s/\\\\\s\\\\\s/$testPrintout/; |
} |
} |
|
# |
|
# We're going to trust LaTeX to break lines appropriately, but |
|
# we'll truncate anything that's more than 3 lines worth of |
|
# text. This is also assuming (which will probably end badly) |
|
# nobody's going to embed LaTeX control sequences in the title |
|
# header or rather that those control sequences won't get broken |
|
# by the stuff below. |
|
# |
|
my $total_length = 3*$chars_per_line; |
|
if (length($format) > $total_length) { |
|
$format = substr($format, 0, $total_length); |
|
} |
|
|
|
|
return $format; |
return $format; |
|
|
Line 922 sub old_character_chart {
|
Line 1139 sub old_character_chart {
|
$result =~ s/&(rdquo|#8221);/\'\'/g; |
$result =~ s/&(rdquo|#8221);/\'\'/g; |
|
|
|
|
|
|
return $result; |
return $result; |
} |
} |
|
|
Line 1059 sub page_format_transformation {
|
Line 1277 sub page_format_transformation {
|
|
|
if ($selectionmade eq '4') { |
if ($selectionmade eq '4') { |
if ($choice eq 'all_problems') { |
if ($choice eq 'all_problems') { |
$assignment='Problems from the Whole Course'; |
$assignment=&mt('Problems from the Whole Course'); |
} else { |
} else { |
$assignment='Resources from the Whole Course'; |
$assignment=&mt('Resources from the Whole Course'); |
} |
} |
} else { |
} else { |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
Line 1283 sub unsupported {
|
Line 1501 sub unsupported {
|
return $result; |
return $result; |
} |
} |
|
|
|
# |
|
# Map from helper layout style to the book/album: |
|
# |
|
sub map_laystyle { |
|
my ($laystyle) = @_; |
|
if ($laystyle eq 'L') { |
|
$laystyle='album'; |
|
} else { |
|
$laystyle='book'; |
|
} |
|
return $laystyle; |
|
} |
|
|
|
sub print_page_in_course { |
|
my ($helper, $rparmhash, $currentURL, $resources) = @_; |
|
my %parmhash = %$rparmhash; |
|
my @page_resources = @$resources; |
|
my $mode = $helper->{'VARS'}->{'LATEX_TYPE'}; |
|
my $symb = $helper->{'VARS'}->{'symb'}; |
|
|
|
|
|
my $format_from_helper = $helper->{'VARS'}->{'FORMAT'}; |
|
|
|
|
|
my @temporary_array=split /\|/,$format_from_helper; |
|
my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array; |
|
$laystyle = &map_laystyle($laystyle); |
|
my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle, |
|
$numberofcolumns); |
|
my $LaTeXwidth=&recalcto_mm($textwidth); |
|
|
|
|
|
if ($mode ne '') {$mode='\\'.$mode} |
|
my $result = &print_latex_header($mode); |
|
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
|
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
|
my $title=&Apache::lonnet::gettitle($symb); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
} else { |
|
$result.=$currentURL; |
|
} |
|
$result .= '\\\\'; |
|
|
|
if ($helper->{'VARS'}->{'style_file'}=~/\w/) { |
|
&Apache::lonnet::appenv({'construct.style' => |
|
$helper->{'VARS'}->{'style_file'}}); |
|
} elsif ($env{'construct.style'}) { |
|
&Apache::lonnet::delenv('construct.style'); |
|
} |
|
|
|
# First is the overall page description. This is then followed by the |
|
# components of the page. Each of which must be printed independently. |
|
my $the_page = shift(@page_resources); |
|
|
|
|
|
foreach my $resource (@page_resources) { |
|
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
|
$result .= $resource->title() . '\\\\'; |
|
|
|
# Recurse if a .page: |
|
|
|
if ($resource_src =~ /.page$/i) { |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my @page_resources = $navmap->retrieveResources($resource_src); |
|
$result .= &print_page_in_course($helper, $rparmhash, |
|
$resource_src, \@page_resources); |
|
} |
|
# these resources go through the XML transformer: |
|
|
|
elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm\xhtml|xhtm)$/) { |
|
my $urlp = &Apache::lonnet::clutter($resource_src); |
|
my %form; |
|
my %moreenv; |
|
|
|
&Apache::lonxml::remember_problem_counter(); |
|
$moreenv{'request.filename'}=$urlp; |
|
if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';} |
|
|
|
$form{'grade_target'} = 'tex'; |
|
$form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); |
|
$form{'pdfFormFiels'} = $pdfFormFields; # |
|
$form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; |
|
|
|
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
|
$form{'suppress_tries'}=$parmhash{'suppress_tries'}; |
|
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
|
$form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'}; |
|
$form{'print_annotations'}=$helper->{'VARS'}->{'PRINT_ANNOTATIONS'}; |
|
if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') || |
|
($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) { |
|
$form{'problem_split'}='yes'; |
|
} |
|
my $rndseed = time; |
|
if ($helper->{'VARS'}->{'curseed'}) { |
|
$rndseed=$helper->{'VARS'}->{'curseed'}; |
|
} |
|
$form{'rndseed'}=$rndseed; |
|
&Apache::lonnet::appenv(\%moreenv); |
|
|
|
&Apache::lonxml::clear_problem_counter(); |
|
|
|
my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); |
|
|
|
|
|
# current document with answers.. no need to encap in minipage |
|
# since there's only one answer. |
|
|
|
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
|
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
|
my %answerform = %form; |
|
|
|
|
|
$answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; |
|
$answerform{'grade_target'}='answer'; |
|
$answerform{'answer_output_mode'}='tex'; |
|
$answerform{'rndseed'}=$rndseed; |
|
if ($helper->{'VARS'}->{'probstatus'} eq 'exam') { |
|
$answerform{'problemtype'}='exam'; |
|
} |
|
$resources_printed .= $urlp.':'; |
|
my $answer=&ssi_with_retries($urlp,$ssi_retry_count, %answerform); |
|
|
|
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
|
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
|
} else { |
|
$texversion= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
|
if ($helper->{'VARS'}->{'construction'} ne '1') { |
|
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($urlp,$LaTeXwidth); |
|
} else { |
|
$texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; |
|
my $URLpath=$urlp; |
|
$URLpath=~s/~([^\/]+)/public_html\/$1\/$1/; |
|
$texversion.=&path_to_problem($URLpath,$LaTeXwidth); |
|
} |
|
$texversion.='\vskip 1 mm '.$answer.'\end{document}'; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
# Print annotations. |
|
|
|
|
|
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
|
my $annotation .= &annotate($currentURL); |
|
$texversion =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/; |
|
} |
|
|
|
if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') { |
|
$texversion=&IndexCreation($texversion,$currentURL); |
|
} |
|
if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') { |
|
$texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$currentURL| \\strut\\\\\\strut /; |
|
|
|
} |
|
$texversion = &latex_header_footer_remove($texversion); |
|
|
|
# the first remaining line is a comment from londefdef the second |
|
# line seems to be an extraneous \vskip 1mm \\\\ : |
|
# (imperfect removal from header_footer_remove? |
|
|
|
$texversion =~ s/\\vskip 1mm \\\\\\\\//; |
|
|
|
$result .= $texversion; |
|
if ($currentURL=~m/\.page\s*$/) { |
|
($result,$numberofcolumns) = &page_cleanup($result); |
|
} |
|
} |
|
} |
|
|
|
$result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}'; |
|
return $result; |
|
} |
|
|
|
|
# |
# |
# List of recently generated print files |
# List of recently generated print files |
Line 1359 sub recently_generated {
|
Line 1756 sub recently_generated {
|
# A reference to a page break hash. |
# A reference to a page break hash. |
# |
# |
# |
# |
#use Data::Dumper; |
# use Data::Dumper; |
#sub dump_helper_vars { |
# sub dump_helper_vars { |
# my ($helper) = @_; |
# my ($helper) = @_; |
# my $helpervars = Dumper($helper->{'VARS'}); |
# my $helpervars = Dumper($helper->{'VARS'}); |
# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); |
# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); |
Line 1375 sub get_page_breaks {
|
Line 1772 sub get_page_breaks {
|
} |
} |
return %page_breaks; |
return %page_breaks; |
} |
} |
|
# |
|
# Returns text to insert for any extra vskip prior to the resource. |
|
# Parameters: |
|
# helper - Reference to the helper object driving the printout. |
|
# resource - Identifies the resource about to be printed. |
|
# |
|
# This is done as follows: |
|
# POSSIBLE_RESOURCES has the list of possible resources. |
|
# EXTRASPACE has the list of extra space values. |
|
# EXTRASPACE_UNITS is the set of resources for which the units are |
|
# mm. All others are 'in'. |
|
# |
|
# The resource is found in the POSSIBLE_RESOURCES to get the index |
|
# of the EXTRASPACE value. |
|
# |
|
# In order to speed this up for lengthy printouts, the first time, |
|
# POSSIBLE_RESOURCES is turned into a look up hash and |
|
# EXTRASPACE is turned into an array. |
|
# |
|
|
|
|
|
my %possible_resources; |
|
my %extraspace_mm; |
|
my @extraspace; |
|
my $skips_loaded = 0; |
|
|
|
# Function to load the skips hash and array |
|
|
|
sub load_skips { |
|
|
|
my ($helper) = @_; |
|
|
|
# If this is the first time, unrap the resources and extra spaces: |
|
|
|
if (!$skips_loaded) { |
|
@extraspace = (split(/\|\|\|/, $helper->{'VARS'}->{'EXTRASPACE'})); |
|
my @resource_list = (split(/\|\|\|/, $helper->{'VARS'}->{'POSSIBLE_RESOURCES'})); |
|
my $i = 0; |
|
foreach my $resource (@resource_list) { |
|
$possible_resources{$resource} = $i; |
|
$i++; |
|
} |
|
foreach my $mm_resource (split(/\|\|\|/, $helper->{'VARS'}->{'EXTRASPACE_UNITS'})) { |
|
$extraspace_mm{$mm_resource} = 1; |
|
} |
|
$skips_loaded = 1; |
|
} |
|
} |
|
|
|
sub get_extra_vspaces { |
|
my ($helper, $resource) = @_; |
|
|
|
&load_skips($helper); |
|
|
|
# Lookup the resource in the possible resources hash.. that is the index |
|
# into the extraspace array that gives us either an empty string or |
|
# the number of mm to skip: |
|
|
|
my $index = $possible_resources{$resource}; |
|
my $skip = $extraspace[$index]; |
|
|
|
my $result = ''; |
|
if ($skip ne '') { |
|
my $units = 'in'; |
|
if (defined($extraspace_mm{$resource})) { |
|
$units = 'mm'; |
|
} |
|
$result = '\vskip '.$skip.' '.$units; |
|
} |
|
|
|
|
|
return $result; |
|
|
|
|
|
} |
|
|
|
# |
|
# The resource chooser part of the helper needs more than just |
|
# the value of the extraspaces var to recover the value into a text |
|
# field option. This sub produces the required format for the saved var: |
|
# specifically |
|
# ||| separated fields of the form resourcename=value |
|
# |
|
# Parameters: |
|
# $helper - Refers to the helper we are configuring |
|
# Implicit input: |
|
# $helper->{'VARS'}->{'EXTRASPACE'} - the spaces helper var has the text field |
|
# value. |
|
# $helper->{'VARS'}->{'EXTRASPACE_UNITS'} - units for the skips (checkboxes). |
|
# $helper->{'VARS'}->{'POSSIBLE_RESOURCES'} - has the list of resources. ||| |
|
# separated of course. |
|
# Implicit outputs: |
|
# $env{'form.extraspace'} |
|
# $env{'form.extraspace_units'} |
|
# |
|
sub set_form_extraspace { |
|
my ($helper) = @_; |
|
|
|
# the most convenient way to do this is to drive from the skips arrays/hash. |
|
# may not be the fastest, but this is once per print request so it's not so |
|
# speed critical: |
|
|
|
&load_skips($helper); |
|
|
|
my $result = ''; |
|
|
|
foreach my $resource (keys(%possible_resources)) { |
|
my $vskip = $extraspace[$possible_resources{$resource}]; |
|
$result .= $resource .'=' . $vskip . '|||'; |
|
} |
|
|
|
$env{'form.extraspace'} = $result; |
|
$env{'form.extraspace_units'} = $helper->{'VARS'}->{'EXTRASPACE_UNITS'}; |
|
return $result; |
|
|
|
} |
|
|
# Output a sequence (recursively if neeed) |
# Output a sequence (recursively if neeed) |
# from construction space. |
# from construction space. |
Line 1453 sub print_construction_sequence {
|
Line 1966 sub print_construction_sequence {
|
$result.=$texversion; |
$result.=$texversion; |
|
|
} elsif ($urlp=~/\.(sequence|page)$/) { |
} elsif ($urlp=~/\.(sequence|page)$/) { |
|
|
# header: |
# header: |
|
|
$result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent '; |
$result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent '; |
Line 1497 sub output_data {
|
Line 2010 sub output_data {
|
my %parmhash = %$rparmhash; |
my %parmhash = %$rparmhash; |
$ssi_error = 0; # This will be set nonzero by failing ssi's. |
$ssi_error = 0; # This will be set nonzero by failing ssi's. |
$resources_printed = ''; |
$resources_printed = ''; |
|
$font_size = $helper->{'VARS'}->{'fontsize'}; |
my $do_postprocessing = 1; |
my $do_postprocessing = 1; |
my $js = <<ENDPART; |
my $js = <<ENDPART; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 1526 sub output_data {
|
Line 2040 sub output_data {
|
ENDPART |
ENDPART |
|
|
|
|
|
# Breadcrumbs |
my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js); |
#FIXME: Choose better/different breadcrumbs?!? Links? |
|
my $brcrum = [{'href' => '', |
|
'text' => 'Helper'}, #FIXME: Different origin possible than print out helper? |
|
{'href' => '', |
|
'text' => 'Preparing Printout'}]; |
|
|
|
my $start_page = &Apache::loncommon::start_page('Preparing Printout', |
|
$js, |
|
{'bread_crumbs' => $brcrum,}); |
my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); |
my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); |
|
|
$r->print($start_page."\n<p>\n$msg\n</p>\n"); |
$r->print($start_page."\n<p>\n$msg\n</p>\n"); |
Line 1537 ENDPART
|
Line 2059 ENDPART
|
# indexed by symb and contains 1's for each break. |
# indexed by symb and contains 1's for each break. |
|
|
$env{'form.pagebreaks'} = $helper->{'VARS'}->{'FINISHPAGE'}; |
$env{'form.pagebreaks'} = $helper->{'VARS'}->{'FINISHPAGE'}; |
|
&set_form_extraspace($helper); |
$env{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; |
$env{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; |
&Apache::loncommon::store_course_settings('print', |
&Apache::loncommon::store_course_settings('print', |
{'pagebreaks' => 'scalar', |
{'pagebreaks' => 'scalar', |
|
'extraspace' => 'scalar', |
|
'extraspace_units' => 'scalar', |
'lastprinttype' => 'scalar'}); |
'lastprinttype' => 'scalar'}); |
|
|
my %page_breaks = &get_page_breaks($helper); |
my %page_breaks = &get_page_breaks($helper); |
|
|
my $format_from_helper = $helper->{'VARS'}->{'FORMAT'}; |
my $format_from_helper = $helper->{'VARS'}->{'FORMAT'}; |
Line 1549 ENDPART
|
Line 2073 ENDPART
|
my $number_of_columns = 1; #used only for pages to determine the width of the cell |
my $number_of_columns = 1; #used only for pages to determine the width of the cell |
my @temporary_array=split /\|/,$format_from_helper; |
my @temporary_array=split /\|/,$format_from_helper; |
my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array; |
my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array; |
if ($laystyle eq 'L') { |
|
$laystyle='album'; |
$laystyle = &map_laystyle($laystyle); |
} else { |
|
$laystyle='book'; |
|
} |
|
my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns); |
my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns); |
my $assignment = $env{'form.assignment'}; |
my $assignment = $env{'form.assignment'}; |
my $LaTeXwidth=&recalcto_mm($textwidth); |
my $LaTeXwidth=&recalcto_mm($textwidth); |
Line 1607 ENDPART
|
Line 2128 ENDPART
|
} |
} |
$selectionmade = 1; |
$selectionmade = 1; |
if ($cleanURL!~m|^/adm/| |
if ($cleanURL!~m|^/adm/| |
&& $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
&& $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { |
my $rndseed=time; |
my $rndseed=time; |
my $texversion=''; |
my $texversion=''; |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { |
Line 1700 ENDPART
|
Line 2221 ENDPART
|
($result,$number_of_columns) = &page_cleanup($result); |
($result,$number_of_columns) = &page_cleanup($result); |
} |
} |
} elsif ($cleanURL!~m|^/adm/| |
} elsif ($cleanURL!~m|^/adm/| |
&& $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') { |
&& $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') { |
#printing content of sequence from the construction space |
#printing content of sequence from the construction space |
|
|
|
|
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
# $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
|
$result .= &print_construction_sequence($currentURL, $helper, %form, |
$result .= &print_construction_sequence($currentURL, $helper, %form, |
$LaTeXwidth); |
$LaTeXwidth); |
$result .= '\end{document}'; |
$result .= '\end{document}'; |
Line 1715 ENDPART
|
Line 2237 ENDPART
|
$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//;} |
$resources_printed .= $currentURL.':'; |
$resources_printed .= $currentURL.':'; |
my $texversion=&ssi_with_retries($currentURL, $ssi_retry_count, %form); |
my $texversion = &ssi_with_retries($currentURL, $ssi_retry_count, %form); |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
my $annotation = &annotate($currentURL); |
my $annotation = &annotate($currentURL); |
$texversion =~ s/(\\end{document})/$annotation$1/; |
$texversion =~ s/(\\end{document})/$annotation$1/; |
Line 1737 ENDPART
|
Line 2259 ENDPART
|
} elsif ($cleanURL =~ /\.pdf$/i) { |
} elsif ($cleanURL =~ /\.pdf$/i) { |
$result .= &include_pdf($cleanURL); |
$result .= &include_pdf($cleanURL); |
$result .= '\end{document}'; |
$result .= '\end{document}'; |
|
} elsif ($cleanURL =~ /\.page$/i) { # Print page in non construction space contexts. |
|
|
|
# Determine the set of resources in the map of the page: |
|
|
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my @page_resources = $navmap->retrieveResources($cleanURL); |
|
$result .= &print_page_in_course($helper, $rparmhash, |
|
$cleanURL, \@page_resources); |
|
|
|
|
} else { |
} else { |
$result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, |
$result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, |
$helper->{'VARS'}->{'symb'}); |
$helper->{'VARS'}->{'symb'}); |
} |
} |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') or |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') or # BUGBUG |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') or # BUGBUG |
Line 1750 ENDPART
|
Line 2284 ENDPART
|
|
|
|
|
#-- produce an output string |
#-- produce an output string |
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') { |
if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') ) { |
$selectionmade = 2; |
$selectionmade = 2; |
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') { |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page')) |
|
{ |
$selectionmade = 3; |
$selectionmade = 3; |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') |
) { |
) { |
Line 1792 ENDPART
|
Line 2329 ENDPART
|
$result.="\\newpage\n"; |
$result.="\\newpage\n"; |
} |
} |
} |
} |
|
$result .= &get_extra_vspaces($helper, $master_seq[$i]); |
my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); |
my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); |
$urlp=&Apache::lonnet::clutter($urlp); |
$urlp=&Apache::lonnet::clutter($urlp); |
$form{'symb'}=$master_seq[$i]; |
$form{'symb'}=$master_seq[$i]; |
|
|
|
|
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem |
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem |
|
|
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} |
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} |
Line 1806 ENDPART
|
Line 2343 ENDPART
|
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
$resources_printed .= $urlp.':'; |
$resources_printed .= $urlp.':'; |
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonxml::remember_problem_counter(); |
|
if ($flag_latex_header_remove eq 'NO') { |
|
$texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF |
|
$flag_latex_header_remove = 'YES'; |
|
} |
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
if ($urlp=~/\.page$/) { |
if ($urlp=~/\.page$/) { |
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
Line 1879 ENDPART
|
Line 2420 ENDPART
|
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} |
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} |
$resources_printed .= $urlp.':'; |
$resources_printed .= $urlp.':'; |
my $texversion=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
my $annotation = &annotate($urlp); |
my $annotation = &annotate($urlp); |
$texversion =~ s/(\\end{document)/$annotation$1/; |
$texversion =~ s/(\\end{document)/$annotation$1/; |
Line 1930 ENDPART
|
Line 2471 ENDPART
|
} |
} |
$result .= '\end{document}'; |
$result .= '\end{document}'; |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') || |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') || |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students_from_page') || |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems_students') || |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems_students') || |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')){ |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')){ |
|
|
Line 1937 ENDPART
|
Line 2479 ENDPART
|
#-- prints assignments for whole class or for selected students |
#-- prints assignments for whole class or for selected students |
my $type; |
my $type; |
if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') || |
if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') || |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students_from_page') || |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems_students') ) { |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems_students') ) { |
$selectionmade=5; |
$selectionmade=5; |
$type='problems'; |
$type='problems'; |
Line 1976 ENDPART
|
Line 2519 ENDPART
|
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
|
|
#loop over students |
#loop over students |
my $flag_latex_header_remove = 'NO'; |
|
|
my $flag_latex_header_remove = 'NO'; |
my %moreenv; |
my %moreenv; |
$moreenv{'instructor_comments'}='hide'; |
$moreenv{'instructor_comments'}='hide'; |
$moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); |
$moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); |
Line 2024 ENDPART
|
Line 2568 ENDPART
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
$result .= $print_array[0].' \end{document}'; |
$result .= $print_array[0].' \end{document}'; |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') || |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') || |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') || |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) { |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) { |
my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'}; |
Line 2222 ENDPART
|
Line 2767 ENDPART
|
$URLback=~s|^/~|/priv/|; |
$URLback=~s|^/~|/priv/|; |
} |
} |
} |
} |
|
# |
|
# Final adjustment of the font size: |
|
# |
|
|
|
$result = set_font_size($result); |
|
|
#-- writing .tex file in prtspool |
#-- writing .tex file in prtspool |
my $temp_file; |
my $temp_file; |
Line 2374 sub print_resources {
|
Line 2924 sub print_resources {
|
# so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the |
# so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the |
# postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself. |
# postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself. |
# |
# |
|
my $syllabus_first = 0; |
|
|
foreach my $curresline (@{$master_seq}) { |
foreach my $curresline (@{$master_seq}) { |
if (defined $page_breaks{$curresline}) { |
if (defined $page_breaks{$curresline}) { |
if($i != 0) { |
if($i != 0) { |
$current_output.= "\\newpage\n"; |
$current_output.= "\\newpage\n"; |
} |
} |
} |
} |
|
$current_output .= &get_extra_vspaces($helper, $curresline); |
$i++; |
$i++; |
|
|
if ( !($type eq 'problems' && |
if ( !($type eq 'problems' && |
Line 2391 sub print_resources {
|
Line 2941 sub print_resources {
|
if ($res_url!~m|^ext/| |
if ($res_url!~m|^ext/| |
&& $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
&& $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
$printed .= $curresline.':'; |
$printed .= $curresline.':'; |
|
|
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonxml::remember_problem_counter(); |
|
|
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
|
|
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
# Use a copy of the hash so we don't pervert it on future loop passes. |
# Use a copy of the hash so we don't pervert it on future loop passes. |
Line 2423 sub print_resources {
|
Line 2971 sub print_resources {
|
$rendered = $header.$body; |
$rendered = $header.$body; |
} |
} |
} |
} |
|
|
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
my $url = &Apache::lonnet::clutter($res_url); |
my $url = &Apache::lonnet::clutter($res_url); |
my $annotation = &annotate($url); |
my $annotation = &annotate($url); |
$rendered =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/; |
$rendered =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/; |
} |
} |
|
my $junk; |
if ($remove_latex_header eq 'YES') { |
if ($remove_latex_header eq 'YES') { |
$rendered = &latex_header_footer_remove($rendered); |
$rendered = &latex_header_footer_remove($rendered); |
} else { |
} else { |
Line 2436 sub print_resources {
|
Line 2984 sub print_resources {
|
} |
} |
$current_output .= $rendered; |
$current_output .= $rendered; |
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
|
if ($i == 1) { |
|
$syllabus_first = 1; |
|
} |
$printed .= $curresline.':'; |
$printed .= $curresline.':'; |
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
Line 2480 sub print_resources {
|
Line 3031 sub print_resources {
|
my $header_start = ($columns_in_format == 1) ? '\lhead' |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
: '\fancyhead[LO]'; |
: '\fancyhead[LO]'; |
$header_line = $header_start.'{'.$header_line.'}'; |
$header_line = $header_start.'{'.$header_line.'}'; |
if ($current_output=~/\\documentclass/) { |
if ($current_output=~/\\documentclass/ && (!$syllabus_first)) { |
$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$header_line$namepostfix}\\vskip 5 mm /; |
|
} elsif ($syllabus_first) { |
|
|
|
$current_output =~ s/\\\\ Last updated:/Last updated:/ |
} else { |
} else { |
my $blankpages = |
my $blankpages = |
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; |
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; |
Line 2625 sub printHelper {
|
Line 3179 sub printHelper {
|
$helper->declareVar('PRINT_TYPE'); |
$helper->declareVar('PRINT_TYPE'); |
$helper->declareVar("showallfoils"); |
$helper->declareVar("showallfoils"); |
$helper->declareVar("STUDENTS"); |
$helper->declareVar("STUDENTS"); |
|
$helper->declareVar("EXTRASPACE"); |
|
|
|
|
|
|
|
|
# The page breaks can get loaded initially from the course environment: |
# The page breaks and extra spaces |
|
# 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. |
# |
# |
|
|
# $helper->{VARS}->{FINISHPAGE} = ''; |
|
|
|
&Apache::loncommon::restore_course_settings('print', |
&Apache::loncommon::restore_course_settings('print', |
{'pagebreaks' => 'scalar', |
{'pagebreaks' => 'scalar', |
|
'extraspace' => 'scalar', |
|
'extraspace_units' => 'scalar', |
'lastprinttype' => 'scalar'}); |
'lastprinttype' => 'scalar'}); |
|
|
# This will persistently load in the data we want from the |
# This will persistently load in the data we want from the |
Line 2647 sub printHelper {
|
Line 3203 sub printHelper {
|
if (!defined ($env{"form.CURRENT_STATE"})) { |
if (!defined ($env{"form.CURRENT_STATE"})) { |
|
|
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
|
$helper->{VARS}->{EXTRASPACE} = $env{'form.extraspace'}; |
|
$helper->{VARS}->{EXTRASPACE_UNITS} = $env{'form.extraspace_units'}; |
} else { |
} else { |
my $state = $env{"form.CURRENT_STATE"}; |
my $state = $env{"form.CURRENT_STATE"}; |
if ($state eq "START") { |
if ($state eq "START") { |
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
|
$helper->{VARS}->{EXTRASPACE} = $env{'form.extraspace'}; |
|
$helper->{VARS}->{EXTRASPACE_UNITS} = $env{'form.extraspace_units'}; |
|
|
} |
} |
} |
} |
|
|
Line 2702 sub printHelper {
|
Line 3263 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 { |
|
# From course space: |
|
|
if ($symb ne '') { |
if ($symb ne '') { |
($map, $id, $url) = &Apache::lonnet::decode_symb($symb); |
($map, $id, $url) = &Apache::lonnet::decode_symb($symb); |
$helper->{VARS}->{'postdata'} = |
$helper->{VARS}->{'postdata'} = |
Line 2711 sub printHelper {
|
Line 3274 sub printHelper {
|
$is_published=1; # From resource space. |
$is_published=1; # From resource space. |
} |
} |
$url = &Apache::lonnet::clutter($url); |
$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'}; |
$resourceTitle = substr($postdata, rindex($postdata, '/') + 1); |
$resourceTitle = substr($postdata, rindex($postdata, '/') + 1); |
Line 2768 sub printHelper {
|
Line 3330 sub printHelper {
|
if ($perm{'pav'}) { |
if ($perm{'pav'}) { |
$start_new_option = |
$start_new_option = |
"<option text='".&mt('Start new page<br />before selected'). |
"<option text='".&mt('Start new page<br />before selected'). |
"' variable='FINISHPAGE' />"; |
"' variable='FINISHPAGE' />". |
|
"<option text='".&mt('Extra space<br />before selected'). |
|
"' variable='EXTRASPACE' type='text' />" . |
|
"<option " . |
|
"' variable='POSSIBLE_RESOURCES' type='hidden' />". |
|
"<option text='".&mt('Space units<br />check for mm'). |
|
"' variable='EXTRASPACE_UNITS' type='checkbox' />" |
|
; |
|
|
|
|
|
} |
|
|
|
# If not construction space user can print the components of a page: |
|
|
|
my $page_ispage; |
|
my $page_title; |
|
if (!$helper->{VARS}->{'construction'}) { |
|
my $varspostdata = $helper->{VARS}->{'postdata'}; |
|
my $varsassignment = $helper->{VARS}->{'assignment'}; |
|
my $page_navmap = Apache::lonnavmaps::navmap->new(); |
|
if (defined($page_navmap)) { |
|
my @page_resources = $page_navmap->retrieveResources($url); |
|
if(defined($page_resources[0])) { |
|
$page_ispage = $page_resources[0]->is_page(); |
|
$page_title = $page_resources[0]->title(); |
|
my $resourcesymb = $page_resources[0]->symb(); |
|
my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb); |
|
if ($page_ispage) { |
|
push @{$printChoices}, |
|
[&mt('Selected [_1]Problems[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$page_title.'</i></b>'), |
|
'map_problems_in_page', |
|
'CHOOSE_PROBLEMS_PAGE']; |
|
push @{$printChoices}, |
|
[&mt('Selected [_1]Resources[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$page_title.'</i></b>'), |
|
'map_resources_in_page', |
|
'CHOOSE_RESOURCES_PAGE']; |
|
} |
|
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS_PAGE', |
|
'Select Problem(s) to print', |
|
"multichoice='1' toponly='1' addstatus='1' closeallpages='1'", |
|
'RESOURCES', |
|
'PAGESIZE', |
|
$url, |
|
$isProblem, '', $symbFilter, |
|
$start_new_option); |
|
|
|
|
|
$helperFragment .= &generate_resource_chooser('CHOOSE_RESOURCES_PAGE', |
|
'Select Resource(s) to print', |
|
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
|
'RESOURCES', |
|
'PAGESIZE', |
|
$url, |
|
$isNotMap, '', $symbFilter, |
|
$start_new_option); |
|
|
|
|
|
|
|
|
|
|
|
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment); |
|
|
|
} |
|
} |
} |
} |
|
|
if (($helper->{'VARS'}->{'construction'} ne '1' ) && |
if (($helper->{'VAR'}->{'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}, [&mt('Selected [_1]Problems[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 'map_problems', 'CHOOSE_PROBLEMS']; |
push @{$printChoices}, |
|
[&mt('Selected [_1]Problems[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), |
|
'map_problems', |
|
'CHOOSE_PROBLEMS']; |
# Allow all resources from sequence |
# Allow all resources from sequence |
push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; |
push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), |
|
'map_problems_pages', |
my $helperFragment = <<HELPERFRAGMENT; |
'CHOOSE_PROBLEMS_HTML']; |
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print"> |
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS', |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
'Select Problem(s) to print', |
closeallpages="1"> |
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
<nextstate>PAGESIZE</nextstate> |
'RESOURCES', |
<filterfunc>return $isProblem;</filterfunc> |
'PAGESIZE', |
<mapurl>$map</mapurl> |
$map, |
<valuefunc>return $symbFilter;</valuefunc> |
$isProblem, '', |
$start_new_option |
$symbFilter, |
</resource> |
$start_new_option); |
</state> |
$helperFragment .= &generate_resource_chooser('CHOOSE_PROBLEMS_HTML', |
|
'Select Resource(s) to print', |
<state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print"> |
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
'RESOURCES', |
closeallpages="1"> |
'PAGESIZE', |
<nextstate>PAGESIZE</nextstate> |
$map, |
<filterfunc>return $isNotMap;</filterfunc> |
$isNotMap, '', |
<mapurl>$map</mapurl> |
$symbFilter, |
<valuefunc>return $symbFilter;</valuefunc> |
$start_new_option); |
$start_new_option |
|
</resource> |
|
</state> |
|
HELPERFRAGMENT |
|
|
|
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment); |
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment); |
} |
} |
|
|
# If the user has pfo (print for others) allow them to print all |
# If the user has pfo (print for others) allow them to print all |
# problems and resources in the entire course, optionally for selected students |
# problems and resources in the entire course, optionally for selected students |
|
my $post_data = $helper->{VARS}->{'postdata'}; |
if ($perm{'pfo'} && !$is_published && |
if ($perm{'pfo'} && !$is_published && |
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
($post_data=~/\/res\// || $post_data =~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
|
|
push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b>'), 'all_problems', 'ALL_PROBLEMS']; |
push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b>'), 'all_problems', 'ALL_PROBLEMS']; |
push @{$printChoices}, [&mtn('Selected <b>Resources</b> from <b>entire course</b>'), 'all_resources', 'ALL_RESOURCES']; |
push @{$printChoices}, [&mtn('Selected <b>Resources</b> from <b>entire course</b>'), 'all_resources', 'ALL_RESOURCES']; |
push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b> for <b>selected people</b>'), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS']; |
push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b> for <b>selected people</b>'), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS']; |
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
my $suffixXml = <<ALL_PROBLEMS; |
<state name="ALL_PROBLEMS" title="Select Problem(s) to print"> |
|
<resource variable="RESOURCES" toponly='0' multichoice="1" |
|
suppressEmptySequences='0' addstatus="1" closeallpages="1"> |
|
<nextstate>PAGESIZE</nextstate> |
|
<filterfunc>return $isProblemOrMap;</filterfunc> |
|
<choicefunc>return $isNotMap;</choicefunc> |
|
<valuefunc>return $symbFilter;</valuefunc> |
|
$start_new_option |
|
</resource> |
|
</state> |
|
<state name="ALL_RESOURCES" title="Select Resource(s) to print"> |
|
<resource variable="RESOURCES" toponly='0' multichoice='1' |
|
suppressEmptySequences='0' addstatus='1' closeallpages='1'> |
|
<nextstate>PAGESIZE</nextstate> |
|
<filterfunc>return $isNotMap; </filterfunc> |
|
<valuefunc>return $symbFilter;</valuefunc> |
|
$start_new_option |
|
</resource> |
|
</state> |
|
<state name="ALL_PROBLEMS_STUDENTS" title="Select Problem(s) to print"> |
|
<resource variable="RESOURCES" toponly='0' multichoice="1" |
|
suppressEmptySequences='0' addstatus="1" closeallpages="1"> |
|
<nextstate>STUDENTS1</nextstate> |
|
<filterfunc>return $isProblemOrMap;</filterfunc> |
|
<choicefunc>return $isNotMap;</choicefunc> |
|
<valuefunc>return $symbFilter;</valuefunc> |
|
$start_new_option |
|
</resource> |
|
</state> |
|
<state name="STUDENTS1" title="Select People"> |
<state name="STUDENTS1" title="Select People"> |
<message><b>Select sorting order of printout</b> </message> |
<message><b>Select sorting order of printout</b> </message> |
<choices variable='student_sort'> |
<choices variable='student_sort'> |
Line 2853 HELPERFRAGMENT
|
Line 3449 HELPERFRAGMENT
|
<message><br /><hr /><br /> </message> |
<message><br /><hr /><br /> </message> |
<student multichoice='1' variable="STUDENTS" nextstate="PRINT_FORMATTING" coursepersonnel="1"/> |
<student multichoice='1' variable="STUDENTS" nextstate="PRINT_FORMATTING" coursepersonnel="1"/> |
</state> |
</state> |
|
|
ALL_PROBLEMS |
ALL_PROBLEMS |
|
&Apache::lonxml::xmlparse($r, 'helper', |
|
&generate_resource_chooser('ALL_PROBLEMS', |
|
'SelectProblem(s) to print', |
|
'multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"', |
|
'RESOURCES', |
|
'PAGESIZE', |
|
'', |
|
$isProblemOrMap, $isNotMap, |
|
$symbFilter, |
|
$start_new_option) . |
|
&generate_resource_chooser('ALL_RESOURCES', |
|
'Select Resource(s) to print', |
|
" toponly='0' multichoice='1' suppressEmptySequences='0' addstatus='1' closeallpages='1'", |
|
'RESOURCES', |
|
'PAGESIZE', |
|
'', |
|
$isNotMap,'',$symbFilter, |
|
$start_new_option) . |
|
&generate_resource_chooser('ALL_PROBLEMS_STUDENTS', |
|
'Select Problem(s) to print', |
|
'toponly="0" multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"', |
|
'RESOURCES', |
|
'STUDENTS1', |
|
'', |
|
$isProblemOrMap,'' , $symbFilter, |
|
$start_new_option) . |
|
$suffixXml |
|
); |
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]selected people[_5]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>','<b>','</b>'), 'problems_for_students', 'CHOOSE_STUDENTS']; |
|
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]CODEd assignments[_5]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>','<b>','</b>'), 'problems_for_anon', 'CHOOSE_ANON1']; |
# If we were looking at a page, allow a selection of problems from the page |
|
# 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]', |
|
'<b>', '</b>', '<b><i>'.$page_title.'</i></b>', '<b>', '</b>'), |
|
'problems_for_students_from_page', 'CHOOSE_TGT_STUDENTS_PAGE']; |
|
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from page [_3] for [_4]CODEd assignments[_5]', |
|
'<b>', '</b>', '<b><i>'.$page_title.'</i></b>', '<b>', '</b>'), |
|
'problems_for_anon_page', 'CHOOSE_ANON1_PAGE']; |
|
} |
|
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]selected people[_5]', |
|
'<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>','<b>','</b>'), |
|
'problems_for_students', 'CHOOSE_STUDENTS']; |
|
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3] for [_4]CODEd assignments[_5]', |
|
'<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>','<b>','</b>'), |
|
'problems_for_anon', 'CHOOSE_ANON1']; |
} |
} |
|
|
my $randomly_ordered_warning = |
my $randomly_ordered_warning = |
Line 2873 ALL_PROBLEMS
|
Line 3512 ALL_PROBLEMS
|
# with one state, and use REGEXPs at inclusion time to set state names |
# with one state, and use REGEXPs at inclusion time to set state names |
# and next states for better mix and match capability |
# and next states for better mix and match capability |
# |
# |
my $resource_selector=<<RESOURCE_SELECTOR; |
my $resource_selector= &generate_resource_chooser('SELECT_PROBLEMS', |
<state name="SELECT_PROBLEMS" title="Select resources to print"> |
'Select resources to print', |
$randomly_ordered_warning |
'multichoice="1" addstatus="1" closeallpages="1"', |
|
'RESOURCES', |
<nextstate>PRINT_FORMATTING</nextstate> |
'PRINT_FORMATTING', |
<message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message> |
$map, |
<resource variable="RESOURCES" multichoice="1" addstatus="1" |
$isProblem, '', $symbFilter, |
closeallpages="1"> |
$start_new_option); |
<filterfunc>return $isProblem;</filterfunc> |
$resource_selector .= <<RESOURCE_SELECTOR; |
<mapurl>$map</mapurl> |
|
<valuefunc>return $symbFilter;</valuefunc> |
|
$start_new_option |
|
</resource> |
|
</state> |
|
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
<choices variable="EMPTY_PAGES"> |
<choices variable="EMPTY_PAGES"> |
Line 2906 ALL_PROBLEMS
|
Line 3540 ALL_PROBLEMS
|
</choices> |
</choices> |
</state> |
</state> |
RESOURCE_SELECTOR |
RESOURCE_SELECTOR |
|
$resource_selector .= &generate_resource_chooser('CHOOSE_STUDENTS_PAGE', |
|
'Select Problem(s) to print', |
|
"multichoice='1' addstatus='1' closeallpages ='1'", |
|
'RESOURCES', |
|
'PRINT_FORMATTING', |
|
$url, |
|
$isProblem, '', $symbFilter, |
|
$start_new_option); |
|
|
|
|
|
# Generate student choosers. |
|
|
|
|
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS); |
|
<state name="CHOOSE_STUDENTS" title="Select Students and Resources"> |
&Apache::lonxml::xmlparse($r, 'helper', |
<message><b>Select sorting order of printout</b> </message> |
&generate_student_chooser('CHOOSE_TGT_STUDENTS_PAGE', |
<choices variable='student_sort'> |
'student_sort', |
<choice computer='0'>Sort by section then student</choice> |
'STUDENTS', |
<choice computer='1'>Sort by students across sections.</choice> |
'CHOOSE_STUDENTS_PAGE')); |
</choices> |
&Apache::lonxml::xmlparse($r, 'helper', |
<message><br /><hr /><br /> </message> |
&generate_student_chooser('CHOOSE_STUDENTS', |
<student multichoice='1' variable="STUDENTS" nextstate="SELECT_PROBLEMS" coursepersonnel="1"/> |
'student_sort', |
</state> |
'STUDENTS', |
$resource_selector |
'SELECT_PROBLEMS')); |
CHOOSE_STUDENTS |
&Apache::lonxml::xmlparse($r, 'helper', $resource_selector); |
|
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
Line 2976 CHOOSE_STUDENTS
|
Line 3622 CHOOSE_STUDENTS
|
if ($codechoice eq '') { |
if ($codechoice eq '') { |
$codechoice='<choice computer="default">Default</choice>'; |
$codechoice='<choice computer="default">Default</choice>'; |
} |
} |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1); |
my $anon1 = &generate_code_selector($helper, |
<state name="CHOOSE_ANON1" title="Specify CODEd Assignments"> |
'CHOOSE_ANON1', |
<nextstate>SELECT_PROBLEMS</nextstate> |
'SELECT_PROBLEMS', |
<message><h4>Fill out one of the forms below</h4></message> |
$codechoice, |
<message><br /><hr /> <br /></message> |
$code_selection, |
<message><h3>Generate new CODEd Assignments</h3></message> |
$namechoice) . $resource_selector; |
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message> |
|
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
|
<validator> |
&Apache::lonxml::xmlparse($r, 'helper',$anon1); |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
|
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
my $anon_page = &generate_code_selector($helper, |
!\$helper->{'VARS'}{'SINGLE_CODE'} && |
'CHOOSE_ANON1_PAGE', |
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
'SELECT_PROBLEMS_PAGE', |
return "You need to specify the number of assignments to print"; |
$codechoice, |
} |
$code_selection, |
return undef; |
$namechoice) . |
</validator> |
&generate_resource_chooser('SELECT_PROBLEMS_PAGE', |
</string> |
'Select Problem(s) to print', |
<message></td></tr><tr><td></message> |
"multichoice='1' addstatus='1' closeallpages ='1'", |
<message><b>Names to save the CODEs under for later:</b></message> |
'RESOURCES', |
<message></td><td></message> |
'PRINT_FORMATTING', |
<string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" /> |
$url, |
<message></td></tr><tr><td></message> |
$isProblem, '', $symbFilter, |
<message><b>Bubble sheet type:</b></message> |
$start_new_option); |
<message></td><td></message> |
&Apache::lonxml::xmlparse($r, 'helper', $anon_page); |
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
|
$codechoice |
|
</dropdown> |
|
<message></td></tr><tr><td colspan="2"></td></tr><tr><td></message> |
|
<message></td></tr><tr><td></table></message> |
|
<message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message> |
|
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
|
<string variable="SINGLE_CODE" size="10"> |
|
<validator> |
|
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
|
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
|
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
|
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
|
\$helper->{'VARS'}{'CODE_OPTION'}); |
|
} else { |
|
return undef; # Other forces control us. |
|
} |
|
</validator> |
|
</string> |
|
<message></td></tr><tr><td></message> |
|
$code_selection |
|
<message></td></tr></table></message> |
|
<message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message> |
|
<message><b>Select saved CODEs:</b></message> |
|
<message></td><td></message> |
|
<dropdown variable="REUSE_OLD_CODES"> |
|
$namechoice |
|
</dropdown> |
|
<message></td></tr></table></message> |
|
</state> |
|
$resource_selector |
|
CHOOSE_ANON1 |
|
|
|
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
Line 3044 CHOOSE_ANON1
|
Line 3658 CHOOSE_ANON1
|
$resource_selector=<<RESOURCE_SELECTOR; |
$resource_selector=<<RESOURCE_SELECTOR; |
<state name="SELECT_RESOURCES" title="Select Resources"> |
<state name="SELECT_RESOURCES" title="Select Resources"> |
$randomly_ordered_warning |
$randomly_ordered_warning |
|
|
<nextstate>PRINT_FORMATTING</nextstate> |
<nextstate>PRINT_FORMATTING</nextstate> |
<message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message> |
<message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message> |
<resource variable="RESOURCES" multichoice="1" addstatus="1" |
<resource variable="RESOURCES" multichoice="1" addstatus="1" |
Line 3055 CHOOSE_ANON1
|
Line 3668 CHOOSE_ANON1
|
$start_new_option |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
|
|
<state name="PRINT_FORMATTING" title="Format of the print job"> |
<state name="PRINT_FORMATTING" title="Format of the print job"> |
<nextstate>NUMBER_PER_PDF</nextstate> |
<nextstate>NUMBER_PER_PDF</nextstate> |
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
Line 3158 CHOOSE_ANON2
|
Line 3772 CHOOSE_ANON2
|
)) |
)) |
&& $helper->{VARS}->{'assignment'} eq "" |
&& $helper->{VARS}->{'assignment'} eq "" |
) { |
) { |
|
|
my $pretty_dir = &Apache::lonnet::hreflocation($subdir); |
my $pretty_dir = &Apache::lonnet::hreflocation($subdir); |
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from current subdirectory [_3]','<b>','</b>','<b><i>'.$pretty_dir.'</i></b>','<b>','</b>'), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from current subdirectory [_3]','<b>','</b>','<b><i>'.$pretty_dir.'</i></b>','<b>','</b>'), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
my $xmlfrag = <<CHOOSE_FROM_SUBDIR; |
my $xmlfrag = <<CHOOSE_FROM_SUBDIR; |
Line 3233 CHOOSE_FROM_ANY_SEQUENCE
|
Line 3846 CHOOSE_FROM_ANY_SEQUENCE
|
&addMessage('<br />' |
&addMessage('<br />' |
.'<h3>'.&mt('Print Options').'</h3>' |
.'<h3>'.&mt('Print Options').'</h3>' |
.&Apache::lonhtmlcommon::start_pick_box() |
.&Apache::lonhtmlcommon::start_pick_box() |
# .&Apache::lonhtmlcommon::row_headline() |
|
# .'<h3>'.&mt('Print Options').'</h3>' |
|
# .&Apache::lonhtmlcommon::row_closure() |
|
.&Apache::lonhtmlcommon::row_title( |
.&Apache::lonhtmlcommon::row_title( |
'<label for="ANSWER_TYPE_forminput">' |
'<label for="ANSWER_TYPE_forminput">' |
.&mt('Print Answers') |
.&mt('Print Answers') |
Line 3253 CHOOSE_FROM_ANY_SEQUENCE
|
Line 3863 CHOOSE_FROM_ANY_SEQUENCE
|
Apache::lonhelper::dropdown->new(); |
Apache::lonhelper::dropdown->new(); |
&addMessage(&Apache::lonhtmlcommon::row_closure()); |
&addMessage(&Apache::lonhtmlcommon::row_closure()); |
$startedTable = 1; |
$startedTable = 1; |
|
|
|
# |
|
# Select font size. |
|
# |
|
|
|
$helper->declareVar('fontsize'); |
|
&addMessage(&Apache::lonhtmlcommon::row_title(&mt('Font Size'))); |
|
my $xmlfrag = << "FONT_SELECTION"; |
|
|
|
|
|
<dropdown variable='fontsize' multichoice='0', allowempty='0'> |
|
<defaultvalue> |
|
return 'normalsize'; |
|
</defaultvalue> |
|
<choice computer='tiny'>Tiny</choice> |
|
<choice computer='sub/superscriptsize'>Script Size</choice> |
|
<choice computer='footnotesize'>Footnote Size</choice> |
|
<choice computer='small'>Small</choice> |
|
<choice computer='normalsize'>Normal (default)</choice> |
|
<choice computer='large'>larger than normal</choice> |
|
<choice computer='Large'>Even larger than normal</choice> |
|
<choice computer='LARGE'>Still larger than normal</choice> |
|
<choice computer='huge'>huge font size</choice> |
|
<choice computer='Huge'>Largest possible size</choice> |
|
</dropdown> |
|
FONT_SELECTION |
|
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |
|
&addMessage(&Apache::lonhtmlcommon::row_closure(1)); |
} |
} |
|
|
if ($perm{'pav'}) { |
if ($perm{'pav'}) { |
Line 3352 CHOOSE_FROM_ANY_SEQUENCE
|
Line 3990 CHOOSE_FROM_ANY_SEQUENCE
|
$paramHash->{'multichoice'} = "true"; |
$paramHash->{'multichoice'} = "true"; |
$paramHash->{'allowempty'} = "true"; |
$paramHash->{'allowempty'} = "true"; |
$paramHash->{'variable'} = "showallfoils"; |
$paramHash->{'variable'} = "showallfoils"; |
$paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ]; |
$paramHash->{'CHOICES'} = [ [&mt('Show All Foils'), "1"] ]; |
Apache::lonhelper::choices->new(); |
Apache::lonhelper::choices->new(); |
&addMessage(&Apache::lonhtmlcommon::row_closure(1)); |
&addMessage(&Apache::lonhtmlcommon::row_closure(1)); |
} |
} |
Line 3389 CHOOSE_FROM_ANY_SEQUENCE
|
Line 4027 CHOOSE_FROM_ANY_SEQUENCE
|
.qq|<a href="javascript:openbrowser('helpform','style_file_forminput','sty')">| |
.qq|<a href="javascript:openbrowser('helpform','style_file_forminput','sty')">| |
.$selectfiletext.'</a>' |
.$selectfiletext.'</a>' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title(&mt('Show all foils')) |
.&Apache::lonhtmlcommon::row_title(&mt('Show All Foils')) |
.'</message> |
.'</message> |
<choices allowempty="1" multichoice="true" variable="showallfoils"> |
<choices allowempty="1" multichoice="true" variable="showallfoils"> |
<choice computer="1"> </choice> |
<choice computer="1"> </choice> |
Line 3415 CHOOSE_FROM_ANY_SEQUENCE
|
Line 4053 CHOOSE_FROM_ANY_SEQUENCE
|
<choice computer="problem">Homework Problem</choice> |
<choice computer="problem">Homework Problem</choice> |
<choice computer="exam">Exam Problem</choice> |
<choice computer="exam">Exam Problem</choice> |
<choice computer="survey">Survey question</choice> |
<choice computer="survey">Survey question</choice> |
|
,choice computer="anonsurvey"Anonymous survey question</choice> |
</dropdown> |
</dropdown> |
PROBTYPE |
PROBTYPE |
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |
|
|
&addMessage(&Apache::lonhtmlcommon::row_closure(1)); |
&addMessage(&Apache::lonhtmlcommon::row_closure(1)); |
|
|
|
|
|
|
} |
} |
} |
} |
|
|
Line 3530 sub render {
|
Line 4170 sub render {
|
my $pdfFormLabel=&mt('PDF-Formfields'); |
my $pdfFormLabel=&mt('PDF-Formfields'); |
my $with=&mt('with Formfields'); |
my $with=&mt('with Formfields'); |
my $without=&mt('without Formfields'); |
my $without=&mt('without Formfields'); |
|
|
|
|
$result.='<h3>'.&mt('Layout Options').'</h3>' |
$result.='<h3>'.&mt('Layout Options').'</h3>' |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
Line 3675 sub render {
|
Line 4317 sub render {
|
my ($laystyle, $cols, $papersize) = split(/\|/, $format); |
my ($laystyle, $cols, $papersize) = split(/\|/, $format); |
($papersize) = split(/ /, $papersize); |
($papersize) = split(/ /, $papersize); |
|
|
|
$laystyle = &Apache::lonprintout::map_laystyle($laystyle); |
|
|
if ($laystyle eq 'L') { |
|
$laystyle = 'album'; |
|
} else { |
|
$laystyle = 'book'; |
|
} |
|
|
|
|
|
my %size; |
my %size; |
Line 3761 sub preprocess {
|
Line 4399 sub preprocess {
|
($papersize) = split(/ /, $papersize); |
($papersize) = split(/ /, $papersize); |
|
|
|
|
if ($laystyle eq 'L') { |
$laystyle = &Apache::lonprintout::map_laystyle($laystyle); |
$laystyle = 'album'; |
|
} else { |
|
$laystyle = 'book'; |
|
} |
|
# Figure out some good defaults for the print out and set them: |
# Figure out some good defaults for the print out and set them: |
|
|
my %size; |
my %size; |