--- rat/lonratedt.pm 2005/06/08 16:35:46 1.69 +++ rat/lonratedt.pm 2005/06/09 21:40:37 1.72 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.69 2005/06/08 16:35:46 www Exp $ +# $Id: lonratedt.pm,v 1.72 2005/06/09 21:40:37 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,7 +33,7 @@ package Apache::lonratedt; =head1 NAME -Apache::lonratedt: advanced resource assembly tool +Apache::lonratedt: simple resource assembly tool =head1 SYNOPSIS @@ -173,7 +173,7 @@ use Apache::loncommon; use Apache::lonlocal; use File::Copy; -use vars qw(@order @resources @resparms @zombies %revzombies); +use vars qw(@order @resources @resparms @zombies); # Mapread read maps into global arrays @links and @resources, determines status @@ -189,13 +189,11 @@ sub mapread { undef @order; undef @resparms; undef @zombies; - undef %revzombies; @resources=(''); @order=(); @resparms=(); @zombies=(); - %revzombies=(); my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); if ($errtext) { return ($errtext,2); } @@ -210,7 +208,6 @@ sub mapread { $resources[$number]=$content; } else { $zombies[$number]=$content; - $revzombies{$src}=$number; } } if ($command eq 'objlinks') { @@ -449,10 +446,31 @@ sub buttons { return $output.'
'; } -# ----------------------------------------------------- Get an unused res index +# ------------------------------------- Revive zombie idx or get unused number -sub unusedindex { - return 1+($#resources>$#zombies?$#resources:$#zombies); +sub getresidx { + my $url=shift; + 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; + } + } + return $max; +} + +# --------------------------------------------------------------- Make a zombie + +sub makezombie { + my $idx=shift; + my ($name,$url,$ext)=split(/\:/,$resources[$idx]); + my $now=time; + $zombies[$idx]=$name. + ' [('.$now.','.$env{'user.name'}.','.$env{'user.domain'}.')]:'. + $url.':'.$ext.':zombie'; } # ----------------------------------------------------------- Paste into target @@ -467,7 +485,7 @@ sub pastetarget { $name=&Apache::lonnet::unescape($name); $url=&Apache::lonnet::unescape($url); if ($url) { - my $idx=&unusedindex(); + my $idx=&getresidx($url); $insertorder[$#insertorder+1]=$idx; my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } @@ -513,7 +531,7 @@ sub startfinish { $resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res'; # Make sure this has at least start and finish if ($#order==0) { - $resources[&unusedindex()]='::false'; + $resources[&getresidx()]='::false'; $order[1]=$#resources; } # Make the last one a finish resource @@ -906,7 +924,11 @@ sub smpedt { foreach (@targetselect) { if ($_-1==$i) { $include=0; } } - if ($include) { $neworder[$#neworder+1]=$order[$i]; } + if ($include) { + $neworder[$#neworder+1]=$order[$i]; + } else { + &makezombie($order[$i]); + } } @order=@neworder; &storemap(&Apache::lonnet::filelocation('',$url)); 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.