[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Mon, 05 May 2003 18:48:15 -0000
This is a MIME encoded message
--sakharuk1052160495
Content-Type: text/plain
sakharuk Mon May 5 14:48:15 2003 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Can print assignments for students. The possibility to add a few empty pages after each student's output is restored (to print every student's assignment from the beggining of the next physical sheet of paper). Some additional work from Jeremy is needed - select students over sections.
--sakharuk1052160495
Content-Type: text/plain
Content-Disposition: attachment; filename="sakharuk-20030505144815.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.149 loncom/interface/lonprintout.pm:1.150
--- loncom/interface/lonprintout.pm:1.149 Mon May 5 14:01:21 2003
+++ loncom/interface/lonprintout.pm Mon May 5 14:48:15 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.149 2003/05/05 18:01:21 bowersj2 Exp $
+# $Id: lonprintout.pm,v 1.150 2003/05/05 18:48:15 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1430,12 +1430,6 @@
my $flag_latex_header_remove = 'NO';
my $flag_page_in_sequence = 'NO';
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
-
-# foreach my $key (@master_seq) {
-# $r->print(' '.$key.'<br />');
-# }
-# return OK;
-
for (my $i=0;$i<=$#master_seq;$i++) {
$master_seq[$i]=~/___\d+___(.*)$/;
my $urlp='/res/'.$1;
@@ -1470,104 +1464,59 @@
&Apache::lonnet::delenv('form.counter');
if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;}
$result .= '\end{document}';
-# } elsif ($choice eq 'Standard LaTeX output for the top level sequence') {
-# # where is the main sequence of the course?
-# $selectionmade = 4;
-# my $main_seq=&Apache::lonnet::clutter($ENV{'request.course.uri'});
-# my @file_seq = &coming_from_hash($main_seq);
-# for (my $i=0;$i<=$#file_seq;$i++) {
-# my ($path,$title,$symb) = split /&&/,$file_seq[$i];
-# $file_seq[$i] = $path.'&&'.$symb;
-# }
-# my $flag_latex_header_remove = 'NO';
-# #-- produce an output string
-# for (my $i=0;$i<=$#file_seq;$i++) {
-# if (not $file_seq[$i]=~/^&&/) {
-# my ($urlp,$symb) = split /&&/, $file_seq[$i];
-# $urlp=~s/\/home\/httpd\/html//;
-# if ($urlp=~m/\.(problem|exam|quiz|assess|survey|form|library)/) {
-# my %moreenv;
-# $moreenv{'form.grade_target'}='tex';
-# $moreenv{'form.textwidth'}=$LaTeXwidth;
-# &Apache::lonnet::appenv(%moreenv);
-# my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$symb));
-# &Apache::lonnet::delenv('form.grade_target','form.textwidth');
-# if ($flag_latex_header_remove ne 'NO') {
-# $texversion = &latex_header_footer_remove($texversion);
-# } else {
-# $texversion =~ s/\\end{document}//;
-# }
-# $result .= $texversion;
-# $flag_latex_header_remove = 'YES';
-# }
-# }
-# }
-# $result .= '\end{document}';
-# } elsif ($choice eq 'All class print') {
-# #-- prints assignments for whole class or for selected students
-# $selectionmade = 5;
-# my @students = ();
-# for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) {
-# if ($ENV{'form.whomtoprint'.$i}=~/:/) {
-# push @students,$ENV{'form.whomtoprint'.$i};
-# }
-# }
-# #where is the primary sequence containing current resource (the same for all students)?
-# my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
-# my @sequence = split('___',$symbolic);
-# my $primary_sequence;
-#
-# $primary_sequence=&Apache::lonnet::clutter($sequence[0]);
-# my @master_seq = &coming_from_hash($primary_sequence);
-# for (my $i=0;$i<=$#master_seq;$i++) {
-# my ($path,$title,$symb) = split /&&/,$master_seq[$i];
-# $master_seq[$i] = $path.'&&'.$symb;
-# }
-# #loop over students
-# my $flag_latex_header_remove = 'NO';
-# my %moreenv;
-# $moreenv{'form.textwidth'}=$LaTeXwidth;
-# &Apache::lonnet::appenv(%moreenv);
-# my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
-# foreach my $person (@students) {
-# my $current_output = '';
+ } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {
+ #-- prints assignments for whole class or for selected students
+ $selectionmade=5;
+ my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'};
+ my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
+ #loop over students
+ my $flag_latex_header_remove = 'NO';
+ my %moreenv;
+ $moreenv{'form.textwidth'}=$LaTeXwidth;
+ &Apache::lonnet::appenv(%moreenv);
+ my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
+ foreach my $person (@students) {
+ my $current_output = '';
# my ($usersection,$username,$userdomain) = split /:/,$person;
-# my $fullname = &get_name($username,$userdomain);
-# #goes through all resources, checks if they are available for current student, and produces output
-# foreach my $curresline (@master_seq) {
+ my ($username,$userdomain) = split /:/,$person;
+ my $fullname = &get_name($username,$userdomain);
+ #goes through all resources, checks if they are available for current student, and produces output
+ foreach my $curresline (@master_seq) {
# my ($curres,$symb) = split /&&/, $curresline;
# if ($curres=~ m/\.(problem|exam|quiz|assess|survey|form|library)/) {
-# my ($map,$id,$res_url) = split(/___/,$symb);
-# if (&Apache::lonnet::allowed('bre',$res_url)) {
-# my $rendered = &Apache::loncommon::get_student_view($symb,$username,$userdomain,
-# $ENV{'request.course.id'},'tex');
-# if ($flag_latex_header_remove eq 'YES') {
-# $rendered = &latex_header_footer_remove($rendered);
-# } else {
-# $rendered =~ s/\\end{document}//;
-# }
-# $current_output .= $rendered;
-# }
-# $flag_latex_header_remove = 'YES';
-# }
-# }
-# my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
-# if ($current_output=~/\\documentclass/) {
-# $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\vskip 3 mm /;
-# } else {
-# my $blanspages = '';
-# for (my $j=0;$j<$ENV{'form.addedpages'};$j++) {$blanspages.='\clearpage\strut\clearpage';}
-# $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage \\vskip 3mm'.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}} - '.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}\hskip 1.4in } \vskip 5 mm '.$current_output;
-# }
-# $result .= $current_output;
-# &Apache::lonnet::delenv('form.counter');
-# &Apache::lonxml::init_counter();
-# &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
-# 'last student '.$fullname);
-# }
-# &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
-# $result .= '\end{document}';
-# &Apache::lonnet::delenv('form.textwidth');
+ if ($curresline=~ m/\.(problem|exam|quiz|assess|survey|form|library)$/) {
+# my ($map,$id,$res_url) = split(/___/,$symb);$curresres
+ my ($map,$id,$res_url) = split(/___/,$curresline);
+ if (&Apache::lonnet::allowed('bre',$res_url)) {
+ my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,
+ $ENV{'request.course.id'},'tex');
+ if ($flag_latex_header_remove eq 'YES') {
+ $rendered = &latex_header_footer_remove($rendered);
+ } else {
+ $rendered =~ s/\\end{document}//;
+ }
+ $current_output .= $rendered;
+ }
+ $flag_latex_header_remove = 'YES';
+ }
+ }
+ my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+ if ($current_output=~/\\documentclass/) {
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\vskip 3 mm /;
+ } else {
+ my $blanspages = '';
+ for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\clearpage\strut\clearpage';}
+ $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage \\vskip 3mm'.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}} - '.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}\hskip 1.4in } \vskip 5 mm '.$current_output;
+ }
+ $result .= $current_output;
+ &Apache::lonnet::delenv('form.counter');
+ &Apache::lonxml::init_counter();
+ &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
+ 'last student '.$fullname);
+ }
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $result .= '\end{document}';
+ &Apache::lonnet::delenv('form.textwidth');
# } elsif ($choice eq 'Subdirectory print') {
# #prints selected problems from the subdirectory
# $selectionmade = 6;
@@ -1685,12 +1634,12 @@
return OK;
}
- my $loaderror=&Apache::lonnet::overloaderror($r);
- if ($loaderror) { return $loaderror; }
- $loaderror=
- &Apache::lonnet::overloaderror($r,
- $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
- if ($loaderror) { return $loaderror; }
+# my $loaderror=&Apache::lonnet::overloaderror($r);
+# if ($loaderror) { return $loaderror; }
+# $loaderror=
+# &Apache::lonnet::overloaderror($r,
+# $ENV{'course.'.$ENV{'request.course.id'}.'.home'});
+# if ($loaderror) { return $loaderror; }
$r->content_type('text/html');
$r->send_http_header;
--sakharuk1052160495--