Diff for /loncom/interface/lonprintout.pm between versions 1.228 and 1.236

version 1.228, 2003/09/05 19:34:28 version 1.236, 2003/09/17 17:32:56
Line 531  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 670  ENDPART Line 670  ENDPART
     $form{'problem_split'}=$parmhash{'problem_stream_switch'};      $form{'problem_split'}=$parmhash{'problem_stream_switch'};
     $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};      $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
     my $rndseed=time;      my $rndseed=time;
       if ($helper->{'VARS'}->{'curseed'}) {
    $rndseed=$helper->{'VARS'}->{'curseed'};
       }
     $form{'rndseed'}=$rndseed;      $form{'rndseed'}=$rndseed;
     &Apache::lonnet::appenv(%moreenv);      &Apache::lonnet::appenv(%moreenv);
     &Apache::lonnet::delenv('form.counter');      &Apache::lonnet::delenv('form.counter');
Line 700  ENDPART Line 703  ENDPART
             #printing content of sequence from the construction space              #printing content of sequence from the construction space
     my $flag_latex_header_remove = 'NO';       my $flag_latex_header_remove = 'NO'; 
     my $rndseed=time;      my $rndseed=time;
       if ($helper->{'VARS'}->{'curseed'}) {
    $rndseed=$helper->{'VARS'}->{'curseed'};
       }
     $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;      $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
     my $errtext=&Apache::lonratedt::mapread($currentURL);      my $errtext=&Apache::lonratedt::mapread($currentURL);
     for (my $member=0;$member<=$#Apache::lonratedt::order;$member++) {      for (my $member=0;$member<=$#Apache::lonratedt::order;$member++) {
Line 709  ENDPART Line 715  ENDPART
     my %form;      my %form;
     $form{'grade_target'}='tex';      $form{'grade_target'}='tex';
     $form{'textwidth'}=$LaTeXwidth;      $form{'textwidth'}=$LaTeXwidth;
       $form{'problem_split'}=$parmhash{'problem_stream_switch'};
       $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
     $form{'rndseed'}=$rndseed;      $form{'rndseed'}=$rndseed;
     my $texversion=&Apache::lonnet::ssi($urlp,%form);      my $texversion=&Apache::lonnet::ssi($urlp,%form);
     if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {      if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
  my %form;   my %form;
  $form{'grade_target'}='answer';   $form{'grade_target'}='answer';
  $form{'answer_output_mode'}='tex';   $form{'answer_output_mode'}='tex';
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};  
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
                           if ($urlp=~/\/res\//) {$ENV{'request.state'}='published';}
    ####my $answer=' SSSSSS '.$ENV{'request.state'}.' FFFFFFF ';
  my $answer=&Apache::lonnet::ssi($urlp,%form);   my $answer=&Apache::lonnet::ssi($urlp,%form);
  $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;   $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
     }      }
Line 728  ENDPART Line 737  ENDPART
     if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {      if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
  $texversion=&IndexCreation($texversion,$urlp);   $texversion=&IndexCreation($texversion,$urlp);
     }      }
     if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') {      if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URpL'} eq 'yes') {
  $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;   $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;
     }      }
     $result.=$texversion;      $result.=$texversion;
     $flag_latex_header_remove = 'YES';      $flag_latex_header_remove = 'YES';
  } elsif ($urlp=~/\.(sequence|page)$/) {   } elsif ($urlp=~/\.(sequence|page)$/) {
     $result.='\strut\newline\noindent This is sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent ';      $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\} /;}      if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
Line 766  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::declutter($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 776  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 837  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 884  ENDPART Line 893  ENDPART
  @list_of_files=sort @list_of_files;   @list_of_files=sort @list_of_files;
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO'; 
  my $rndseed=time;   my $rndseed=time;
    if ($helper->{'VARS'}->{'curseed'}) {
       $rndseed=$helper->{'VARS'}->{'curseed'};
    }
  for (my $i=0;$i<=$#list_of_files;$i++) {   for (my $i=0;$i<=$#list_of_files;$i++) {
     my $urlp = $list_of_files[$i];      my $urlp = $list_of_files[$i];
     if ($urlp=~/\//) {      if ($urlp=~/\//) {
Line 1059  sub printHelper { Line 1071  sub printHelper {
     my $helper = Apache::lonhelper::helper->new("Printing Helper");      my $helper = Apache::lonhelper::helper->new("Printing Helper");
     $helper->declareVar('symb');      $helper->declareVar('symb');
     $helper->declareVar('postdata');          $helper->declareVar('postdata');    
       $helper->declareVar('curseed');    
     $helper->declareVar('filename');      $helper->declareVar('filename');
     $helper->declareVar('construction');      $helper->declareVar('construction');
     $helper->declareVar('assignment');      $helper->declareVar('assignment');
Line 1067  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 1105  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 1114  sub printHelper { Line 1127  sub printHelper {
         }          }
         $subdir = &Apache::lonnet::filelocation("", $url);          $subdir = &Apache::lonnet::filelocation("", $url);
     }      }
       if (!$helper->{VARS}->{'curseed'} && $ENV{'form.curseed'}) {
    $helper->{VARS}->{'curseed'}=$ENV{'form.curseed'};
       }
   
     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 1141  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 1163  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 1173  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 1187  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 1199  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 1210  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 1270  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;
Line 1331  CHOOSE_FROM_SUBDIR Line 1352  CHOOSE_FROM_SUBDIR
     Apache::lonhelper::dropdown->new();      Apache::lonhelper::dropdown->new();
     addMessage("</td></tr>");      addMessage("</td></tr>");
  }   }
    if ($helper->{'VARS'}->{'construction'}) { 
       my $xmlfrag .= <<'RNDSEED';
       <message><tr><td align='right'>Use random seed: </td><td></message>
       <string variable="curseed" size="15" maxlength="15">
    <defaultvalue>
               return $helper->{VARS}->{'curseed'};
           </defaultvalue>
        </string>
                <message></td></tr></message>
   RNDSEED
               &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
    }
     }      }
   
     if ($startedTable) {      if ($startedTable) {

Removed from v.1.228  
changed lines
  Added in v.1.236


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