--- loncom/interface/lonprintout.pm 2002/07/23 14:09:45 1.41
+++ loncom/interface/lonprintout.pm 2002/08/09 18:06:46 1.48
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.41 2002/07/23 14:09:45 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.48 2002/08/09 18:06:46 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -72,13 +72,14 @@ sub menu_for_output {
Current document
(you will print what you see on the screen)
ENDMENUOUT1
- if (not $ENV{'request.role'}=~m/^au\./) {
+ if ((not $ENV{'request.role'}=~m/^au\./) and (not $ENV{'request.role'}=~m/^ca\./)) {
$r->print(< All problems from the primary sequence
The whole primary sequence (problems plus all html and xml files)
All problems from the top level sequence
ENDMENUOUT2
+ }
my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'});
$subdirtoprint =~ s/\/[^\/]+$//;
if (&Apache::lonnet::allowed('bre',$subdirtoprint) eq 'F') {
@@ -86,7 +87,6 @@ ENDMENUOUT2
All problems from current subdirectory (where this particular problem is)
ENDMENUOUT4
}
- }
$r->print(<
And what page format do you prefer?
@@ -98,7 +98,17 @@ ENDMENUOUT4
- Number of columns:
+ Number of columns:
@@ -130,12 +140,15 @@ ENDPART
my $laystyle = 'book';
my $result = '';
my $number_of_columns = 1;
+# my $number_of_columns = $ENV{'form.numberofcolumns'};
if ($choice eq 'Standard LaTeX output for current document') {
#-- single document - problem, page, html, xml
my %moreenv;
$moreenv{'form.grade_target'}='tex';
- if ($ENV{'request.role'}=~m/^au\./) {$ENV{'form.url'}=~s/http:\/\/[^\/]+//;}
+ if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
+ $ENV{'form.url'}=~s/http:\/\/[^\/]+//;
+ }
$moreenv{'request.filename'}=$ENV{'form.url'};
&Apache::lonnet::appenv(%moreenv);
my $texversion=&Apache::lonnet::ssi($ENV{'form.url'});
@@ -185,62 +198,123 @@ ENDPART
} elsif ($choice eq 'Standard LaTeX output for the top level sequence') {
my @master_seq = ();
my @add_file_seq = ();
-#-- where is the main sequence of the course?
+ # where is the main sequence of the course?
my $main_seq = '/res/'.$ENV{'request.course.uri'};
my $file=&Apache::lonnet::filelocation("",$main_seq);
my $filecontents=&Apache::lonnet::getfile($file);
my @file_seq = &content_map($filecontents);
-#-- do we have any other sequence inside?
+ for (my $iu=0;$iu<=$#file_seq;$iu++) {
+ $file_seq[$iu]=~s/^"//;
+ $file_seq[$iu]=~s/"$//;
+ $file_seq[$iu]=&Apache::lonnet::filelocation("",$file_seq[$iu]);
+#remove $result .= ' SSS '.$file_seq[$iu].' FFF ';
+ }
my $i=0;
- while ($i<=$#file_seq) {
- $_ = $file_seq[$i];
- if (/\.sequence$/) {
- $file = &Apache::lonnet::filelocation("",$file_seq[$i]);
- $filecontents=&Apache::lonnet::getfile($file);
- @add_file_seq = &content_map($filecontents);
- splice(@file_seq,$i,1,@add_file_seq);
- @add_file_seq = ();
- $i = -1;
+ while ($i<=$#file_seq) {
+ unless ($file_seq[$i]=~m/\.(problem|page)/) {
+ if ($file_seq[$i]=~m/\.sequence/) {
+ my $filecontents=&Apache::lonnet::getfile($file_seq[$i]);
+ my @newfile_seq = &content_map($filecontents);
+ $result .=' START '.$i.' LOOK '.$filecontents.' FINISH ';
+# splice @file_seq,$1,1,@newfile_seq;
+# $i=-1;
+ } else {
+ splice @file_seq,$1,1;
+ }
}
+
+
+
+
$i++;
}
- @master_seq = @file_seq;
+ for (my $iu=0;$iu<=$#file_seq;$iu++) {
+ $result .= ' SSS '.$file_seq[$iu].' FFF ';
+ }
+
+
+ # do we have any other sequence inside?
+# $result.=$#file_seq.' ';
+## my $i=1;
+## while ($i<=$#file_seq) {
+# $result.=' '.$file_seq[$i].' ';
+## $file_seq[$i]=~s/^"//;
+## $file_seq[$i]=~s/"$//;
+## if ($file_seq[$i]=~m/\.sequence\s*$/) {
+## $file = &Apache::lonnet::filelocation("",$file_seq[$i]);
+# $result.=' location '.$file.' ';
+# $result .= 'FFFFFFFFF'.$file.' ';
+## $filecontents=&Apache::lonnet::getfile($file);
+## @add_file_seq = &content_map($filecontents);
+
+#
+# for (my $iu=0;$iu<=$#add_file_seq;$iu++) {
+# $result .= ' SDSD '.$add_file_seq[$iu].' FDFD ';
+# }
+#
+
+
+## splice(@file_seq,$i,1,@add_file_seq);
+## @add_file_seq = ();
+## $i = -1;
+## }
+## $i++;
+## last; #do not forget to remove
+## }
+## @master_seq = @file_seq;
+
+#
+# for (my $iu=0;$iu<=$#file_seq;$iu++) {
+# $result .= ' SSS '.$file_seq[$iu].' FFF ';
+# }
+#
+
#-- produce an output string
- for (my $i=0;$i<=$#master_seq;$i++) {
- $_ = $master_seq[$i];
- m/\"(.*)\"/;
- $_ = $1;
- my $urlp = $1;
- if (/\.(problem|exam|quiz|assess|survey|form|library)/) {
- my %moreenv;
- $moreenv{'form.grade_target'}='tex';
- &Apache::lonnet::appenv(%moreenv);
- my $texversion=&Apache::lonnet::ssi($urlp);
- &Apache::lonnet::delenv('form.grade_target');
- $result .= $texversion;
- }
- }
- $result = &additional_cleanup($result);
+### for (my $i=0;$i<=$#master_seq;$i++) {
+### $_ = $master_seq[$i];
+### m/\"(.*)\"/;
+### $_ = $1;
+### my $urlp = $1;
+### if (/\.(problem|exam|quiz|assess|survey|form|library)/) {
+### my %moreenv;
+### $moreenv{'form.grade_target'}='tex';
+### &Apache::lonnet::appenv(%moreenv);
+### my $texversion=&Apache::lonnet::ssi($urlp);
+### &Apache::lonnet::delenv('form.grade_target');
+### $result .= $texversion;
+### }
+### }
+### $result = &additional_cleanup($result);
} elsif ($choice eq 'Subdirectory print') {
my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'});
$subdirtoprint =~ s/\/[^\/]+$//;
my @list_of_files = ();
- my $localdirectory = $subdirtoprint;
- $localdirectory =~ s/.*(\/res\/)/$1/;
- my @content_directory = &Apache::lonnet::dirlist($localdirectory);
+ if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
+ $subdirtoprint =~ s/^[^~]*~(\w+)\//\/home\/$1\/public_html\//;
+ } else {
+ $subdirtoprint =~ s/.*(\/res\/)/$1/;
+ }
+ my @content_directory = ();
+ if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
+ @content_directory = &Apache::lonnet::dirlist($subdirtoprint,$ENV{'user.domain'}, $ENV{'user.name'},'');
+ } else {
+ @content_directory = &Apache::lonnet::dirlist($subdirtoprint);
+ }
for (my $iy=0;$iy<=$#content_directory;$iy++) {
my @tempo_array = split(/&/,$content_directory[$iy]);
- $content_directory[$iy] = $tempo_array[0];
- if ($content_directory[$iy] =~ m/^[^\.]+\.problem$/) {
- push @list_of_files,$content_directory[$iy];
+ if ($tempo_array[0] =~ m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/) {
+ push(@list_of_files,$tempo_array[0]);
}
}
- $localdirectory =~ s/\/$//;
+ $subdirtoprint =~ s/\/$//;
for (my $i=0;$i<=$#list_of_files;$i++) {
- my $urlp = $localdirectory.'/'.$list_of_files[$i];
+ my $urlp = $subdirtoprint.'/'.$list_of_files[$i];
my %moreenv;
$moreenv{'form.grade_target'}='tex';
&Apache::lonnet::appenv(%moreenv);
+ if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) {
+ $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/;
+ }
my $texversion=&Apache::lonnet::ssi($urlp);
&Apache::lonnet::delenv('form.grade_target');
$texversion =~ s/(\\begin{document})/$1 {\\tiny\\begin{verbatim}$urlp\\end{verbatim}}/;
@@ -284,10 +358,9 @@ ENDPART
$first_comment = index($result,'