--- loncom/interface/lonprintout.pm 2002/09/06 17:46:13 1.56 +++ loncom/interface/lonprintout.pm 2002/09/09 20:20:40 1.58 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.56 2002/09/06 17:46:13 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.58 2002/09/09 20:20:40 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,7 +45,6 @@ use Apache::lonxml; use Apache::lonnet; use Apache::loncommon; use Apache::inputtags; -use Apache::loncoursedata; use Apache::grades; use Apache::edit; use Apache::File(); @@ -62,7 +61,6 @@ sub headerform {
$ENV{'form.postdata'}

-

What do you want to print? Make a choice.


ENDHEADER } @@ -70,6 +68,7 @@ ENDHEADER sub menu_for_output { my $r = shift; $r->print(<What do you want to print? Make a choice.
Current document @@ -109,13 +108,6 @@ ENDMENUOUT4 Number of columns: @@ -126,6 +118,77 @@ ENDMENUOUT5 } +sub problem_choice_menu { + my $r = shift; + 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'},''); + } else { + @content_directory = &Apache::lonnet::dirlist($subdirtoprint); + } + for (my $iy=0;$iy<=$#content_directory;$iy++) { + my @tempo_array = split(/&/,$content_directory[$iy]); + if ($tempo_array[0] =~ m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/) { + push(@list_of_files,$tempo_array[0]); + } + } + $subdirtoprint =~ s/\/$//; + for (my $i=0;$i<=$#list_of_files;$i++) { + $list_of_files[$i] = $subdirtoprint.'/'.$list_of_files[$i]; + } + $r->print(< + + + +

Mark problems which you want to print

+ +  + +

+ENDMENUOUT1 + my $i; + foreach my $file (@list_of_files) { + $r->print('
'. + $file); + $i++; + } + $r->print(< + + + +ENDMENUOUT2 +} + + sub additional_class_menu { my $r = shift; $r->print(<

Mark students which assignments you want to print

ENDMENUOUT1 - my $c = $r->connection; - my %cache; - my $courseID = $ENV{'request.course.id'}; - my $classlist = &Apache::loncoursedata::DownloadClasslist($courseID,$cache{'ClasslistTimestamp'},$c); - &Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c); - my @all_students = split(':::',$cache{'NamesOfStudents'}); - my @active_students = (); - foreach my $student (@all_students) { - if ($cache{$student.':Status'} eq 'Active') { - push @active_students,$student; - } - } - my $what_to_print = ''; + my %courselist=&Apache::lonnet::dump( + 'classlist', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + my $now=time; + $r->print(< + function checkall() { + for (i=0; i +  + +  + +

+ENDDISHEADER my $i = 0; - foreach my $student (@active_students) { - $what_to_print .= '

'; -# $what_to_print .= ''; - $i++; + foreach (sort keys %courselist) { + my ($end,$start)=split(/\:/,$courselist{$_}); + my $active=1; + if (($end) && ($now>$end)) { $active=0; } + if ($active) { + my ($sname,$sdom)=split(/\:/,$_); + my %reply=&Apache::lonnet::get('environment', + ['firstname','middlename','lastname','generation'], + $sdom,$sname); + my $section=&Apache::lonnet::usection + ($sdom,$sname,$ENV{'request.course.id'}); + $r->print( + '
'. + $reply{'firstname'}.' '. + $reply{'middlename'}.' '. + $reply{'lastname'}.' '. + $reply{'generation'}. + ' ('.$_.') '.$section); + $i++; + } } - $what_to_print .= '
'.$cache{$student.':fullname'}.'
'.$cache{$student.':fullname'}.'
'; $r->print(< +
@@ -170,14 +276,21 @@ sub additional_print_menu { for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) { $what_to_print .= ''; } + for (my $i=0; $i<$ENV{'form.numberofproblems'};$i++) { + $what_to_print .= ''; + } $r->print(< + -Enter width of the page:
+Define page layout parameters:
+Width:
+Height:
+Left margin:
@@ -339,7 +452,7 @@ ENDPART #loop over students foreach my $person (@students) { my $current_output = ''; - my ($username,$userdomain) = split /:/,$person; + my ($usersection,$username,$userdomain) = split /:/,$person; my $fullname = &Apache::grades::get_fullname($username,$userdomain); #goes through all resources, checks if they are available for current student, and produces output foreach my $curres (@master_seq) { @@ -358,48 +471,30 @@ ENDPART $current_output =~ s/\\begin{document}/\\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$fullname}}\\hskip 1\.4in } \\vskip 5 mm /; $result .= $current_output; } - $result = &additional_cleanup($result); - - - - - - } elsif ($choice eq 'Subdirectory print') { - 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'},''); - } else { - @content_directory = &Apache::lonnet::dirlist($subdirtoprint); - } - for (my $iy=0;$iy<=$#content_directory;$iy++) { - my @tempo_array = split(/&/,$content_directory[$iy]); - if ($tempo_array[0] =~ m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/) { - push(@list_of_files,$tempo_array[0]); + #prints selected problems from the subdirectory + my @list_of_files = (); + for (my $i=0; $i<$ENV{'form.numberofproblems'};$i++) { + if ($ENV{'form.whattoprint'.$i}=~/^\//) { +# $result.= $ENV{'form.whattoprint'.$i}.' FFF '; + push @list_of_files,$ENV{'form.whattoprint'.$i}; } } - $subdirtoprint =~ s/\/$//; for (my $i=0;$i<=$#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}}/; - $result .= $texversion; + my $urlp = $list_of_files[$i]; + if ($urlp=~/\//) { + 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}}/; + $result .= $texversion; + } } $result = &additional_cleanup($result); @@ -900,6 +995,8 @@ sub handler { if ($ENV{'form.phase'} eq 'two') { if($ENV{'form.choice'} eq 'All class print') { &additional_class_menu($r); + } elsif($ENV{'form.choice'} eq 'Subdirectory print') { + &problem_choice_menu($r); } else { $ENV{'form.phase'} = 'three'; }