[LON-CAPA-cvs] cvs: rat / lonratedt.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 22 Jan 2003 17:25:03 -0000
www Wed Jan 22 12:25:03 2003 EDT
Modified files:
/rat lonratedt.pm
Log:
Bug #962
Automatically removes "NO RESOURCE" in DOCS if enough real resources are
present.
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.42 rat/lonratedt.pm:1.43
--- rat/lonratedt.pm:1.42 Fri Dec 6 07:58:11 2002
+++ rat/lonratedt.pm Wed Jan 22 12:25:03 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.42 2002/12/06 12:58:11 www Exp $
+# $Id: lonratedt.pm,v 1.43 2003/01/22 17:25:03 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -318,17 +318,38 @@
# modifies @resources
sub startfinish {
+# Remove all start and finish
foreach (@order) {
my ($name,$url,$ext)=split(/\:/,$resources[$_]);
if ($url=~/http\&colon\:\/\//) { $ext='true'; }
$resources[$_]=$name.':'.$url.':'.$ext.':normal:res';
}
+# Garbage collection
+ my $stillchange=1;
+ while (($#order>1) && ($stillchange)) {
+ $stillchange=0;
+ for (my $i=0;$i<=$#order;$i++) {
+ my ($name,$url,$ext)=split(/\:/,$resources[$order[$i]]);
+ unless ($url) {
+# Take out empty resource
+ for (my $j=$i+1;$j<=$#order;$j++) {
+ $order[$j-1]=$order[$j];
+ }
+ $#order--;
+ $stillchange=1;
+ last;
+ }
+ }
+ }
+# Put in a start resource
my ($name,$url,$ext)=split(/\:/,$resources[$order[0]]);
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res';
+# Make sure this has at least start and finish
if ($#order==0) {
$resources[$#resources+1]='::false';
$order[1]=$#resources;
}
+# Make the last one a finish resource
($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]);
$resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res';
}