Diff for /loncom/interface/lonprintout.pm between versions 1.625 and 1.626

version 1.625, 2012/12/08 20:10:26 version 1.626, 2012/12/10 01:09:06
Line 705  sub incomplete { Line 705  sub incomplete {
 #  to only those that are in the original set selcted to be printed.  #  to only those that are in the original set selcted to be printed.
 #  #
 # Parameters:  # Parameters:
 #   $helper - The helper we need $helper->{'VARS'}->{'symb'}  #   $map - The URL of the folder being printed.
 #            to construct the navmap and the iteration.  #          Used to determine which startResource and finishResource
 #   $seq   - The original set of resources to print   #          to use when using the navmap's getIterator method.
   #   $seq   - The original set of resources to print.
 #            (really an array of resource names (array of symb's).  #            (really an array of resource names (array of symb's).
 #   $who   - Student/domain for whome the sequence will be generated.  #   $who   - Student/domain for whome the sequence will be generated.
   #   $code  - CODE being printed when printing Problems/Resources
   #            from folder for CODEd assignments
 #  #
 # Implicit inputs:  # Implicit inputs:
 #   $  #   $
Line 718  sub incomplete { Line 721  sub incomplete {
 #   print_resources.  #   print_resources.
 #   # 
 sub master_seq_to_person_seq {  sub master_seq_to_person_seq {
     my ($helper, $seq, $who, $code) = @_;      my ($map, $seq, $who, $code) = @_;
   
   
     my ($username, $userdomain, $usersection) = split(/:/, $who);      my ($username, $userdomain, $usersection) = split(/:/, $who);
   
   
     # Toss the sequence up into a hash so that we have O(1) lookup time.      # Toss the sequence up into a hash so that we have O(1) lookup time.
     # on the items that come out of the user's list of resources.      # on the items that come out of the user's list of resources.
     #      #
       
     my %seq_hash = map {$_  => 1} @$seq;      my %seq_hash = map {$_  => 1} @$seq;
     my @output_seq;      my @output_seq;
           
     my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'});  
     my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,      my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,
                                                            $code);                                                             $code);
     my $iterator         = $navmap->getIterator($navmap->firstResource(),      my ($start,$finish);
  $navmap->finishResource(),  
  {}, 1);  
     my %nonResourceItems = (  
  $iterator->BEGIN_MAP    => 1,  
  $iterator->BEGIN_BRANCH => 1,  
  $iterator->END_BRANCH   => 1,  
  $iterator->END_MAP      => 1,  
  $iterator->FORWARD      => 1,  
  $iterator->BACKWARD     => 1  
   
     ); # These items are not resources but appear in the midst of iteration.      if ($map) {
           my $mapres = $navmap->getResourceByUrl($map);
           if ($mapres->is_map()) {
               $start = $mapres->map_start();
               $finish = $mapres->map_finish();
           }
       }
       unless ($start && $finish) {
           $start = $navmap->firstResource();
           $finish = $navmap->finishResource();
       }
   
       my $iterator         = $navmap->getIterator($start,$finish,{},1);
   
     #  Iterate on the resource..select the items that are randomly selected      #  Iterate on the resource..select the items that are randomly selected
     #  and that are in the seq_has.  Presumably the iterator will take care      #  and that are in the seq_has.  Presumably the iterator will take care
Line 757  sub master_seq_to_person_seq { Line 761  sub master_seq_to_person_seq {
  #  Only process resources..that are not removed by randomout...   #  Only process resources..that are not removed by randomout...
  #  and are selected for printint as well.   #  and are selected for printint as well.
  #   #
        
  if (! exists $nonResourceItems{$curres} && ! $curres->randomout()) {          if (ref($curres) && ! $curres->randomout()) {
     my $symb = $curres->symb();              my $currsymb = $curres->symb();
     if (exists $seq_hash{$symb}) {              if (exists($seq_hash{$currsymb})) {
  push(@output_seq, $symb);                  push(@output_seq, $currsymb);
     }      }
  }   }
     }      }
      
   
     return \@output_seq; # for now.      return \@output_seq; # for now.
           
Line 3145  ENDPART Line 3148  ENDPART
  }   }
  my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};   my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
   
            my $map;
            if ($helper->{VARS}->{'symb'}) {
                ($map, my $id, my $resource) =
                    &Apache::lonnet::decode_symb($helper->{VARS}->{'symb'});
            }
   
  #loop over students   #loop over students
   
   my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO';
Line 3179  ENDPART Line 3188  ENDPART
      } else {       } else {
  $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});   $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
      }       }
      my $actual_seq = master_seq_to_person_seq($helper, \@master_seq, $person);       my $actual_seq = master_seq_to_person_seq($map, \@master_seq,
                                                          $person);
      my ($output,$fullname, $printed)=&print_resources($r,$helper,       my ($output,$fullname, $printed)=&print_resources($r,$helper,
      $person,$type,       $person,$type,
      \%moreenv,  $actual_seq,       \%moreenv,  $actual_seq,
Line 3221  ENDPART Line 3231  ENDPART
                  }                   }
      }       }
  }   }
          my ($randomorder,$randompick);           my ($randomorder,$randompick,$map);
          if ($helper->{VARS}{'symb'}) {           if ($helper->{VARS}{'symb'}) {
                ($map, my $id, my $resource) =
                    &Apache::lonnet::decode_symb($helper->{VARS}{'symb'});
              my $navmap = Apache::lonnavmaps::navmap->new();               my $navmap = Apache::lonnavmaps::navmap->new();
              if (defined($navmap)) {               if (defined($navmap)) {
                  my ($map,$id,$resource) =   
                      &Apache::lonnet::decode_symb($helper->{VARS}{'symb'});  
                  if ($map) {                   if ($map) {
                      my $res = $navmap->getResourceByUrl($map);                       my $mapres = $navmap->getResourceByUrl($map);
                      $randomorder = $res->randomorder();                       $randomorder = $mapres->randomorder();
                      $randompick = $res->randompick();                       $randompick = $mapres->randompick();
                  }                   }
              }               }
          }           }
Line 3298  ENDPART Line 3308  ENDPART
              my $actual_seq = \@master_seq;               my $actual_seq = \@master_seq;
              if ($randomorder) {               if ($randomorder) {
                  $env{'form.CODE'} = $moreenv{'CODE'};                   $env{'form.CODE'} = $moreenv{'CODE'};
                  $actual_seq = master_seq_to_person_seq($helper,\@master_seq,undef,                   $actual_seq = master_seq_to_person_seq($map, \@master_seq,
                                                           undef,
                                                         $moreenv{'CODE'});                                                          $moreenv{'CODE'});
                  delete($env{'form.CODE'});                   delete($env{'form.CODE'});
              }               }

Removed from v.1.625  
changed lines
  Added in v.1.626


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