--- loncom/interface/lonprintout.pm 2002/12/11 21:33:16 1.97 +++ loncom/interface/lonprintout.pm 2003/01/13 21:20:51 1.104 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.97 2002/12/11 21:33:16 albertel Exp $ +# $Id: lonprintout.pm,v 1.104 2003/01/13 21:20:51 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -66,11 +66,12 @@ sub headerform {
ENDHEADER - if ($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) { - $r->print(<print(<Path to current document: $ENV{'form.postdata'}

ENDHEADER1 -} + } } @@ -81,9 +82,10 @@ sub menu_for_output { if ($title_for_single_resource ne '') {$title_for_single_resource = '"'.$title_for_single_resource.'"';} if ($title_for_sequence ne '') {$title_for_sequence = '"'.$title_for_sequence.'"';} if ($title_for_main_map ne '') {$title_for_main_map = '"'.$title_for_main_map.'"';} + $ENV{'form.postdata'} =~ s|http://[^/]+||; my $subdir_to_print = $ENV{'form.postdata'}; $subdir_to_print =~ m/\/([^\/]+)$/; - $subdir_to_print =~ s/$1//; + $subdir_to_print =~ s/\Q$1\E//; $r->print(<What do you want to print? Make a choice.
@@ -151,11 +153,14 @@ ENDMENUOUT5 sub sequence_content_menu { my ($key_to,$r) = @_; + my $primary_sequence; my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); my @sequence = split('___',$symbolic); - my $primary_sequence = '/res/'.$sequence[0]; + if ($sequence[0]=~/^uploaded/) {$primary_sequence = '/'.$sequence[0];} + else {$primary_sequence = '/res/'.$sequence[0];} my @master_seq = &coming_from_hash($primary_sequence,$sequence[0]); - my @master_seq_view = @master_seq; + my @master_seq_view = sort @master_seq; + @master_seq = sort @master_seq; for (my $i=0;$i<=$#master_seq_view;$i++) { $master_seq_view[$i]=~/\/([^\/]+)$/; $master_seq_view[$i]=$1; @@ -193,7 +198,7 @@ ENDMENUOUT1 my $inc=0; for (my $i=0;$i<=$#master_seq_view;$i++) { if ($key_to==1 && $master_seq_view[$i]=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { - $r->print('
'. + $r->print('
'."\n". $master_seq_view[$i]); $inc++; } elsif ($key_to==0 && $master_seq_view[$i]=~/\.(problem|exam|quiz|assess|survey|form|library|xml|htm|html|page)$/) { @@ -217,14 +222,13 @@ sub problem_choice_menu { my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); $subdirtoprint =~ s/\/[^\/]+$//; my @list_of_files = (); - 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'},''); + if ($subdirtoprint =~ m|/home/([^/]+)/public_html|) { + #localmachine CSTR space + my $user=$1; + my $domain=$Apache::lonnet::perlvar{'lonDefDomain'}; + @content_directory = &Apache::lonnet::dirlist($subdirtoprint, + $domain, $user,''); } else { @content_directory = &Apache::lonnet::dirlist($subdirtoprint); } @@ -269,7 +273,7 @@ sub problem_choice_menu {

ENDMENUOUT1 my $i=0; - foreach my $file (@list_of_files) { + foreach my $file (sort @list_of_files) { $r->print('
'. $file); $i++; @@ -330,7 +334,7 @@ ENDMENUOUT1 }   - +  

@@ -431,7 +435,8 @@ ENDPART if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';} if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;} } - if (($choice eq 'Standard LaTeX output for current document') && ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./)) { + if (($choice eq 'Standard LaTeX output for current document') && + ($ENV{'form.url'}=~m|^/~|)) { if ($ENV{'form.layout'} eq '') {$layout = 'CAPA';} if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';} if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;} @@ -440,8 +445,11 @@ ENDPART my $number_of_columns = 1; #used only for pages to determine the width of the cell my $selectionmade = ''; my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns); - my $LaTeXwidth; - + if ($numberofcolumns == 1) { + $textwidth=$ENV{'form.width'}; + $textheight=$ENV{'form.height'}; + } + my $LaTeXwidth; if ($textwidth=~/(\d+\s*cm)/) { $LaTeXwidth = $1*10; } elsif ($textwidth=~/(\d+\s*mm)/) { @@ -498,7 +506,7 @@ ENDPART $moreenv{'form.grade_target'}='tex'; $moreenv{'form.textwidth'}=$LaTeXwidth; &Apache::lonnet::appenv(%moreenv); - &Apache::lonnet::logthis("Trying to get $urlp with symb $symb"); + #&Apache::lonnet::logthis("Trying to get $urlp with symb $symb"); my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$symb)); &Apache::lonnet::delenv('form.grade_target','form.textwidth'); if ($urlp =~ m/\.page/) { @@ -616,8 +624,8 @@ ENDPART $moreenv{'form.grade_target'}='tex'; $moreenv{'form.textwidth'}=$LaTeXwidth; &Apache::lonnet::appenv(%moreenv); - if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { - $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/; + if ($urlp =~ m|/home/([^/]+)/public_html|) { + $urlp =~ s|/home/([^/]*)/public_html|/~$1|; } my $texversion=&Apache::lonnet::ssi($urlp); &Apache::lonnet::delenv('form.grade_target','form.textwidth'); @@ -725,7 +733,13 @@ sub coming_from_hash { my $mapid = $hash{'map_pc_'.$mainsequence}; my $mapstart = $hash{'map_start_'.$mainsequence}; my $mapfinish = $hash{'map_finish_'.$mainsequence}; - my ($presymb) = split(/___/,$symb); + my ($presymb); + if ($symb) { + ($presymb)=split(/___/,$symb); + } else { + $presymb=$mainsequence; + $presymb=~s|^/res/||; + } $presymb = $presymb.'___'; my $current_resource = $mapstart; while ($current_resource ne $mapfinish) { @@ -1178,8 +1192,14 @@ sub character_chart { sub page_format_transformation { - my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; - my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns); + my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; + my ($textwidth,$textheight,$oddoffset,$evenoffset); + $assignment=~s/_/ /g; + if ($numberofcolumns != 1) { + ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns); + } else { + ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'}); + } my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; if ($layout eq 'CBI') { $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}}} \\hfill $courseidinfo} \\vskip 5 mm /; @@ -1187,7 +1207,7 @@ sub page_format_transformation { if ($choice ne 'All class print') { $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\markboth{}{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}} $courseidinfo - $assignment}\\pagestyle{myheadings}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}/; } else { - $text =~ s/\\begin{document}/\\setlength{\\textheight}{$textheight}\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\textwidth}{$textwidth}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1} \\vskip 5 mm /; + $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1} \\vskip 5 mm /; } } return $text; @@ -1213,9 +1233,14 @@ sub details_for_menu { my $name_of_resourse = $hash{'title_'.$hash{'ids_'.$ENV{'form.postdata'}}}; my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'}); my ($map,$id,$resource)=split(/___/,$symbolic); - my $name_of_sequence = $hash{'title_'.$hash{'ids_/res/'.$map}}; + my $name_of_sequence; + if ($map=~/^uploaded/) { + $name_of_sequence = $hash{'title_'.$hash{'ids_/'.$map}}; + } else { + $name_of_sequence = $hash{'title_'.$hash{'ids_/res/'.$map}}; + } if ($name_of_sequence =~ /^\s*$/) { - $map =~ m|([^/]+)$|; + $map =~ m|([^/]+)$|; $name_of_sequence = $1; } my $name_of_map = $hash{'title_'.$hash{'ids_/res/'.$ENV{'request.course.uri'}}};