Diff for /loncom/interface/lonprintout.pm between versions 1.226 and 1.237

version 1.226, 2003/09/05 02:25:30 version 1.237, 2003/09/22 20:00:08
Line 49  use Apache::grades; Line 49  use Apache::grades;
 use Apache::edit;  use Apache::edit;
 use Apache::File();  use Apache::File();
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
   use Apache::lonratedt;
 use POSIX qw(strftime);  use POSIX qw(strftime);
 use GDBM_File;  use GDBM_File;
   
Line 530  sub details_for_menu { Line 531  sub details_for_menu {
   
     my $name_of_resourse = $hash{'title_'.$hash{'ids_'.$ENV{'form.postdata'}}};      my $name_of_resourse = $hash{'title_'.$hash{'ids_'.$ENV{'form.postdata'}}};
     my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'});      my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'});
     my ($map,$id,$resource)=split(/___/,$symbolic);      my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic);
     $map=&Apache::lonnet::clutter($map);      $map=&Apache::lonnet::clutter($map);
     my $name_of_sequence;      my $name_of_sequence;
     $name_of_sequence = $hash{'title_'.$hash{'ids_'.$map}};      $name_of_sequence = $hash{'title_'.$hash{'ids_'.$map}};
Line 698  ENDPART Line 699  ENDPART
     if ($currentURL=~m/\.page\s*$/) {      if ($currentURL=~m/\.page\s*$/) {
  ($result,$number_of_columns) = &page_cleanup($result);   ($result,$number_of_columns) = &page_cleanup($result);
     }      }
           } elsif ($currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') {
               #printing content of sequence from the construction space
       my $flag_latex_header_remove = 'NO'; 
       my $rndseed=time;
       if ($helper->{'VARS'}->{'curseed'}) {
    $rndseed=$helper->{'VARS'}->{'curseed'};
       }
       $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
       my $errtext=&Apache::lonratedt::mapread($currentURL);
       for (my $member=0;$member<=$#Apache::lonratedt::order;$member++) {
    $Apache::lonratedt::resources[$Apache::lonratedt::order[$member]]=~/^([^:]*):([^:]*):/;
    my $urlp=$2;
    if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {
       my %form;
       $form{'grade_target'}='tex';
       $form{'textwidth'}=$LaTeXwidth;
       $form{'problem_split'}=$parmhash{'problem_stream_switch'};
       $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
       $form{'rndseed'}=$rndseed;
       my $texversion=&Apache::lonnet::ssi($urlp,%form);
       if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
    my %form;
    $form{'grade_target'}='answer';
    $form{'answer_output_mode'}='tex';
    $form{'rndseed'}=$rndseed;
                           if ($urlp=~/\/res\//) {$ENV{'request.state'}='published';}
    ####my $answer=' SSSSSS '.$ENV{'request.state'}.' FFFFFFF ';
    my $answer=&Apache::lonnet::ssi($urlp,%form);
    $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
       }
       if ($flag_latex_header_remove ne 'NO') {
    $texversion = &latex_header_footer_remove($texversion);
       } else {
    $texversion =~ s/\\end{document}//;
       }
       if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
    $texversion=&IndexCreation($texversion,$urlp);
       }
       if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URpL'} eq 'yes') {
    $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;
       }
       $result.=$texversion;
       $flag_latex_header_remove = 'YES';
    } elsif ($urlp=~/\.(sequence|page)$/) {
       $result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent ';
    }  
       }
       if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
       $result .= '\end{document}';   
  } else {   } else {
   $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';    $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
   if ($currentURL=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {    if ($currentURL=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {
       $result.=$1;        $result.=$1;
   } elsif ($currentURL=~/\/ext\//) {    } elsif ($currentURL=~/\/ext\//) {
Line 725  ENDPART Line 775  ENDPART
  &Apache::lonnet::delenv('form.counter');   &Apache::lonnet::delenv('form.counter');
  &Apache::lonxml::init_counter();   &Apache::lonxml::init_counter();
  for (my $i=0;$i<=$#master_seq;$i++) {   for (my $i=0;$i<=$#master_seq;$i++) {
     $master_seq[$i]=~/___\d+___(.*)$/;      my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
     my $urlp='/res/'.$1;      $urlp=&Apache::lonnet::clutter($urlp);
     if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {      if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
  $selectionmade = 2;   $selectionmade = 2;
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {      } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
Line 735  ENDPART Line 785  ENDPART
  $selectionmade = 4;   $selectionmade = 4;
     }      }
     $form{'symb'}=$master_seq[$i];      $form{'symb'}=$master_seq[$i];
     $master_seq[$i]=~/(.*)___\d*___/;      my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]);
     my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($1),'header'); #tittle of the assignment which contains this problem      my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #tittle of the assignment which contains this problem
     #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");      #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");
     my $texversion=&Apache::lonnet::ssi($urlp,%form);      my $texversion=&Apache::lonnet::ssi($urlp,%form);
     if ($urlp=~/\.page$/) {      if ($urlp=~/\.page$/) {
Line 796  ENDPART Line 846  ENDPART
     &Apache::lonxml::init_counter();      &Apache::lonxml::init_counter();
     foreach my $curresline (@master_seq)  {      foreach my $curresline (@master_seq)  {
  if ($curresline=~ m/\.(problem|exam|quiz|assess|survey|form|library)$/) {   if ($curresline=~ m/\.(problem|exam|quiz|assess|survey|form|library)$/) {
     my ($map,$id,$res_url) = split(/___/,$curresline);      my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
     if (&Apache::lonnet::allowed('bre',$res_url)) {      if (&Apache::lonnet::allowed('bre',$res_url)) {
  my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,   my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,
                                                                         $ENV{'request.course.id'},'tex');                                                                          $ENV{'request.course.id'},'tex');
Line 1030  sub printHelper { Line 1080  sub printHelper {
     # very first screen.      # very first screen.
     # Detect whether we're coming from construction space      # Detect whether we're coming from construction space
     if ($ENV{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {      if ($ENV{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {
         $helper->{VARS}->{'filename'} = "/home/$1/public_html/$2";          $helper->{VARS}->{'filename'} = "~$1/$2";
         $helper->{VARS}->{'construction'} = 1;          $helper->{VARS}->{'construction'} = 1;
     } else {      } else {
         if ($ENV{'form.postdata'}) {          if ($ENV{'form.postdata'}) {
Line 1068  sub printHelper { Line 1118  sub printHelper {
         $subdir = substr($helper->{VARS}->{'filename'},          $subdir = substr($helper->{VARS}->{'filename'},
                          0, rindex($helper->{VARS}->{'filename'}, '/') + 1);                           0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
     } else {      } else {
         ($map, $id, $url) = split(/___/, $symb);          ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
         $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);          $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
   
         if (!$resourceTitle) { # if the resource doesn't have a title, use the filename          if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
Line 1082  sub printHelper { Line 1132  sub printHelper {
     }      }
   
     my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();      my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
       my $userPriviledged = ($ENV{'request.role'}=~m/^cc\./ or
      $ENV{'request.role'}=~m/^in\./ or
      $ENV{'request.role'}=~m/^ta\./);
   
     Apache::lonhelper::registerHelperTags();      Apache::lonhelper::registerHelperTags();
   
Line 1107  sub printHelper { Line 1160  sub printHelper {
     my $printChoices = [];      my $printChoices = [];
     my $paramHash;      my $paramHash;
   
     if ($resourceTitle) {      if ($resourceTitle && $helper->{VARS}->{'postdata'}) {
         push @{$printChoices}, ["<b>$resourceTitle</b> (prints what you just saw on the screen)", 'current_document', 'PAGESIZE'];          push @{$printChoices}, ["<b>$resourceTitle</b> (what you just saw on the screen)", 'current_document', 'PAGESIZE'];
     }      }
   
 #    $r->print($helper->{VARS}->{'postdata'});  #    $r->print($helper->{VARS}->{'postdata'});
   
     # If we're in a sequence...      # If we're in a sequence...
     if ($helper->{'VARS'}->{'construction'} ne '1') {      if (($helper->{'VARS'}->{'construction'} ne '1') &&
    $helper->{VARS}->{'postdata'}) {
         # Allow problems from sequence          # Allow problems from sequence
         push @{$printChoices}, ["Problem(s) from <b>$sequenceTitle</b>", 'map_problems', 'CHOOSE_PROBLEMS'];          push @{$printChoices}, ["<b>Selected problems</b> in $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];
         # Allow all resources from sequence          # Allow all resources from sequence
         push @{$printChoices}, ["Everything (problem(s), page(s), html/xml file(s)) from <b>$sequenceTitle</b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];          push @{$printChoices}, ["<b>Selected resources</b> in $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
   
         my $isProblem = '$res->is_problem()';          my $isProblem = '$res->is_problem()';
  $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;   $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
Line 1129  sub printHelper { Line 1183  sub printHelper {
         my $helperFragment = <<HELPERFRAGMENT;          my $helperFragment = <<HELPERFRAGMENT;
   <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">    <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
     <message>(mark them then click "next" button) <br /></message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1'>      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
Line 1139  sub printHelper { Line 1193  sub printHelper {
   
   <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">    <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
     <message>(mark them then click "next" button) <br /></message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1'>      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
Line 1153  HELPERFRAGMENT Line 1207  HELPERFRAGMENT
   
     # If the user is priviledged, allow them to print all       # If the user is priviledged, allow them to print all 
     # problems in the course, optionally for selected students      # problems in the course, optionally for selected students
     if (($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) and ($helper->{VARS}->{'postdata'}=~/\/res\//)) {       if ($userPriviledged && ($helper->{VARS}->{'postdata'}=~/\/res\//)) { 
         push @{$printChoices}, ['<b>Problems</b> in this course', 'all_problems', 'ALL_PROBLEMS'];          push @{$printChoices}, ['Selected problems from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
         push @{$printChoices}, ["Problems from <b>$sequenceTitle</b> for selected students", 'problems_for_students', 'CHOOSE_STUDENTS'];          push @{$printChoices}, ["Selected problems from $sequenceTitle for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS'];
   
         my $isProblem = '$res->is_problem()';          my $isProblem = '$res->is_problem()';
  $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;   $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
Line 1165  HELPERFRAGMENT Line 1219  HELPERFRAGMENT
         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);          &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
   <state name="ALL_PROBLEMS" title="Select Problem(s) to print">    <state name="ALL_PROBLEMS" title="Select Problem(s) to print">
     <message>(mark them then click "next" button) <br /></message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" suppressEmptySequences='1'>      <resource variable="RESOURCES" multichoice="1"
    suppressEmptySequences='1' addstatus="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblemOrMap;</filterfunc>
       <choicefunc>return $isProblem;</choicefunc>        <choicefunc>return $isProblem;</choicefunc>
Line 1176  HELPERFRAGMENT Line 1231  HELPERFRAGMENT
   <state name="CHOOSE_STUDENTS" title="Select Students and Resources">    <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />      <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />
     <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>      <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
     <resource variable="RESOURCES" multichoice="1">      <resource variable="RESOURCES" multichoice="1" addstatus="1">
       <filterfunc>return $isProblem</filterfunc>        <filterfunc>return $isProblem</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symb</valuefunc>        <valuefunc>return $symb</valuefunc>
Line 1236  CHOOSE_FROM_SUBDIR Line 1291  CHOOSE_FROM_SUBDIR
  $paramHash->{'variable'} = 'ANSWER_TYPE';      $paramHash->{'variable'} = 'ANSWER_TYPE';   
  $helper->declareVar('ANSWER_TYPE');            $helper->declareVar('ANSWER_TYPE');         
         $paramHash->{CHOICES} = [          $paramHash->{CHOICES} = [
                                    ['Yes', 'yes'],                                     ['No', 'yes'],
                                    ['No', 'no'] ];                                     ['Yes', 'no'] ];
         Apache::lonhelper::dropdown->new();          Apache::lonhelper::dropdown->new();
  addMessage("</td></tr>");   addMessage("</td></tr>");
  $startedTable = 1;   $startedTable = 1;

Removed from v.1.226  
changed lines
  Added in v.1.237


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>