--- loncom/interface/lonprintout.pm 2003/05/06 20:50:04 1.155
+++ loncom/interface/lonprintout.pm 2003/05/13 20:42:39 1.165
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.155 2003/05/06 20:50:04 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.165 2003/05/13 20:42:39 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1363,28 +1363,41 @@ ENDPART
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
#-- single document - problem, page, html, xml, ...
my $currentURL;
- if (not defined $helper->{'VARS'}->{'construction'}) {
+ if ($helper->{'VARS'}->{'construction'} ne '1') {
+ #prins published resource
$currentURL=$helper->{'VARS'}->{'postdata'};
} else {
- $currentURL=$helper->{'VARS'}->{'construction'};
+ #prins resource from the construction space
+ $currentURL=$helper->{'VARS'}->{'filename'};
+ $currentURL=~s/\/home\//\/~/;
+ $currentURL=~s/public_html\///;
}
$selectionmade = 1;
if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
- my %moreenv;
- $moreenv{'form.grade_target'}='tex';
- if (&Apache::lonnet::allowed('bre',$currentURL)) {
- $currentURL=~s/http:\/\/[^\/]+//;
- }
- $moreenv{'request.filename'}=$currentURL;
- $moreenv{'form.textwidth'}=$LaTeXwidth;
- &Apache::lonnet::appenv(%moreenv);
- my $texversion=&Apache::lonnet::ssi($currentURL);
- &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter');
- $result .= $texversion;
- if ($currentURL=~m/\.page\s*$/) {
- ($result,$number_of_columns) = &page_cleanup($result);
- }
- } else {
+ my %moreenv;
+ $moreenv{'form.grade_target'}='tex';
+ $moreenv{'request.filename'}=$currentURL;
+ $moreenv{'form.textwidth'}=$LaTeXwidth;
+ &Apache::lonnet::appenv(%moreenv);
+ my $texversion=&Apache::lonnet::ssi($currentURL);
+ &Apache::lonnet::delenv('form.grade_target');
+ &Apache::lonnet::delenv('form.textwidth');
+ &Apache::lonnet::delenv('form.counter');
+ if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
+ $moreenv{'form.grade_target'}='answer';
+ $moreenv{'form.print_answer'}='yes';
+ &Apache::lonnet::appenv(%moreenv);
+ my $answer=&Apache::lonnet::ssi($currentURL);
+ &Apache::lonnet::delenv('form.grade_target');
+ &Apache::lonnet::delenv('form.print_answer');
+# $r->print('
'.$answer.'
'); return OK;
+ $texversion=~s/(\\end{document})/$answer$1/;
+ }
+ $result .= $texversion;
+ if ($currentURL=~m/\.page\s*$/) {
+ ($result,$number_of_columns) = &page_cleanup($result);
+ }
+ } else {
# $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
# if ($ENV{'form.url'}=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {
# $result.=$1;
@@ -1392,9 +1405,7 @@ ENDPART
# $result.=$ENV{'form.url'};
# }
# $result.=' \end{document}'
- }
-
-
+ }
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems')) {
@@ -1418,7 +1429,8 @@ ENDPART
&Apache::lonnet::appenv(%moreenv);
#&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");
my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$master_seq[$i]));
- &Apache::lonnet::delenv('form.grade_target','form.textwidth');
+ &Apache::lonnet::delenv('form.grade_target');
+ &Apache::lonnet::delenv('form.textwidth');
if ($urlp=~/\.page$/) {
($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;}
@@ -1505,7 +1517,8 @@ ENDPART
$urlp =~ s|^/home/httpd/html||;
}
my $texversion=&Apache::lonnet::ssi($urlp);
- &Apache::lonnet::delenv('form.grade_target','form.textwidth');
+ &Apache::lonnet::delenv('form.grade_target');
+ &Apache::lonnet::delenv('form.textwidth');
#this chunck is responsible for printing the path to problem
my $newurlp = '';
my $HowMany = length($urlp)*2;
@@ -1583,10 +1596,11 @@ sub handler {
$helper = $result;
-# my $key;
-# foreach $key (keys %{$helper->{'VARS'}}) {
-# $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'
');
-# }
+
+ my $key;
+ foreach $key (keys %{$helper->{'VARS'}}) {
+ $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-
');
+ }
# return OK;
@@ -1689,14 +1703,29 @@ sub printHelper {
my $helper = Apache::lonhelper::helper->new("Printing Wizard");
$helper->declareVar('symb');
- $helper->declareVar('postdata');
+ $helper->declareVar('postdata');
+ $helper->declareVar('filename');
+ $helper->declareVar('construction');
# This will persistently load in the data we want from the
# very first screen.
- if ($ENV{'form.postdata'}) {
- if ($ENV{'form.postdata'}!~/\/res\//) {$helper->{VARS}->{'construction'} = $ENV{'form.postdata'};}
- $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});
+ # Detect whether we're coming from construction space
+ if ($ENV{'form.postdata'} =~ /http:\/\// ) {
+ $ENV{'form.postdata'} =~ /http:\/\/[a-zA-Z.]+\/~([a-zA-Z0-9]+)\/(.*)/;
+ $helper->{VARS}->{'filename'} = "/home/$1/public_html/$2";
+ $helper->{VARS}->{'construction'} = 1;
+ } else {
+ if ($ENV{'form.postdata'}) {
+ $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});
+ }
+ if ($ENV{'form.symb'}) {
+ $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
+ }
+ if ($ENV{'form.url'}) {
+ $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
+ }
}
+
if ($ENV{'form.symb'}) {
$helper->{VARS}->{'symb'} = $ENV{'form.symb'};
}
@@ -1704,37 +1733,40 @@ sub printHelper {
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
}
-
my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu;
$helper->{VARS}->{'assignment'} = $sequenceTitle;
+
# Extract map
my $symb = $helper->{VARS}->{'symb'};
- my ($map, $id, $url) = split(/___/, $symb);
- $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
+ my ($map, $id, $url);
+ my $subdir;
- if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
- my $url = $helper->{VARS}->{'postdata'};
- $resourceTitle = substr($url, rindex($url, '/') + 1);
+ # Get the resource name from construction space
+ if ($helper->{VARS}->{'construction'}) {
+ $resourceTitle = substr($helper->{VARS}->{'filename'},
+ rindex($helper->{VARS}->{'filename'}, '/')+1);
+ $subdir = substr($helper->{VARS}->{'filename'},
+ 0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
+ } else {
+ ($map, $id, $url) = split(/___/, $symb);
+ $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
+
+ if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
+ my $url = $helper->{VARS}->{'postdata'};
+ $resourceTitle = substr($url, rindex($url, '/') + 1);
+ }
+ $subdir = &Apache::lonnet::filelocation("", $url);
}
Apache::lonhelper::registerHelperTags();
- my $subdir = &Apache::lonnet::filelocation("", $url);
-
# "Delete everything after the last slash."
$subdir =~ s|/[^/]+$||;
- if (not defined $helper->{VARS}->{'construction'}) {
- $subdir = '/home/httpd/html/res'.$subdir;
- } else {
- $helper->{VARS}->{'construction'}=~/^([^\/]+)\/\/([^\/]+)(.*)\/[^\/]*$/;
- $subdir = $3;
- $subdir=~/\/~([^\/]+)\/(.*)$/;
- $subdir = '/home/'.$1.'/public_html/'.$2;
+ if (not $helper->{VARS}->{'construction'}) {
+ $subdir='/home/httpd/html/res/'.$subdir;
}
-#### $r->print('Dir: '.$subdir.' ');
-#### return OK;
# What can be printed is a very dynamic decision based on
@@ -1750,12 +1782,15 @@ sub printHelper {
# the helper by hand.
my $printChoices = [];
my $paramHash;
- # We can always print the current screen.
- push @{$printChoices}, ["Current resource $resourceTitle (prints what you just saw on the screen)", 'current_document', 'PAGESIZE'];
+ if ($resourceTitle) {
+ push @{$printChoices}, ["$resourceTitle (prints what you just saw on the screen)", 'current_document', 'PAGESIZE'];
+ }
+
+ $r->print($helper->{VARS}->{'postdata'});
# If we're in a sequence...
- if (not defined $helper->{'VARS'}->{'construction'}) {
+ if ($helper->{'VARS'}->{'construction'} ne '1') {
# Allow problems from sequence
push @{$printChoices}, ["Problem(s) from $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];
# Allow all resources from sequence
@@ -1863,6 +1898,20 @@ CHOOSE_FROM_SUBDIR
$helper->declareVar('PRINT_TYPE');
$paramHash->{CHOICES} = $printChoices;
Apache::lonhelper::choices->new();
+
+ if ($ENV{'request.role.adv'}) {
+ $paramHash = Apache::lonhelper::getParamHash();
+ $paramHash->{MESSAGE_TEXT} = "
Next option is available only for advanced users:
";
+ Apache::lonhelper::message->new();
+ $paramHash = Apache::lonhelper::getParamHash();
+ $paramHash->{'variable'} = 'ANSWER_TYPE';
+ $helper->declareVar('ANSWER_TYPE');
+ $paramHash->{CHOICES} = [
+ ['Print without answer', 'yes'],
+ ['Print with answers', 'no'] ];
+ Apache::lonhelper::choices->new();
+ }
+
Apache::lonprintout::page_format_state->new("FORMAT");
# Generate the PAGESIZE state which will offer the user the margin