version 1.557.2.2, 2009/07/14 11:08:00
|
version 1.560.2.3, 2009/09/08 10:53:15
|
Line 1
|
Line 1
|
|
# |
|
# Issues: |
|
# - Need to get the state flow for selected problems/resources for students |
|
# correct |
|
# - Need to do the CODEd stuff. |
|
# - Need to regularize and figure out for each case who puts on the latex |
|
# front matter and make sure it gets done. |
|
# |
|
# |
|
|
# The LearningOnline Network |
# The LearningOnline Network |
# Printout |
# Printout |
# |
# |
Line 26
|
Line 36
|
# |
# |
# |
# |
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 74 my $ssi_retry_count = 5; # Some arbitrar
|
Line 83 my $ssi_retry_count = 5; # Some arbitrar
|
|
|
my $font_size = 'normalsize'; # Default is normalsize... |
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 ($value_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; |
|
} |
|
|
|
|
|
#----------------------------------------------------------------------- |
|
|
|
|
# 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 104 sub fetch_raw_resource {
|
Line 212 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 230 sub include_pdf {
|
Line 338 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 1339 sub print_page_in_course {
|
Line 1451 sub print_page_in_course {
|
|
|
|
|
if ($mode ne '') {$mode='\\'.$mode} |
if ($mode ne '') {$mode='\\'.$mode} |
my $result.= &print_latex_header($mode); |
my $result = &print_latex_header($mode); |
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
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); |
$result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' '; |
|
} else { |
} else { |
$result.=$currentURL; |
$result.=$currentURL; |
} |
} |
|
$result .= '\\\\'; |
|
|
if ($helper->{'VARS'}->{'style_file'}=~/\w/) { |
if ($helper->{'VARS'}->{'style_file'}=~/\w/) { |
&Apache::lonnet::appenv({'construct.style' => |
&Apache::lonnet::appenv({'construct.style' => |
$helper->{'VARS'}->{'style_file'}}); |
$helper->{'VARS'}->{'style_file'}}); |
Line 1355 sub print_page_in_course {
|
Line 1468 sub print_page_in_course {
|
&Apache::lonnet::delenv('construct.style'); |
&Apache::lonnet::delenv('construct.style'); |
} |
} |
|
|
# First is theo verall page description. This is then followed by the |
# First is the overall page description. This is then followed by the |
# components of the page. Each of which must be printed independently. |
# components of the page. Each of which must be printed independently. |
|
|
my $the_page = shift(@page_resources); |
my $the_page = shift(@page_resources); |
$result .= "URL: $currentURL " .'\\\\'; |
|
|
|
foreach my $resource (@page_resources) { |
foreach my $resource (@page_resources) { |
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
|
$result .= $resource->title() . '\\\\'; |
|
|
# Recurse if a .page: |
# Recurse if a .page: |
|
|
if ($resource_src =~ /.page$/i) { |
if ($resource_src =~ /.page$/i) { |
Line 1408 sub print_page_in_course {
|
Line 1521 sub print_page_in_course {
|
|
|
my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); |
my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); |
|
|
|
|
# current document with answers.. no need to encap in minipage |
# current document with answers.. no need to encap in minipage |
# since there's only one answer. |
# since there's only one answer. |
|
|
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')) { |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
my %answerform = %form; |
$form{'grade_target'}='answer'; |
|
$form{'answer_output_mode'}='tex'; |
|
$form{'rndseed'}=$rndseed; |
$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') { |
if ($helper->{'VARS'}->{'probstatus'} eq 'exam') { |
$form{'problemtype'}='exam'; |
$answerform{'problemtype'}='exam'; |
} |
} |
$resources_printed .= $currentURL.':'; |
$resources_printed .= $urlp.':'; |
my $answer=&ssi_with_retries($currentURL,$ssi_retry_count, %form); |
my $answer=&ssi_with_retries($urlp,$ssi_retry_count, %answerform); |
|
|
|
|
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
} else { |
} else { |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); |
my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$title = &Apache::lonxml::latex_special_symbols($title); |
Line 1462 sub print_page_in_course {
|
Line 1578 sub print_page_in_course {
|
$texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$currentURL| \\strut\\\\\\strut /; |
$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; |
$result .= $texversion; |
if ($currentURL=~m/\.page\s*$/) { |
if ($currentURL=~m/\.page\s*$/) { |
($result,$numberofcolumns) = &page_cleanup($result); |
($result,$numberofcolumns) = &page_cleanup($result); |
Line 1549 sub recently_generated {
|
Line 1673 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'}); |
Line 1717 sub output_data {
|
Line 1841 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 1891 ENDPART
|
Line 2023 ENDPART
|
&& $currentURL=~/\.(sequence|page)$/ && $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 |
|
|
&Apache::lonnet::logthis("Printing sequence/page but construction space??"); |
|
|
|
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
# $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
# $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
Line 1929 ENDPART
|
Line 2060 ENDPART
|
$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. |
} elsif ($cleanURL =~ /\.page$/i) { # Print page in non construction space contexts. |
&Apache::lonnet::logthis("Printing .page $cleanURL at " . __LINE__); |
|
|
|
# Determine the set of resources in the map of the page: |
# Determine the set of resources in the map of the page: |
|
|
Line 1945 ENDPART
|
Line 2075 ENDPART
|
$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 1953 ENDPART
|
Line 2085 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')) |
|
{ |
|
&Apache::lonnet::logthis("Selectionmade => 3"); |
$selectionmade = 3; |
$selectionmade = 3; |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') |
) { |
) { |
Line 1995 ENDPART
|
Line 2131 ENDPART
|
$result.="\\newpage\n"; |
$result.="\\newpage\n"; |
} |
} |
} |
} |
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]; |
|
|
|
&Apache::lonnet::logthis("Element $i Sequence $sequence Middle $middle_thingy URLP $urlp"); |
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 2007 ENDPART
|
Line 2143 ENDPART
|
my $texversion=''; |
my $texversion=''; |
if ($urlp!~m|^/adm/| |
if ($urlp!~m|^/adm/| |
&& $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)$/) { |
&Apache::lonnet::logthis("At line 1834 printing $urlp"); |
&Apache::lonnet::logthis("Problem"); |
$resources_printed .= $urlp.':'; |
$resources_printed .= $urlp.':'; |
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonxml::remember_problem_counter(); |
|
&Apache::lonnet::logthis("Fetching tex for $urlp"); |
|
my $debug = Dumper(%form); |
|
&Apache::lonnet::logthis("Form: $debug"); |
|
|
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
|
&Apache::lonnet::logthis("texversion so far: $texversion"); |
if ($urlp=~/\.page$/) { |
if ($urlp=~/\.page$/) { |
&Apache::lonnet::logthis("Handling a .page at ". __LINE__); |
&Apache::lonnet::("Special page actions"); |
|
|
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
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}/; |
Line 2035 ENDPART
|
Line 2175 ENDPART
|
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$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)$/) { |
|
&Apache::lonnet::logthis("problem printing"); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion =~ s/\\begin{document}//; |
$texversion =~ s/\\begin{document}//; |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
Line 2080 ENDPART
|
Line 2221 ENDPART
|
} |
} |
} |
} |
$result .= $texversion; |
$result .= $texversion; |
|
&Apache::lonnet::logthis("About to set rem header true with $result"); |
$flag_latex_header_remove = 'YES'; |
$flag_latex_header_remove = 'YES'; |
} elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
Line 2602 sub print_resources {
|
Line 2744 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::lonnet::logthis("At line 2427 printing $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); |
Line 2913 sub printHelper {
|
Line 3054 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 2920 sub printHelper {
|
Line 3063 sub printHelper {
|
} else { |
} else { |
$url = $helper->{VARS}->{'postdata'}; |
$url = $helper->{VARS}->{'postdata'}; |
$is_published=1; # From resource space. |
$is_published=1; # From resource space. |
|
&Apache::lonnet::logthis("Resource url $url"); |
} |
} |
$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 2982 sub printHelper {
|
Line 3125 sub printHelper {
|
"' variable='FINISHPAGE' />"; |
"' variable='FINISHPAGE' />"; |
} |
} |
|
|
if (($helper->{'VARS'}->{'construction'} ne '1' ) && |
# 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(); |
|
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->{'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"> |
&Apache::lonnet::logthis("Map url : $map"); |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS', |
closeallpages="1"> |
'Select Problem(s) to print', |
<nextstate>PAGESIZE</nextstate> |
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
<filterfunc>return $isProblem;</filterfunc> |
'RESOURCES', |
<mapurl>$map</mapurl> |
'PAGESIZE', |
<valuefunc>return $symbFilter;</valuefunc> |
$map, |
$start_new_option |
$isProblem, '', |
</resource> |
$symbFilter, |
</state> |
$start_new_option); |
|
$helperFragment .= &generate_resource_chooser('CHOOSE_PROBLEMS_HTML', |
<state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print"> |
'Select Resource(s) to print', |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
closeallpages="1"> |
'RESOURCES', |
<nextstate>PAGESIZE</nextstate> |
'PAGESIZE', |
<filterfunc>return $isNotMap;</filterfunc> |
$map, |
<mapurl>$map</mapurl> |
$isNotMap, '', |
<valuefunc>return $symbFilter;</valuefunc> |
$symbFilter, |
$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 3064 HELPERFRAGMENT
|
Line 3231 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', 'CHOOSE_STUDENTS']; |
|
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', 'CHOOSE_ANON1']; |
|
} |
|
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 3084 ALL_PROBLEMS
|
Line 3294 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> |
'', |
<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 3118 ALL_PROBLEMS
|
Line 3323 ALL_PROBLEMS
|
</state> |
</state> |
RESOURCE_SELECTOR |
RESOURCE_SELECTOR |
|
|
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS); |
# Generate student choosers. |
<state name="CHOOSE_STUDENTS" title="Select Students and Resources"> |
|
<message><b>Select sorting order of printout</b> </message> |
|
<choices variable='student_sort'> |
|
<choice computer='0'>Sort by section then student</choice> |
|
<choice computer='1'>Sort by students across sections.</choice> |
&Apache::lonxml::xmlparse($r, 'helper', |
</choices> |
&generate_student_chooser('CHOOSE_STUDENTS', |
<message><br /><hr /><br /> </message> |
'student_sort', |
<student multichoice='1' variable="STUDENTS" nextstate="SELECT_PROBLEMS" coursepersonnel="1"/> |
'STUDENTS', |
</state> |
'SELECT_PROBLEMS')); |
$resource_selector |
&Apache::lonxml::xmlparse($r, 'helper', $resource_selector); |
CHOOSE_STUDENTS |
|
|
|
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 3255 CHOOSE_ANON1
|
Line 3459 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 3266 CHOOSE_ANON1
|
Line 3469 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 3995 sub preprocess {
|
Line 4199 sub preprocess {
|
($papersize) = split(/ /, $papersize); |
($papersize) = split(/ /, $papersize); |
|
|
|
|
$laystyle = &map_laystyle($laystyle); |
$laystyle = &Apache::lonprintout::map_laystyle($laystyle); |
|
|
# Figure out some good defaults for the print out and set them: |
# Figure out some good defaults for the print out and set them: |
|
|