--- rat/map.pm 2007/01/26 23:37:51 1.6 +++ rat/map.pm 2007/12/01 01:59:54 1.9 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # routines for modyfing .sequence and .page files # -# $Id: map.pm,v 1.6 2007/01/26 23:37:51 albertel Exp $ +# $Id: map.pm,v 1.9 2007/12/01 01:59:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -145,7 +145,7 @@ sub mapread { # Call lonsequence::attemptread to read from resource space # sub attemptread { - my $fn=shift; + my ($fn,$unsorted)=@_; my @links; my @theseres; @@ -166,6 +166,9 @@ sub attemptread { $links[$number]=$content; } } + if ($unsorted) { + return @theseres; + } # --------------------------------------------------------------- Sort, sort of @@ -245,14 +248,21 @@ sub attemptread { # ------------------------------------- Revive zombie idx or get unused number sub getresidx { - my $url=shift; + my ($url,$residx)= @_; my $max=1+($#resources>$#zombies?$#resources:$#zombies); unless ($url) { return $max; } for (my $i=0; $i<=$#zombies; $i++) { my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]); if ($src eq $url) { - undef($zombies[$i]); - return $i; + if ($residx) { + if ($i == $residx) { + undef($zombies[$i]); + return $i; + } + } else { + undef($zombies[$i]); + return $i; + } } } return $max; @@ -277,11 +287,11 @@ sub pastetarget { my @insertorder=(); foreach (@which) { if (defined($_)) { - my ($name,$url)=split(/\=/,$_); + my ($name,$url,$residx)=split(/\=/,$_); $name=&unescape($name); $url=&unescape($url); if ($url) { - my $idx=&getresidx($url); + my $idx=&getresidx($url,$residx); $insertorder[$#insertorder+1]=$idx; my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; }