Diff for /loncom/interface/lonprintout.pm between versions 1.122 and 1.126

version 1.122, 2003/02/27 21:01:09 version 1.126, 2003/03/03 20:58:18
Line 157  sub sequence_content_menu { Line 157  sub sequence_content_menu {
     my $primary_sequence;      my $primary_sequence;
     my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});      my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
     my @sequence = split('___',$symbolic);      my @sequence = split('___',$symbolic);
     if ($sequence[0]=~/^uploaded/) {$primary_sequence = '/'.$sequence[0];}       $primary_sequence=&Apache::lonnet::clutter($sequence[0]);
       else {$primary_sequence = '/res/'.$sequence[0];}   
     my @master_seq = &coming_from_hash($primary_sequence);      my @master_seq = &coming_from_hash($primary_sequence);
     my @titles_master_seq = ();       my @titles_master_seq = (); 
     for (my $i=0;$i<=$#master_seq;$i++) {      for (my $i=0;$i<=$#master_seq;$i++) {
Line 371  ENDDISHEADER Line 370  ENDDISHEADER
               $sdom,$sname);                $sdom,$sname);
            my $section=&Apache::lonnet::usection             my $section=&Apache::lonnet::usection
        ($sdom,$sname,$ENV{'request.course.id'});         ($sdom,$sname,$ENV{'request.course.id'});
      if ($section == -1) { $section = ''; }
            $r->print(             $r->print(
         '<br /><input type=checkbox name="whomtoprint'.$i.'" value="'.$section.':'.$_.'"> '.          '<br /><input type=checkbox name="whomtoprint'.$i.'" value="'.$section.':'.$_.'"> '.
       $reply{'firstname'}.' '.         $reply{'firstname'}.' '. 
Line 550  ENDPART Line 550  ENDPART
     }  elsif ($choice eq 'Standard LaTeX output for the top level sequence') {      }  elsif ($choice eq 'Standard LaTeX output for the top level sequence') {
         # where is the main sequence of the course?          # where is the main sequence of the course?
  $selectionmade = 4;   $selectionmade = 4;
  my $main_seq;   my $main_seq=&Apache::lonnet::clutter($ENV{'request.course.uri'});
  if ($ENV{'request.course.uri'}=~/\/?uploaded\//) {  
     $main_seq = $ENV{'request.course.uri'};  
  } else {  
     $main_seq = '/res/'.$ENV{'request.course.uri'};  
  }  
  my @file_seq = &coming_from_hash($main_seq);   my @file_seq = &coming_from_hash($main_seq);
  for (my $i=0;$i<=$#file_seq;$i++) {   for (my $i=0;$i<=$#file_seq;$i++) {
     my ($path,$title,$symb) = split /&&/,$file_seq[$i];      my ($path,$title,$symb) = split /&&/,$file_seq[$i];
Line 598  ENDPART Line 593  ENDPART
  my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});   my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
  my @sequence = split('___',$symbolic);   my @sequence = split('___',$symbolic);
  my $primary_sequence;   my $primary_sequence;
  if ($sequence[0]=~/^uploaded/) {$primary_sequence = '/'.$sequence[0];}   
           else {$primary_sequence = '/res/'.$sequence[0];}     $primary_sequence=&Apache::lonnet::clutter($sequence[0]);
  my @master_seq = &coming_from_hash($primary_sequence);    my @master_seq = &coming_from_hash($primary_sequence); 
  for (my $i=0;$i<=$#master_seq;$i++) {   for (my $i=0;$i<=$#master_seq;$i++) {
     my ($path,$title,$symb) = split /&&/,$master_seq[$i];      my ($path,$title,$symb) = split /&&/,$master_seq[$i];
Line 613  ENDPART Line 608  ENDPART
  foreach my $person (@students) {   foreach my $person (@students) {
     my $current_output = '';       my $current_output = ''; 
     my ($usersection,$username,$userdomain) = split /:/,$person;      my ($usersection,$username,$userdomain) = split /:/,$person;
     my $fullname = &Apache::grades::get_fullname($username,$userdomain);          my $fullname = &get_name($username,$userdomain);
             #goes through all resources, checks if they are available for current student, and produces output                 #goes through all resources, checks if they are available for current student, and produces output   
     foreach my $curresline (@master_seq)  {      foreach my $curresline (@master_seq)  {
  my ($curres,$symb) = split /&&/, $curresline;   my ($curres,$symb) = split /&&/, $curresline;
Line 742  sub coming_from_hash { Line 737  sub coming_from_hash {
  if ($hash{'src_'.$current_resource}=~/\.sequence$/) {   if ($hash{'src_'.$current_resource}=~/\.sequence$/) {
     push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});      push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});
  } else {   } else {
     my $presymb;       my $presymb=&Apache::lonnet::declutter($mainsequence);
     if ($mainsequence =~ /\/res\/(.*)$/) {$presymb = $1;}   
               elsif ($mainsequence =~ /\/?(uploaded\/(.*))$/) {$presymb = $1;}   
     my $rid = $current_resource;      my $rid = $current_resource;
     if ($rid=~/,/) {      if ($rid=~/,/) {
  my @rid = split /,/, $rid;   my @rid = split /,/, $rid;
Line 758  sub coming_from_hash { Line 751  sub coming_from_hash {
         $rid =~ m/^$mapid\.(\d*)/;          $rid =~ m/^$mapid\.(\d*)/;
                 $rid = $1;                    $rid = $1;  
     }      }
     $hash{'src_'.$current_resource} =~ m/\/res\/(.*)$/;      my $symb = $presymb.'___'.$rid.'___'.
     my $symb = $presymb.'___'.$rid.'___'.$1;       &Apache::lonnet::declutter($hash{'src_'.$current_resource});
     push @resourcelist,$hash{'src_'.$current_resource}.'&&'.$hash{'title_'.$current_resource}.'&&'.$symb;      push @resourcelist,$hash{'src_'.$current_resource}.'&&'.$hash{'title_'.$current_resource}.'&&'.$symb;
  }   }
  $current_resource = $hash{'goesto_'.$hash{'to_'.$current_resource}};   $current_resource = $hash{'goesto_'.$hash{'to_'.$current_resource}};
Line 768  sub coming_from_hash { Line 761  sub coming_from_hash {
  if ($hash{'src_'.$current_resource}=~/\.sequence$/) {   if ($hash{'src_'.$current_resource}=~/\.sequence$/) {
     push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});      push @resourcelist,&coming_from_hash($hash{'src_'.$current_resource});
  } else {   } else {
     my $presymb;       my $presymb=&Apache::lonnet::declutter($mainsequence);
     if ($mainsequence =~ /\/res\/(.*)$/) {$presymb = $1;}   
               elsif ($mainsequence =~ /\/?(uploaded\/(.*))$/) {$presymb = $1;}   
     my $rid = $current_resource;      my $rid = $current_resource;
     if ($rid=~/,/) {      if ($rid=~/,/) {
  my @rid = split /,/, $rid;   my @rid = split /,/, $rid;
Line 784  sub coming_from_hash { Line 775  sub coming_from_hash {
         $rid =~ m/^$mapid\.(\d*)/;          $rid =~ m/^$mapid\.(\d*)/;
                 $rid = $1;                    $rid = $1;  
     }      }
     $hash{'src_'.$current_resource} =~ m/\/res\/(.*)$/;      my $symb = $presymb.'___'.$rid.'___'.
     my $symb = $presymb.'___'.$rid.'___'.$1;       &Apache::lonnet::declutter($hash{'src_'.$current_resource});
     push @resourcelist,$hash{'src_'.$current_resource}.'&&'.$hash{'title_'.$current_resource}.'&&'.$symb;      push @resourcelist,$hash{'src_'.$current_resource}.'&&'.$hash{'title_'.$current_resource}.'&&'.$symb;
  }   }
  $current_resource = $hash{'goesto_'.$hash{'to_'.$current_resource}};   $current_resource = $hash{'goesto_'.$hash{'to_'.$current_resource}};
Line 1114  sub character_chart { Line 1105  sub character_chart {
     }      }
   
   
   sub get_name {
       my ($uname,$udom)=@_;
       if (!defined($uname)) { $uname=$ENV{'user.name'}; }
       if (!defined($udom)) { $uname=$ENV{'user.domain'}; }
       my $plainname=&Apache::loncommon::plainname($uname,$udom);
       if ($plainname=~/^\s*$/) { $plainname=$uname; }
       return &Apache::lonxml::latex_special_symbols($plainname,undef,undef,
     'header');
   }
   
 sub page_format_transformation {  sub page_format_transformation {
     my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_;       my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; 
     my ($textwidth,$textheight,$oddoffset,$evenoffset);      my ($textwidth,$textheight,$oddoffset,$evenoffset);
Line 1123  sub page_format_transformation { Line 1124  sub page_format_transformation {
  } else {   } else {
   ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});    ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});
  }   }
     my $firstname = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'environment.firstname'}),'','','header');      my $name = &get_name();
     my $lastname = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'environment.lastname'}),'','','header');      if ($name =~ /^\s*$/) {
    $name=&Apache::lonxml::latex_special_symbols($ENV{'user.name'},undef,
        undef,'header');
       }
     my $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'','','header');      my $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'','','header');
     if ($layout eq 'CBI') {      if ($layout eq 'CBI') {
     $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$firstname $lastname}} \\hfill  $courseidinfo} \\vskip 5 mm /;      $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$name}} \\hfill  $courseidinfo} \\vskip 5 mm /;
     } elsif ($layout eq 'CAPA') {      } elsif ($layout eq 'CAPA') {
  if ($choice ne 'All class print') {    if ($choice ne 'All class print') { 
  $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$firstname $lastname} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;   $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
  } else {   } else {
     $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1}  \\vskip 5 mm /;      $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1}  \\vskip 5 mm /;
   
Line 1159  sub details_for_menu { Line 1163  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)=split(/___/,$symbolic);
       $map=&Apache::lonnet::clutter($map);
     my $name_of_sequence;      my $name_of_sequence;
     if ($map=~/^uploaded/) {      $name_of_sequence = $hash{'title_'.$hash{'ids_'.$map}};
  $name_of_sequence = $hash{'title_'.$hash{'ids_/'.$map}};  
     } else {  
  $name_of_sequence = $hash{'title_'.$hash{'ids_/res/'.$map}};  
     }  
     if ($name_of_sequence =~ /^\s*$/) {      if ($name_of_sequence =~ /^\s*$/) {
      $map =~ m|([^/]+)$|;   $map =~ m|([^/]+)$|;
       $name_of_sequence = $1;   $name_of_sequence = $1;
     }      }
     my $name_of_map = $hash{'title_'.$hash{'ids_/res/'.$ENV{'request.course.uri'}}};      my $name_of_map = $hash{'title_'.$hash{'ids_'.&Apache::lonnet::clutter($ENV{'request.course.uri'})}};
     if ($name_of_map =~ /^\s*$/) {      if ($name_of_map =~ /^\s*$/) {
       $ENV{'request.course.uri'} =~ m|([^/]+)$|;   $ENV{'request.course.uri'} =~ m|([^/]+)$|;
       $name_of_map = $1;   $name_of_map = $1;
     }        }
     return ($name_of_resourse,$name_of_sequence,$name_of_map);      return ($name_of_resourse,$name_of_sequence,$name_of_map);
   
 }  }
Line 1218  sub handler { Line 1219  sub handler {
     my $r = shift;      my $r = shift;
   
     # A hook for me to work without disturbing Alex.      # A hook for me to work without disturbing Alex.
     if (!$ENV{'form.jeremy'}) {      if ($ENV{'form.jeremy'}) {
         printWizard($r);          printWizard($r);
         return OK;          return OK;
     }      }
Line 1343  sub printWizard { Line 1344  sub printWizard {
     if ($ENV{'form.postdata'}=~ /\/res\//) {      if ($ENV{'form.postdata'}=~ /\/res\//) {
         # Allow problems from sequence          # Allow problems from sequence
         push @{$printChoices}, ['map_problems', "Problems from <b>$sequenceTitle</b>", 'CHOOSE_PROBLEMS'];          push @{$printChoices}, ['map_problems', "Problems from <b>$sequenceTitle</b>", 'CHOOSE_PROBLEMS'];
         Apache::lonwizard::resource_multichoice->new($wizard, "CHOOSE_PROBLEMS", 'Select Problems', "Select problems to print from <b>$sequenceTitle</b>:", '', 'CHOOSE_FORMAT', 'RESOURCES', sub {my $res = shift; return $res->is_problem()}, undef, $map);          Apache::lonwizard::resource_multichoice->new($wizard, "CHOOSE_PROBLEMS", 'Select Problems', "Select problems to print from <b>$sequenceTitle</b>:", 'CHOOSE_FORMAT', 'RESOURCES', sub {my $res = shift; return $res->is_problem()}, undef, $map);
   
         # Allow all resources from sequence          # Allow all resources from sequence
         push @{$printChoices}, ['map_problems_pages', "Problems and pages from <b>$sequenceTitle</b>", 'CHOOSE_PROBLEMS_HTML'];          push @{$printChoices}, ['map_problems_pages', "Problems and pages from <b>$sequenceTitle</b>", 'CHOOSE_PROBLEMS_HTML'];
         Apache::lonwizard::resource_multichoice->new($wizard, "CHOOSE_PROBLEMS_HTML", 'Select Resources', "Select resources to print from <b>$sequenceTitle</b>:", '', "CHOOSE_FORMAT", 'RESOURCES', sub {my $res = shift; return !$res->is_map()}, undef, $map);          Apache::lonwizard::resource_multichoice->new($wizard, "CHOOSE_PROBLEMS_HTML", 'Select Resources', "Select resources to print from <b>$sequenceTitle</b>:", "CHOOSE_FORMAT", 'RESOURCES', sub {my $res = shift; return !$res->is_map()}, undef, $map);
     }      }
   
     # If the user is priviledged, allow them to print all       # If the user is priviledged, allow them to print all 
Line 1361  sub printWizard { Line 1362  sub printWizard {
     # FIXME: That RE should come from a library somewhere.      # FIXME: That RE should come from a library somewhere.
     if ((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($ENV{'form.postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) {          if ((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($ENV{'form.postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) {    
         push @{$printChoices}, ['problems_from_directory', "Problems from <b>$subdir</b>", 'CHOOSE_FROM_SUBDIR'];          push @{$printChoices}, ['problems_from_directory', "Problems from <b>$subdir</b>", 'CHOOSE_FROM_SUBDIR'];
         Apache::lonwizard::choose_files->new($wizard, "CHOOSE_FROM_SUBDIR", "Select Files","Select problems you wish to print from <b>$subdir</b>:", '', 'CHOOSE_FORMAT', 'FILES', $subdir, $problemFilter);          Apache::lonwizard::choose_files->new($wizard, "CHOOSE_FROM_SUBDIR", "Select Files","Select problems you wish to print from <b>$subdir</b>:", 'CHOOSE_FORMAT', 'FILES', $subdir, $problemFilter);
     }      }
   
     # Despite the appearance of states before here, this is the first state.      # Despite the appearance of states before here, this is the first state.
Line 1373  sub printWizard { Line 1374  sub printWizard {
     untie %hash;      untie %hash;
   
     return OK;      return OK;
   
 }  }
   
   

Removed from v.1.122  
changed lines
  Added in v.1.126


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