--- loncom/interface/lonprintout.pm 2003/02/14 00:23:37 1.114 +++ loncom/interface/lonprintout.pm 2003/02/14 02:21:35 1.115 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.114 2003/02/14 00:23:37 bowersj2 Exp $ +# $Id: lonprintout.pm,v 1.115 2003/02/14 02:21:35 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1355,6 +1355,69 @@ sub handler { } +use Apache::lonwizard; + +sub printWizard { + my $r = shift; + + if ($ENV{'request.course.id'}) { + my $fn=$ENV{'request.course.fn'}; + tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640); + } + + if ($r->header_only) { + if ($ENV{'browser.mathml'}) { + $r->content_type('text/xml'); + } else { + $r->content_type('text/html'); + } + $r->send_http_header; + return OK; + } + + # Send header, nocache + if ($ENV{'browser.mathml'}) { + $r->content_type('text/xml'); + } else { + $r->content_type('text/html'); + } + &Apache::loncommon::no_cache($r); + $r->send_http_header; + $r->rflush(); + + my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu; + + my $wizard = Apache::lonwizard->new("Printing Wizard"); + # PRINT_TYPE: What the user wants to print (current docs, + # whole sequence, etc. + $wizard->declareVars(['PRINT_TYPE']); + + my $subdir = $ENV{'form.postdata'}; + $subdir =~ s|http://[^/]+||; + $subdir =~ m/\/([^\/]+)$/; + $subdir =~ s/\Q$1\E//; + + # This code also shows up above... which is prefered? Is one + # right for this context? + #my $subdir = &Apache::lonnet::filelocation("",$ENV{'form.url'}); + #$subdir =~ s/\/[^\/]+$//; + + Apache::lonwizard::switch_state->new($wizard, "START", "Selecting Resources to Print", "PRINT_TYPE", [ + ['current_document', "$resourceTitle (exactly what was on the screen)", 'CHOOSE_FORMAT'], + ['map_problems', "Problems from $sequenceTitle", 'CHOOSE_FORMAT'], + ['map_problems_pages', "All of $sequenceTitle", 'CHOOSE_FORMAT'], + ['problems_for_students', "Problems from $sequenceTitle for selected students", 'CHOOSE_FORMAT'], + ['problems_from_directory', "Problems from $subdir", 'CHOOSE_FORMAT'] ], + "What do you want to print?"); + + $r->print($wizard->display()); + + untie %hash; + + return OK; + +} + 1; __END__