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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Thu, 12 Jul 2007 19:54:44 -0000


albertel		Thu Jul 12 15:54:44 2007 EDT

  Modified files:              
    /rat/client	ratcode.js 
    /loncom/interface	groupsort.pm 
  Log:
  - when recovering deleted resource in Advanced RAT, support recovering
    the correct id number if possible
  
  
  
Index: rat/client/ratcode.js
diff -u rat/client/ratcode.js:1.6 rat/client/ratcode.js:1.7
--- rat/client/ratcode.js:1.6	Mon Jun 19 05:43:02 2006
+++ rat/client/ratcode.js	Thu Jul 12 15:54:40 2007
@@ -1,7 +1,7 @@
 <!--
 The LearningOnline Network
 Resource Assembly Tool
-// $Id: ratcode.js,v 1.6 2006/06/19 09:43:02 www Exp $
+// $Id: ratcode.js,v 1.7 2007/07/12 19:54:40 albertel Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -244,9 +244,10 @@
 }
 
 // ---------------------------------------------- Creates a new resource object
-function newresource(rid,cid,text,url,ext,type) {
+function newresource(rid,cid,text,url,ext,type,oldidx) {
    stored=0;
-   var newidx=addobj(rid,'b&'+rid+'&'+cid+':0:0:0',url);
+   var newidx=addobj(rid,'b&'+rid+'&'+cid+':0:0:0',url,oldidx);
+
    objcont[newidx]=
     text+':'+url+':'+ext+':'+type+':res';
    return newidx;
@@ -468,7 +469,7 @@
 
 // ---------------------------- Make a new object and add it to the row content
 // returns object number of generated object
-function addobj(kjid,objs,url) {
+function addobj(kjid,objs,url,oldindex) {
    stored=0;
    expense++;
    if ((rowcont[kjid]!='') && (typeof(rowcont[kjid])!="undefined")) { 
@@ -476,13 +477,19 @@
    }
    var newindex=obj.length;
    if ((url!='') && (typeof(url)!="undefined")) {
-// see if we have a zombie with that url
+// see if we have a zombie with that url and possibly oldindex
       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;
+		   if (typeof(oldindex) == "undefined") {
+                     newindex=oidx;
+                   } else {
+                     if (oidx == oldindex) {
+                       newindex=oidx;
+                     }
+                   }
                 }
              }
          }
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.58 loncom/interface/groupsort.pm:1.59
--- loncom/interface/groupsort.pm:1.58	Wed Jul 11 21:04:36 2007
+++ loncom/interface/groupsort.pm	Thu Jul 12 15:54:43 2007
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.58 2007/07/12 01:04:36 albertel Exp $
+# $Id: groupsort.pm,v 1.59 2007/07/12 19:54:43 albertel Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -246,6 +246,7 @@
 	placeResourceInLastRow(
 	       eval("document.forms.groupsort.title"+num+".value"),
  	       eval("document.forms.groupsort.filelink"+num+".value"),
+ 	       eval("document.forms.groupsort.id"+num+".value"),
 	       linkflag
 	);
         linkflag=true;
@@ -267,9 +268,9 @@
     opener.insertrow(opener.maxrow);
     opener.addobj(opener.maxrow,'e&2');
 }
-function placeResourceInLastRow (title,url,linkflag) {
+function placeResourceInLastRow (title,url,id,linkflag) {
     opener.mostrecent=opener.newresource(opener.maxrow,2,opener.escape(title),
-		       opener.escape(url),'false','normal');
+		       opener.escape(url),'false','normal',id);
     opener.save();
     if (linkflag) {
 	opener.joinres(opener.linkmode,opener.mostrecent,0);