[LON-CAPA-cvs] cvs: rat /client ratcode.js loncom/interface groupsort.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 08 Jun 2005 21:13:08 -0000


www		Wed Jun  8 17:13:08 2005 EDT

  Modified files:              
    /loncom/interface	groupsort.pm 
    /rat/client	ratcode.js 
  Log:
  Bug #882: AdvRAT re-uses zombie-IDs
  
  
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.31 loncom/interface/groupsort.pm:1.32
--- loncom/interface/groupsort.pm:1.31	Thu Apr  7 02:56:22 2005
+++ loncom/interface/groupsort.pm	Wed Jun  8 17:13:05 2005
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.31 2005/04/07 06:56:22 albertel Exp $
+# $Id: groupsort.pm,v 1.32 2005/06/08 21:13:05 www Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -116,10 +116,9 @@
     opener.addobj(opener.maxrow,'e&2');
 }
 function placeResourceInLastRow (title,url,linkflag) {
-    opener.newresource(opener.maxrow,2,opener.escape(title),
+    opener.mostrecent=opener.newresource(opener.maxrow,2,opener.escape(title),
 		       opener.escape(url),'false','normal');
     opener.save();
-    opener.mostrecent=opener.obj.length-1;
     if (linkflag) {
 	opener.joinres(opener.linkmode,opener.mostrecent,0);
     }
Index: rat/client/ratcode.js
diff -u rat/client/ratcode.js:1.2 rat/client/ratcode.js:1.3
--- rat/client/ratcode.js:1.2	Wed Jun  8 15:23:37 2005
+++ rat/client/ratcode.js	Wed Jun  8 17:13:06 2005
@@ -1,6 +1,7 @@
 <!--
 The LearningOnline Network
 Resource Assembly Tool
+// $Id: ratcode.js,v 1.3 2005/06/08 21:13:06 www Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -95,6 +96,7 @@
 var data3=new Array(1024);
 var data4=new Array(1024);
 var data5=new Array(1024);
+var data6=new Array(1024);
 
 var inf;
 var srch;
@@ -244,8 +246,10 @@
 // ---------------------------------------------- Creates a new resource object
 function newresource(rid,cid,text,url,ext,type) {
    stored=0;
-   objcont[addobj(rid,'b&'+rid+'&'+cid+':0:0:0')]=
+   var newidx=addobj(rid,'b&'+rid+'&'+cid+':0:0:0',url);
+   objcont[newidx]=
     text+':'+url+':'+ext+':'+type+':res';
+   return newidx;
 }
 
 
@@ -464,15 +468,29 @@
 
 // ---------------------------- Make a new object and add it to the row content
 // returns object number of generated object
-function addobj(kjid,objs) {
+function addobj(kjid,objs,url) {
    stored=0;
    expense++;
    if ((rowcont[kjid]!='') && (typeof(rowcont[kjid])!="undefined")) { 
       rowcont[kjid]+=':'; 
    }
-   rowcont[kjid]+=obj.length;
-   obj[obj.length]=objs;
-   return obj.length-1;
+   var newindex=obj.length;
+   if ((url!='') && (typeof(url)!="undefined")) {
+// see if we have a zombie with that url
+      for (oidx=0;oidx<objcont.length;oidx++) {
+          if (typeof(objcont[oidx])!="undefined") {
+             data6=objcont[oidx].split(':');	
+             if (data6[4]=='zombie') {
+                if (data6[1]==url) {
+                   newindex=oidx;
+                }
+             }
+         }
+      }
+   }
+   rowcont[kjid]+=newindex;
+   obj[newindex]=objs;
+   return newindex;
 } 
 
 // ---------------------------------------- Make horizontal connection for hrid