[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Mon, 12 May 2003 18:14:01 -0000
bowersj2 Mon May 12 14:14:01 2003 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Adding the choice to print out answers for Alex. He'll customize the "if"
clause and possibly the text.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.160 loncom/interface/lonprintout.pm:1.161
--- loncom/interface/lonprintout.pm:1.160 Thu May 8 15:16:42 2003
+++ loncom/interface/lonprintout.pm Mon May 12 14:14:01 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.160 2003/05/08 19:16:42 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.161 2003/05/12 18:14:01 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1363,29 +1363,28 @@
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
#-- single document - problem, page, html, xml, ...
my $currentURL;
- if ($helper->{'VARS'}->{'construction'} ne '1') {
- #prins published resource
+ if (not defined $helper->{'VARS'}->{'construction'}) {
$currentURL=$helper->{'VARS'}->{'postdata'};
} else {
- #prins resource from the construction space
- $currentURL=$helper->{'VARS'}->{'filename'};
- $currentURL=~s/\/home\//\/~/;
- $currentURL=~s/public_html\///;
+ $currentURL=$helper->{'VARS'}->{'construction'};
}
$selectionmade = 1;
if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
- 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','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';
+ 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 {
# $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;
@@ -1393,7 +1392,9 @@
# $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')) {
@@ -1584,7 +1585,7 @@
# my $key;
# foreach $key (keys %{$helper->{'VARS'}}) {
-# $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-<br />');
+# $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<br />');
# }
# return OK;
@@ -1749,9 +1750,16 @@
# "Delete everything after the last slash."
$subdir =~ s|/[^/]+$||;
- if (not $helper->{VARS}->{'construction'}) {
- $subdir='/home/httpd/html/res/'.$subdir;
+ 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;
}
+#### $r->print('Dir: '.$subdir.' ');
+#### return OK;
# What can be printed is a very dynamic decision based on
@@ -1775,7 +1783,7 @@
$r->print($helper->{VARS}->{'postdata'});
# If we're in a sequence...
- if ($helper->{'VARS'}->{'construction'} ne '1') {
+ if (!defined($helper->{'VARS'}->{'construction'})) {
# Allow problems from sequence
push @{$printChoices}, ["Problem(s) from <b>$sequenceTitle</b>", 'map_problems', 'CHOOSE_PROBLEMS'];
# Allow all resources from sequence
@@ -1878,11 +1886,26 @@
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{MESSAGE_TEXT} = "";
Apache::lonhelper::message->new();
+
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'PRINT_TYPE';
$helper->declareVar('PRINT_TYPE');
$paramHash->{CHOICES} = $printChoices;
Apache::lonhelper::choices->new();
+
+ if (1) {
+ $paramHash = Apache::lonhelper::getParamHash();
+ $paramHash->{MESSAGE_TEXT} = "<hr>";
+ Apache::lonhelper::message->new();
+
+ $paramHash = Apache::lonhelper::getParamHash();
+ $paramHash->{CHOICES} = [
+ ['Print with answer', '1'],
+ ['Print without answers', '0'] ];
+ $paramHash->{'variable'} = 'PRINT_WITH_ANSWERS';
+ Apache::lonhelper::choices->new();
+ }
+
Apache::lonprintout::page_format_state->new("FORMAT");
# Generate the PAGESIZE state which will offer the user the margin