version 1.572, 2010/02/28 22:38:45
|
version 1.583.2.5, 2011/09/15 16:33:57
|
Line 196 sub generate_code_selector {
|
Line 196 sub generate_code_selector {
|
<message><br /><hr /> <br /></message> |
<message><br /><hr /> <br /></message> |
<message><h3>Generate new CODEd Assignments</h3></message> |
<message><h3>Generate new CODEd Assignments</h3></message> |
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></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"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5" noproceed="1"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
!\$helper->{'VARS'}{'SINGLE_CODE'} && |
!\$helper->{'VARS'}{'SINGLE_CODE'} && |
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'} ) { |
|
|
return "You need to specify the number of assignments to print"; |
return "You need to specify the number of assignments to print"; |
} |
} |
|
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) >= 1) && |
|
(\$helper->{'VARS'}{'SINGLE_CODE'} ne '') ) { |
|
return 'Specifying number of codes to print and a specific code is not compatible'; |
|
} |
return undef; |
return undef; |
</validator> |
</validator> |
</string> |
</string> |
Line 228 sub generate_code_selector {
|
Line 233 sub generate_code_selector {
|
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
\$helper->{'VARS'}{'CODE_OPTION'}); |
\$helper->{'VARS'}{'CODE_OPTION'}); |
|
} elsif (\$helper->{'VARS'}{'SINGLE_CODE'} ne ''){ |
|
return 'Specifying a code name is incompatible with specifying number of codes.'; |
} else { |
} else { |
return undef; # Other forces control us. |
return undef; # Other forces control us. |
} |
} |
Line 249 CHOOSE_ANON1
|
Line 256 CHOOSE_ANON1
|
return $result; |
return $result; |
} |
} |
|
|
|
# Returns the XML for choosing how assignments are to be formatted |
|
# that text must still be parsed by the helper xml parser. |
|
# Parameters: 3 (required) |
|
|
|
# helper - The helper; $helper->{'VARS'}->{'PRINT_TYPE'} used |
|
# to check if splitting PDFs by section can be offered. |
|
# title - Title for the current state. |
|
# this_state - State name of the chooser. |
|
|
|
sub generate_format_selector { |
|
my ($helper,$title,$this_state) = @_; |
|
my $secpdfoption; |
|
unless (($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') ) { |
|
$secpdfoption = '<choice computer="sections">Each PDF contains exactly one section</choice>'; |
|
} |
|
return <<RESOURCE_SELECTOR; |
|
<state name="$this_state" title="$title"> |
|
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
|
<choices variable="EMPTY_PAGES"> |
|
<choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice> |
|
<choice computer='1'>Add one empty page/column after each student\'s assignment</choice> |
|
<choice computer='2'>Add two empty pages/column after each student\'s assignment</choice> |
|
<choice computer='3'>Add three empty pages/column after each student\'s assignment</choice> |
|
</choices> |
|
<nextstate>PAGESIZE</nextstate> |
|
<message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message> |
|
<choices variable="SPLIT_PDFS"> |
|
<choice computer="all">All assignments in a single PDF file</choice> |
|
$secpdfoption |
|
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
|
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT"> |
|
Specify the number of assignments per PDF:</choice> |
|
</choices> |
|
</state> |
|
RESOURCE_SELECTOR |
|
} |
|
|
|
|
#----------------------------------------------------------------------- |
#----------------------------------------------------------------------- |
|
|
|
|
Line 306 sub set_font_size {
|
Line 353 sub set_font_size {
|
|
|
my ($text) = @_; |
my ($text) = @_; |
|
|
$text =~ s/\\begin{document}/\\begin{document}{\\$font_size/; |
# There appear to be cases where the font directive is empty.. in which |
|
# case the first substituion would insert a spurious \ oh happy day. |
|
# as this has been the cause of much mystery and hair pulling _sigh_ |
|
|
|
if ($font_size ne '') { |
|
|
|
$text =~ s/\\begin{document}/\\begin{document}{\\$font_size/; |
|
} |
$text =~ s/\\end{document}/}\\end{document}/; |
$text =~ s/\\end{document}/}\\end{document}/; |
return $text; |
return $text; |
|
|
Line 497 sub printf_style_subst {
|
Line 551 sub printf_style_subst {
|
# %s - The section if it is supplied. |
# %s - The section if it is supplied. |
# |
# |
sub format_page_header { |
sub format_page_header { |
my ($width, $format, $assignment, $course, $student, $section) = @_; |
my ($width, $format, $assignment, $course, $student) = @_; |
|
|
|
|
|
|
$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. |
my $chars_per_line = int($width/2); # Character/textline. |
|
|
# Default format? |
# Default format? |
|
|
Line 518 sub format_page_header {
|
Line 572 sub format_page_header {
|
# - Allow the assignment to be 2 lines (wrapped). |
# - Allow the assignment to be 2 lines (wrapped). |
# |
# |
|
|
|
my $firstline = "$student $course"; |
|
if (length($firstline) > $chars_per_line) { |
my $name_length = int($chars_per_line *3 /4); |
my $lastchar = $chars_per_line - length($student) - 1; |
my $sec_length = int($chars_per_line / 5); |
if ($lastchar > 0) { |
|
$course = substr($course, 0, $lastchar); |
|
} else { # Nothing left of course: |
|
$course = ''; |
|
} |
|
} |
|
if (length($assignment) > $chars_per_line) { |
|
$assignment = substr($assignment, 0, $chars_per_line); |
|
} |
|
|
$format = "%$name_length".'n'; |
$format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}"; |
|
|
if ($section) { |
} else { |
$format .= ' - Sec: '."%$sec_length".'s'; |
# An open question is how to handle long user formatted page headers... |
} |
# A possible future is to support e.g. %na so that the user can control |
|
# the truncation of the elements that can appear in the header. |
$format .= '\\\\%c \\\\ %a'; |
# |
|
$format = &printf_style_subst("a", $format, $assignment); |
|
$format = &printf_style_subst("c", $format, $course); |
|
$format = &printf_style_subst("n", $format, $student); |
|
|
|
# If the user put %'s in the format string, they must be escaped |
|
# to \% else LaTeX will think they are comments and terminate |
|
# the line.. which is bad!!! |
|
|
} |
} |
# An open question is how to handle long user formatted page headers... |
|
# A possible future is to support e.g. %na so that the user can control |
|
# the truncation of the elements that can appear in the header. |
|
# |
|
$format = &printf_style_subst("a", $format, $assignment); |
|
$format = &printf_style_subst("c", $format, $course); |
|
$format = &printf_style_subst("n", $format, $student); |
|
$format = &printf_style_subst("s", $format, $section); |
|
|
|
|
|
# If the user put %'s in the format string, they must be escaped |
|
# to \% else LaTeX will think they are comments and terminate |
|
# the line.. which is bad!!! |
|
|
|
# If the user has role author, $course and $assignment are empty so |
|
# there is '\\ \\ ' in the page header. That's cause a error in LaTeX |
|
if($format =~ /\\\\\s\\\\\s/) { |
|
#TODO find sensible caption for page header |
|
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout '); |
|
$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 1265 sub get_course {
|
Line 1298 sub get_course {
|
my $courseidinfo; |
my $courseidinfo; |
if (defined($env{'request.course.id'})) { |
if (defined($env{'request.course.id'})) { |
$courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); |
$courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); |
my $sec = $env{'request.course.sec'}; |
|
|
|
} |
} |
return $courseidinfo; |
return $courseidinfo; |
} |
} |
Line 1289 sub page_format_transformation {
|
Line 1320 sub page_format_transformation {
|
|
|
my $name = &get_name(); |
my $name = &get_name(); |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
my $header_text = $parmhash{'print_header_format'}; |
my $header_text = $parmhash{'print_header_format'}; |
$header_text = &format_page_header($textwidth, $header_text, $assignment, |
$header_text = &format_page_header($textwidth, $header_text, $assignment, |
$courseidinfo, $name); |
$courseidinfo, $name); |
Line 1309 sub page_format_transformation {
|
Line 1341 sub page_format_transformation {
|
$text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /; |
$text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /; |
} |
} |
if ($papersize eq 'a4') { |
if ($papersize eq 'a4') { |
$text =~ s/(\\begin{document})/$1\\special{papersize=210mm,297mm}/; |
my $papersize_text; |
|
if ($perm{'pav'}) { |
|
$papersize_text = '\\special{papersize=210mm,297mm}'; |
|
} else { |
|
$papersize_text = '\special{papersize=210mm,297mm}'; |
|
} |
|
$text =~ s/(\\begin{document})/$1$papersize_text/; |
} |
} |
} |
} |
if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;} |
if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;} |
Line 1540 sub print_page_in_course {
|
Line 1578 sub print_page_in_course {
|
my $title=&Apache::lonnet::gettitle($symb); |
my $title=&Apache::lonnet::gettitle($symb); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$title = &Apache::lonxml::latex_special_symbols($title); |
} else { |
} else { |
$result.=$currentURL; |
my $esc_currentURL= $currentURL; |
|
$esc_currentURL =~ s/_/\\_/g; |
|
$result.=$esc_currentURL; |
} |
} |
$result .= '\\\\'; |
$result .= '\\\\'; |
|
|
Line 1570 sub print_page_in_course {
|
Line 1610 sub print_page_in_course {
|
} |
} |
# these resources go through the XML transformer: |
# these resources go through the XML transformer: |
|
|
elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm\xhtml|xhtm)$/) { |
elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { |
my $urlp = &Apache::lonnet::clutter($resource_src); |
my $urlp = &Apache::lonnet::clutter($resource_src); |
my %form; |
my %form; |
my %moreenv; |
my %moreenv; |
Line 1581 sub print_page_in_course {
|
Line 1621 sub print_page_in_course {
|
|
|
$form{'grade_target'} = 'tex'; |
$form{'grade_target'} = 'tex'; |
$form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); |
$form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); |
$form{'pdfFormFiels'} = $pdfFormFields; # |
$form{'pdfFormFields'} = 'no'; |
$form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; |
$form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; |
|
|
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
Line 1685 sub print_page_in_course {
|
Line 1725 sub print_page_in_course {
|
# List of recently generated print files |
# List of recently generated print files |
# |
# |
sub recently_generated { |
sub recently_generated { |
my $r=shift; |
my ($prtspool) = @_; |
my $prtspool=$r->dir_config('lonPrtDir'); |
my $output; |
my $zip_result; |
my $zip_result; |
my $pdf_result; |
my $pdf_result; |
opendir(DIR,$prtspool); |
opendir(DIR,$prtspool); |
Line 1719 sub recently_generated {
|
Line 1759 sub recently_generated {
|
if ($ext eq 'zip') { $zip_result .= $result; } |
if ($ext eq 'zip') { $zip_result .= $result; } |
} |
} |
if ($zip_result || $pdf_result) { |
if ($zip_result || $pdf_result) { |
$r->print('<hr />'); |
$output ='<hr />'; |
} |
} |
if ($zip_result) { |
if ($zip_result) { |
$r->print('<h3>'.&mt('Recently generated printout zip files')."</h3>\n" |
$output .='<h3>'.&mt('Recently generated printout zip files')."</h3>\n" |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
.'<th>'.&mt('Download').'</th>' |
.'<th>'.&mt('Download').'</th>' |
Line 1730 sub recently_generated {
|
Line 1770 sub recently_generated {
|
.'<th>'.&mt('File Size (Bytes)').'</th>' |
.'<th>'.&mt('File Size (Bytes)').'</th>' |
.&Apache::loncommon::end_data_table_header_row() |
.&Apache::loncommon::end_data_table_header_row() |
.$zip_result |
.$zip_result |
.&Apache::loncommon::end_data_table() |
.&Apache::loncommon::end_data_table(); |
); |
|
} |
} |
if ($pdf_result) { |
if ($pdf_result) { |
$r->print('<h3>'.&mt('Recently generated printouts')."</h3>\n" |
$output .='<h3>'.&mt('Recently generated printouts')."</h3>\n" |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table() |
.&Apache::loncommon::start_data_table_header_row() |
.&Apache::loncommon::start_data_table_header_row() |
.'<th>'.&mt('Download').'</th>' |
.'<th>'.&mt('Download').'</th>' |
Line 1742 sub recently_generated {
|
Line 1781 sub recently_generated {
|
.'<th>'.&mt('File Size (Bytes)').'</th>' |
.'<th>'.&mt('File Size (Bytes)').'</th>' |
.&Apache::loncommon::end_data_table_header_row() |
.&Apache::loncommon::end_data_table_header_row() |
.$pdf_result |
.$pdf_result |
.&Apache::loncommon::end_data_table() |
.&Apache::loncommon::end_data_table(); |
); |
|
} |
} |
|
return $output; |
} |
} |
|
|
# |
# |
Line 2090 ENDPART
|
Line 2129 ENDPART
|
my %form; |
my %form; |
$form{'grade_target'} = 'tex'; |
$form{'grade_target'} = 'tex'; |
$form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); |
$form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); |
$form{'pdfFormFields'} = $pdfFormFields; |
$form{'pdfFormFields'} = 'no'; |
|
|
# If form.showallfoils is set, then request all foils be shown: |
# If form.showallfoils is set, then request all foils be shown: |
# privilege will be enforced both by not allowing the |
# privilege will be enforced both by not allowing the |
Line 2110 ENDPART
|
Line 2149 ENDPART
|
&Apache::lonnet::delenv('construct.style'); |
&Apache::lonnet::delenv('construct.style'); |
} |
} |
|
|
|
|
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
#-- single document - problem, page, html, xml, ... |
#-- single document - problem, page, html, xml, ... |
my ($currentURL,$cleanURL); |
my ($currentURL,$cleanURL); |
Line 2280 ENDPART
|
Line 2318 ENDPART
|
($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 |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') |
) { |
) { |
|
|
|
|
|
|
#-- produce an output string |
#-- produce an output string |
if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or |
if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') ) { |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') ) { |
Line 2345 ENDPART
|
Line 2383 ENDPART
|
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonxml::remember_problem_counter(); |
if ($flag_latex_header_remove eq 'NO') { |
if ($flag_latex_header_remove eq 'NO') { |
$texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF |
$texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF |
$flag_latex_header_remove = 'YES'; |
unless (($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only') || |
|
(($i==0) && |
|
(($urlp=~/\.page$/) || |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') || |
|
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page')))) { |
|
$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$/) { |
Line 2353 ENDPART
|
Line 2397 ENDPART
|
if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} |
if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} |
$texversion =~ s/\\end{document}\d*/\\end{document}/; |
$texversion =~ s/\\end{document}\d*/\\end{document}/; |
$flag_page_in_sequence = 'YES'; |
$flag_page_in_sequence = 'YES'; |
} |
} |
|
|
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')) { |
Line 2365 ENDPART
|
Line 2409 ENDPART
|
|
|
&Apache::lonxml::restore_problem_counter(); |
&Apache::lonxml::restore_problem_counter(); |
my $answer=&ssi_with_retries($urlp, $ssi_retry_count, %answerform); |
my $answer=&ssi_with_retries($urlp, $ssi_retry_count, %answerform); |
|
if ($urlp =~ /\.page$/) { |
|
$answer =~ s/\\end{document}(\d*)$//; |
|
} |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
if ($urlp =~ /\.page$/) { |
|
my @probs = split(/\\keephidden{ENDOFPROBLEM}/,$texversion); |
|
my $lastprob = pop(@probs); |
|
$texversion = join('\keephidden{ENDOFPROBLEM}',@probs). |
|
$answer.'\keephidden{ENDOFPROBLEM}'.$lastprob; |
|
} else { |
|
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
|
} |
} else { |
} else { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/) { |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion =~ s/\\begin{document}//; |
# $texversion =~ s/\\begin{document}//; # FIXME |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$title = &Apache::lonxml::latex_special_symbols($title); |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
Line 2401 ENDPART
|
Line 2454 ENDPART
|
if (($selectionmade == 4) and ($assignment ne $prevassignment)) { |
if (($selectionmade == 4) and ($assignment ne $prevassignment)) { |
my $name = &get_name(); |
my $name = &get_name(); |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
$prevassignment=$assignment; |
$prevassignment=$assignment; |
my $header_text = $parmhash{'print_header_format'}; |
my $header_text = $parmhash{'print_header_format'}; |
$header_text = &format_page_header($textwidth, $header_text, |
$header_text = &format_page_header($textwidth, $header_text, |
Line 2437 ENDPART
|
Line 2491 ENDPART
|
if ($i > 0) { |
if ($i > 0) { |
$result .= '\cleardoublepage'; |
$result .= '\cleardoublepage'; |
} |
} |
$result .= &include_pdf($urlp); |
my $texfrompdf = &include_pdf($urlp); |
|
if ($flag_latex_header_remove ne 'NO') { |
|
$texfrompdf = &latex_header_footer_remove($texfrompdf); |
|
} |
|
$result .= $texfrompdf; |
if ($i != $#master_seq) { |
if ($i != $#master_seq) { |
if ($numberofcolumns eq '1') { |
if ($numberofcolumns eq '1') { |
$result .= '\newpage'; |
$result .= '\newpage'; |
Line 2460 ENDPART
|
Line 2518 ENDPART
|
} |
} |
$result .= $texversion; |
$result .= $texversion; |
$flag_latex_header_remove = 'YES'; |
$flag_latex_header_remove = 'YES'; |
} |
} |
if (&Apache::loncommon::connection_aborted($r)) { |
if (&Apache::loncommon::connection_aborted($r)) { |
last; |
last; |
} |
} |
Line 2561 ENDPART
|
Line 2619 ENDPART
|
$resources_printed .= ":"; |
$resources_printed .= ":"; |
$print_array[$i].=$output; |
$print_array[$i].=$output; |
$student_names[$i].=$person.':'.$fullname.'_END_'; |
$student_names[$i].=$person.':'.$fullname.'_END_'; |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); |
# &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student'); |
$flag_latex_header_remove = 'YES'; |
$flag_latex_header_remove = 'YES'; |
if (&Apache::loncommon::connection_aborted($r)) { last; } |
if (&Apache::loncommon::connection_aborted($r)) { last; } |
} |
} |
Line 2634 ENDPART
|
Line 2693 ENDPART
|
my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'}); |
my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'}); |
&adjust_number_to_print($helper); |
&adjust_number_to_print($helper); |
my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'}; |
my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'}; |
if ($number_per_page eq '0' || $number_per_page eq 'all') { |
if ($number_per_page eq '0' || $number_per_page eq 'all' |
|
|| $number_per_page eq 'section') { |
$number_per_page=$num_todo; |
$number_per_page=$num_todo; |
} |
} |
my $flag_latex_header_remove = 'NO'; |
my $flag_latex_header_remove = 'NO'; |
Line 2935 sub print_resources {
|
Line 2995 sub print_resources {
|
$i++; |
$i++; |
|
|
if ( !($type eq 'problems' && |
if ( !($type eq 'problems' && |
($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) { |
($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) ) { |
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline); |
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline); |
if (&Apache::lonnet::allowed('bre',$res_url)) { |
if (&Apache::lonnet::allowed('bre',$res_url)) { |
if ($res_url!~m|^ext/| |
if ($res_url!~m|^ext/| |
Line 2944 sub print_resources {
|
Line 3004 sub print_resources {
|
&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 ($res_url =~ /\.page$/) { |
|
if ($remove_latex_header eq 'NO') { |
|
if (!($rendered =~ /\\begin\{document\}/)) { |
|
$rendered = &print_latex_header().$rendered; |
|
} |
|
} |
|
if ($remove_latex_header eq 'YES') { |
|
$rendered = &latex_header_footer_remove($rendered); |
|
} else { |
|
$rendered =~ s/\\end{document}\d*//; |
|
} |
|
} |
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 2961 sub print_resources {
|
Line 3033 sub print_resources {
|
|
|
|
|
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$header =~ s/\\begin{document}//; #<<<<< |
unless ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only') { |
|
$header =~ s/\\begin{document}//; #<<<<< |
|
} |
my $title = &Apache::lonnet::gettitle($curresline); |
my $title = &Apache::lonnet::gettitle($curresline); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$title = &Apache::lonxml::latex_special_symbols($title); |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
Line 3022 sub print_resources {
|
Line 3096 sub print_resources {
|
if (&Apache::loncommon::connection_aborted($r)) { last; } |
if (&Apache::loncommon::connection_aborted($r)) { last; } |
} |
} |
|
|
|
if ($syllabus_first) { |
|
$current_output =~ s/\\\\ Last updated:/Last updated:/ |
|
} |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
|
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $header_line = |
my $header_line = |
&format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
&format_page_header($LaTeXwidth, $parmhash{'print_header_format'}, |
$currentassignment, $courseidinfo, $fullname, $usersection); |
$currentassignment, $courseidinfo, $fullname); |
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/ && (!$syllabus_first)) { |
if ($current_output=~/\\documentclass/) { |
$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 3108 sub init_perm {
|
Line 3183 sub init_perm {
|
$perm{'pfo'}=&Apache::lonnet::allowed('pfo', |
$perm{'pfo'}=&Apache::lonnet::allowed('pfo', |
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
} |
} |
|
$perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
|
if (!$perm{'vgr'}) { |
|
$perm{'vgr'}=&Apache::lonnet::allowed('vgr', |
|
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
|
} |
} |
} |
|
|
sub get_randomly_ordered_warning { |
sub get_randomly_ordered_warning { |
Line 3520 ALL_PROBLEMS
|
Line 3600 ALL_PROBLEMS
|
$map, |
$map, |
$isProblem, '', $symbFilter, |
$isProblem, '', $symbFilter, |
$start_new_option); |
$start_new_option); |
$resource_selector .= <<RESOURCE_SELECTOR; |
$resource_selector .= &generate_format_selector($helper, |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
'How should results be printed?', |
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
'PRINT_FORMATTING'). |
<choices variable="EMPTY_PAGES"> |
&generate_resource_chooser('CHOOSE_STUDENTS_PAGE', |
<choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice> |
|
<choice computer='1'>Add one empty page/column after each student\'s assignment</choice> |
|
<choice computer='2'>Add two empty pages/column after each student\'s assignment</choice> |
|
<choice computer='3'>Add three empty pages/column after each student\'s assignment</choice> |
|
</choices> |
|
<nextstate>PAGESIZE</nextstate> |
|
<message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message> |
|
<choices variable="SPLIT_PDFS"> |
|
<choice computer="all">All assignments in a single PDF file</choice> |
|
<choice computer="sections">Each PDF contains exactly one section</choice> |
|
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
|
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT"> |
|
Specify the number of assignments per PDF:</choice> |
|
</choices> |
|
</state> |
|
RESOURCE_SELECTOR |
|
$resource_selector .= &generate_resource_chooser('CHOOSE_STUDENTS_PAGE', |
|
'Select Problem(s) to print', |
'Select Problem(s) to print', |
"multichoice='1' addstatus='1' closeallpages ='1'", |
"multichoice='1' addstatus='1' closeallpages ='1'", |
'RESOURCES', |
'RESOURCES', |
Line 3668 RESOURCE_SELECTOR
|
Line 3731 RESOURCE_SELECTOR
|
$start_new_option |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
|
|
<state name="PRINT_FORMATTING" title="Format of the print job"> |
|
<nextstate>NUMBER_PER_PDF</nextstate> |
|
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message> |
|
<choices variable="EMPTY_PAGES"> |
|
<choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice> |
|
<choice computer='1'>Add one empty page/column after each student\'s assignment</choice> |
|
<choice computer='2'>Add two empty pages/column after each student\'s assignment</choice> |
|
<choice computer='3'>Add three empty pages/column after each student\'s assignment</choice> |
|
</choices> |
|
<nextstate>PAGESIZE</nextstate> |
|
<message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message> |
|
<choices variable="SPLIT_PDFS"> |
|
<choice computer="all">All assignments in a single PDF file</choice> |
|
<choice computer="sections">Each PDF contains exactly one section</choice> |
|
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
|
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT"> |
|
Specify the number of assignments per PDF:</choice> |
|
</choices> |
|
</state> |
|
RESOURCE_SELECTOR |
RESOURCE_SELECTOR |
|
|
|
$resource_selector .= &generate_format_selector($helper, |
|
'Format of the print job', |
|
'PRINT_FORMATTING'); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1); |
<state name="CHOOSE_STUDENTS1" title="Select Students and Resources"> |
<state name="CHOOSE_STUDENTS1" title="Select Students and Resources"> |
<choices variable='student_sort'> |
<choices variable='student_sort'> |
Line 3710 CHOOSE_STUDENTS1
|
Line 3756 CHOOSE_STUDENTS1
|
<message><br /><hr /> <br /></message> |
<message><br /><hr /> <br /></message> |
<message><h3>Generate new CODEd Assignments</h3></message> |
<message><h3>Generate new CODEd Assignments</h3></message> |
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></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"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5" noproceed="1"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
!\$helper->{'VARS'}{'REUSE_OLD_CODES'} && |
Line 3718 CHOOSE_STUDENTS1
|
Line 3764 CHOOSE_STUDENTS1
|
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
return "You need to specify the number of assignments to print"; |
return "You need to specify the number of assignments to print"; |
} |
} |
|
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) >= 1) && |
|
(\$helper->{'VARS'}{'SINGLE_CODE'} ne '') ) { |
|
return 'Specifying number of codes to print and a specific code is not compatible'; |
|
} |
return undef; |
return undef; |
</validator> |
</validator> |
</string> |
</string> |
Line 3741 CHOOSE_STUDENTS1
|
Line 3791 CHOOSE_STUDENTS1
|
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
!\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { |
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, |
\$helper->{'VARS'}{'CODE_OPTION'}); |
\$helper->{'VARS'}{'CODE_OPTION'}); |
|
} elsif (\$helper->{'VARS'}{'SINGLE_CODE'} ne ''){ |
|
return 'Specifying a code name is incompatible specifying number of codes.'; |
} else { |
} else { |
return undef; # Other forces control us. |
return undef; # Other forces control us. |
} |
} |
Line 3841 CHOOSE_FROM_ANY_SEQUENCE
|
Line 3893 CHOOSE_FROM_ANY_SEQUENCE
|
my $startedTable = 0; # have we started an HTML table yet? (need |
my $startedTable = 0; # have we started an HTML table yet? (need |
# to close it later) |
# to close it later) |
|
|
if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or |
if (($perm{'pav'} and $perm{'vgr'}) or |
($helper->{VARS}->{'construction'} eq '1')) { |
($helper->{VARS}->{'construction'} eq '1')) { |
&addMessage('<br />' |
&addMessage('<br />' |
.'<h3>'.&mt('Print Options').'</h3>' |
.'<h3>'.&mt('Print Options').'</h3>' |
Line 4088 PROBTYPE
|
Line 4140 PROBTYPE
|
return $helper; |
return $helper; |
} |
} |
|
|
$r->print($helper->display()); |
my $footer; |
if ($helper->{STATE} eq 'START') { |
if ($helper->{STATE} eq 'START') { |
&recently_generated($r); |
my $prtspool=$r->dir_config('lonPrtDir'); |
|
$footer = &recently_generated($prtspool); |
} |
} |
|
$r->print($helper->display($footer)); |
&Apache::lonhelper::unregisterHelperTags(); |
&Apache::lonhelper::unregisterHelperTags(); |
|
|
return OK; |
return OK; |
Line 4167 sub render {
|
Line 4221 sub render {
|
my $PaperType=&mt('Paper type'); |
my $PaperType=&mt('Paper type'); |
my $landscape=&mt('Landscape'); |
my $landscape=&mt('Landscape'); |
my $portrait=&mt('Portrait'); |
my $portrait=&mt('Portrait'); |
my $pdfFormLabel=&mt('PDF-Formfields'); |
|
my $with=&mt('with Formfields'); |
|
my $without=&mt('without Formfields'); |
|
|
|
|
|
$result.='<h3>'.&mt('Layout Options').'</h3>' |
$result.='<h3>'.&mt('Layout Options').'</h3>' |
Line 4178 sub render {
|
Line 4229 sub render {
|
.'<th>'.$PageLayout.'</th>' |
.'<th>'.$PageLayout.'</th>' |
.'<th>'.$NumberOfColumns.'</th>' |
.'<th>'.$NumberOfColumns.'</th>' |
.'<th>'.$PaperType.'</th>' |
.'<th>'.$PaperType.'</th>' |
.'<th>'.$pdfFormLabel.'</th>' |
|
.&Apache::loncommon::end_data_table_header_row() |
.&Apache::loncommon::end_data_table_header_row() |
.&Apache::loncommon::start_data_table_row() |
.&Apache::loncommon::start_data_table_row() |
.'<td>' |
.'<td>' |
Line 4219 sub render {
|
Line 4269 sub render {
|
$result .= <<HTML; |
$result .= <<HTML; |
</select> |
</select> |
</td> |
</td> |
<td align='center'> |
|
<select name='${var}.pdfFormFields'> |
|
<option selected="selected" value="no">$without</option> |
|
<option value="yes">$with</option> |
|
</select> |
|
</td> |
|
HTML |
HTML |
$result.=&Apache::loncommon::end_data_table_row() |
$result.=&Apache::loncommon::end_data_table_row() |
.&Apache::loncommon::end_data_table(); |
.&Apache::loncommon::end_data_table(); |