[LON-CAPA-cvs] cvs: rat / lonratedt.pm loncom/interface londocs.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 08 Jun 2005 17:42:04 -0000
www Wed Jun 8 13:42:04 2005 EDT
Modified files:
/loncom/interface londocs.pm
/rat lonratedt.pm
Log:
Saving my work: Zombies
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.177 loncom/interface/londocs.pm:1.178
--- loncom/interface/londocs.pm:1.177 Sun Jun 5 03:10:32 2005
+++ loncom/interface/londocs.pm Wed Jun 8 13:42:01 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.177 2005/06/05 07:10:32 albertel Exp $
+# $Id: londocs.pm,v 1.178 2005/06/08 17:42:01 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -852,7 +852,7 @@
}
}
if ($url) {
- my $idx = $#Apache::lonratedt::resources + 1;
+ my $idx = &Apache::lonratedt::getresidx($url);
$Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
my $ext = 'false';
if ($url=~/^http:\/\//) { $ext = 'true'; }
@@ -914,8 +914,10 @@
($errtext,$fatal)=
&mapread($coursenum,$coursedom,$folder.'.'.$container);
if ($#Apache::lonratedt::order<1) {
- $Apache::lonratedt::order[0]=1;
- $Apache::lonratedt::resources[1]='';
+ my $idx=&Apache::lonratedt::getresidx();
+ if ($idx<=0) { $idx=1; }
+ $Apache::lonratedt::order[0]=$idx;
+ $Apache::lonratedt::resources[$idx]='';
}
if (defined($env{'form.markcopy'})) {
# Mark for copying
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.69 rat/lonratedt.pm:1.70
--- rat/lonratedt.pm:1.69 Wed Jun 8 12:35:46 2005
+++ rat/lonratedt.pm Wed Jun 8 13:42:01 2005
@@ -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.70 2005/06/08 17:42:01 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -173,7 +173,7 @@
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 @@
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 @@
$resources[$number]=$content;
} else {
$zombies[$number]=$content;
- $revzombies{$src}=$number;
}
}
if ($command eq 'objlinks') {
@@ -449,10 +446,20 @@
return $output.'</form><hr>';
}
-# ----------------------------------------------------- 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;
}
# ----------------------------------------------------------- Paste into target
@@ -467,7 +474,7 @@
$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 +520,7 @@
$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