Diff for /rat/lonsequence.pm between versions 1.30 and 1.37

version 1.30, 2007/01/16 21:19:11 version 1.37, 2009/02/16 13:52:04
Line 27 Line 27
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
   
   
 package Apache::lonsequence;  package Apache::lonsequence;
   
 use strict;  use strict;
Line 36  use GDBM_File; Line 38  use GDBM_File;
 use LONCAPA::map();  use LONCAPA::map();
 use Apache::lonpageflip();  use Apache::lonpageflip();
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::groupsort();
 use Apache::lonlocal;  use Apache::lonlocal;
 use HTML::Entities();  use HTML::Entities();
   
Line 45  my $successtied; Line 48  my $successtied;
 # ----------------------------------------- Attempt to read from resource space  # ----------------------------------------- Attempt to read from resource space
   
 sub attemptread {  sub attemptread {
     my $fn=shift;      my ($fn,$unsorted)=@_;
     &Apache::lonnet::repcopy($fn);      &Apache::lonnet::repcopy($fn);
     if (-e $fn) {      if (-e $fn) {
  return &LONCAPA::map::attemptread($fn);   return &LONCAPA::map::attemptread($fn,$unsorted);
     } else {      } else {
         return ();          return ();
     }      }
Line 114  ENDSELECT Line 117  ENDSELECT
             $successtied=1;              $successtied=1;
   
 # - Evaluate actions from previous page (both cumulatively and chronologically)  # - Evaluate actions from previous page (both cumulatively and chronologically)
         if ($env{'form.catalogmode'} eq 'import') {      if ($env{'form.catalogmode'} eq 'import') {
     my $acts=$env{'form.acts'};   &Apache::groupsort::update_actions_hash(\%selhash);
     my @Acts=split(/b/,$acts);  
     my %ahash;  
     my %achash;  
     my $ac=0;  
     # some initial hashes for working with data  
     foreach (@Acts) {  
  my ($state,$ref)=split(/a/);  
  $ahash{$ref}=$state;  
  $achash{$ref}=$ac;  
  $ac++;  
     }  
     # sorting through the actions and changing the tied database hash  
     foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {  
  my $key=$_;  
  if ($ahash{$key} eq '1') {  
     $selhash{'store_'.$selhash{'pre_'.$key.'_link'}}=  
  $selhash{'pre_'.$key.'_title'};  
     $selhash{'storectr_'.$selhash{'pre_'.$key.'_link'}}=  
  $selhash{'storectr'}+0;  
     $selhash{'storectr'}++;  
  }  
  if ($ahash{$key} eq '0') {  
     if ($selhash{'store_'.$selhash{'pre_'.$key.'_link'}}) {  
        delete $selhash{'store_'.$selhash{'pre_'.$key.'_link'}};  
     }  
  }  
     }  
     # deleting the previously cached listing  
     foreach (keys %selhash) {  
  if ($_ =~ /^pre_/ && $_ =~/link$/) {  
     my $key = $_;  
     $key =~ s/^pre_//;  
     $key =~ s/_[^_]*$//;  
     delete $selhash{'pre_'.$key.'_title'};  
     delete $selhash{'pre_'.$key.'_link'};  
  }  
     }      }
  }  
 # -  # -
         }          }
     }      }
 # ----------------------------- successtied is now '1' if in working selectmode  # ----------------------------- successtied is now '1' if in working selectmode
     my ($errtext,$fatal)=&mapread(&Apache::lonnet::filelocation('',$url),'');      my ($errtext,$fatal)=&mapread(&Apache::lonnet::filelocation('',$url),'');
     if ($fatal==1) {      if ($fatal==1) {
        $r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />');         $r->print('<p class="LC_warning">'
                   .&mt('Map contents are not shown in order.')
                   .'</p><br />');
     }      }
     my $idx=0;      my $idx=0;
     foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {      foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
Line 314  sub handler { Line 282  sub handler {
       &Apache::lonnet::symblist($requrl,$disurl => [$disurl,$dismapid],        &Apache::lonnet::symblist($requrl,$disurl => [$disurl,$dismapid],
  'last_known' => [$disurl,$dismapid]);    'last_known' => [$disurl,$dismapid]); 
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$disurl);        $r->header_out(Location => &Apache::lonnet::absolute_url($ENV{'SERVER_NAME'}).
                                    $disurl);
       return REDIRECT;        return REDIRECT;
    } else {     } else {
        &Apache::loncommon::content_type($r,'text/html');         &Apache::loncommon::content_type($r,'text/html');
Line 358  ENDNONE Line 327  ENDNONE
 1;  1;
 __END__  __END__
   
   =head1 NAME
   
   Apache::lonsequence
   
   =head1 SYNOPSIS
   
   Handler for showing sequence objects of
   educational resources.
   
   This is part of the LearningOnline Network with CAPA project
   described at http://www.lon-capa.org.
   
   =head1 SUBROUTINES
   
   =over
   
   =item handler()
   
   =item viewmap()
   
   =item attemptread()
   
   =item mapread()
   
   =item start_fresh_session()
   
   =back
   
   =cut
   
   
   

Removed from v.1.30  
changed lines
  Added in v.1.37


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