--- rat/lonsequence.pm 2006/11/02 21:15:22 1.28 +++ rat/lonsequence.pm 2008/11/11 16:40:38 1.33 @@ -2,7 +2,7 @@ # # Sequence Handler # -# $Id: lonsequence.pm,v 1.28 2006/11/02 21:15:22 albertel Exp $ +# $Id: lonsequence.pm,v 1.33 2008/11/11 16:40:38 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,6 +27,46 @@ # http://www.lon-capa.org/ # +=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 HANDLER SUBROUTINE + +handler() + +and + +viewmap() + +=head1 OTHER SUBROUTINES + +=over + +=item * + +attemptread() + +=item * + +mapread() + +=item * + +start_fresh_session() + +=back + +=cut + package Apache::lonsequence; use strict; @@ -34,10 +74,11 @@ use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); use GDBM_File; use LONCAPA::map(); -use Apache::lonratsrv(); use Apache::lonpageflip(); use Apache::loncommon(); +use Apache::groupsort(); use Apache::lonlocal; +use HTML::Entities(); my %selhash; my $successtied; @@ -45,10 +86,10 @@ my $successtied; # ----------------------------------------- Attempt to read from resource space sub attemptread { - my $fn=shift; + my ($fn,$unsorted)=@_; &Apache::lonnet::repcopy($fn); if (-e $fn) { - return &LONCAPA::map::attemptread($fn); + return &LONCAPA::map::attemptread($fn,$unsorted); } else { return (); } @@ -114,46 +155,9 @@ ENDSELECT $successtied=1; # - Evaluate actions from previous page (both cumulatively and chronologically) - if ($env{'form.catalogmode'} eq 'import') { - my $acts=$env{'form.acts'}; - 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'}}; - } - } + if ($env{'form.catalogmode'} eq 'import') { + &Apache::groupsort::update_actions_hash(\%selhash); } - # 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'}; - } - } - } # - } } @@ -170,10 +174,15 @@ ENDSELECT $r->print('
');