[LON-CAPA-cvs] cvs: loncom /interface groupsort.pm londocs.pm rat map.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Thu, 12 Jul 2007 01:04:36 -0000


albertel		Wed Jul 11 21:04:36 2007 EDT

  Modified files:              
    /rat	map.pm 
    /loncom/interface	londocs.pm groupsort.pm 
  Log:
  - when having multipled deleted resources with the same urls, restore
    the one with id you wanted to restore
  
  
Index: rat/map.pm
diff -u rat/map.pm:1.6 rat/map.pm:1.7
--- rat/map.pm:1.6	Fri Jan 26 18:37:51 2007
+++ rat/map.pm	Wed Jul 11 21:04:32 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # routines for modyfing .sequence and .page files
 #
-# $Id: map.pm,v 1.6 2007/01/26 23:37:51 albertel Exp $
+# $Id: map.pm,v 1.7 2007/07/12 01:04:32 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -245,14 +245,21 @@
 # ------------------------------------- Revive zombie idx or get unused number
 
 sub getresidx {
-    my $url=shift;
+    my ($url,$residx)= @_;
     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;
+	    if ($residx) {
+		if ($i == $residx) {
+		    undef($zombies[$i]);
+		    return $i;
+		}
+	    } else {
+		undef($zombies[$i]);
+		return $i;
+	    }
 	}
     }
     return $max;
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.287 loncom/interface/londocs.pm:1.288
--- loncom/interface/londocs.pm:1.287	Fri Jul  6 20:53:24 2007
+++ loncom/interface/londocs.pm	Wed Jul 11 21:04:36 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.287 2007/07/07 00:53:24 albertel Exp $
+# $Id: londocs.pm,v 1.288 2007/07/12 01:04:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -932,9 +932,10 @@
             }
         }
 	if ($url) {
-	    if (!$residx) {
-		$residx = &LONCAPA::map::getresidx($url);
-		$LONCAPA::map::order[$#LONCAPA::map::order+1]=$residx;
+	    if (!$residx 
+		|| defined($LONCAPA::map::zombies[$residx])) {
+		$residx = &LONCAPA::map::getresidx($url,$residx);
+		push(@LONCAPA::map::order, $residx);
 	    }
 	    my $ext = 'false';
 	    if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.57 loncom/interface/groupsort.pm:1.58
--- loncom/interface/groupsort.pm:1.57	Wed Jul 11 20:27:13 2007
+++ loncom/interface/groupsort.pm	Wed Jul 11 21:04:36 2007
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.57 2007/07/12 00:27:13 albertel Exp $
+# $Id: groupsort.pm,v 1.58 2007/07/12 01:04:36 albertel Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -160,7 +160,6 @@
 			if ($token->[2]->{'type'} eq 'zombie') { next; }
 		    }
 
-		    my $url=$token->[2]->{'src'};
                     my $name=$token->[2]->{'title'};
 		    $name=~s/ \[\((\d+)\,($LONCAPA::username_re)\,($LONCAPA::domain_re)\)\]$//;
 		    my $note;
@@ -170,9 +169,10 @@
 			    &Apache::lonlocal::locallocaltime($1);
 		    }
 		    $name=~s/\&colon\;/\:/g;
-		    push(@{$resources}, {'url'   => $url,
+		    push(@{$resources}, {'url'   => $token->[2]->{'src'},
 					 'title' => $name,
-					 'note'  => $note, });
+					 'note'  => $note,
+				         'id'    => $token->[2]->{'id'},});
 		}
 	    }
 	}
@@ -228,7 +228,8 @@
 	$begincondition
 	opener.document.forms.simpleedit.importdetail.value+='&'+
               escape(eval("document.forms.groupsort.title"+num+".value"))+'='+
-	      escape(eval("document.forms.groupsort.filelink"+num+".value"));
+	      escape(eval("document.forms.groupsort.filelink"+num+".value"))+'='+
+	      escape(eval("document.forms.groupsort.id"+num+".value"));
 	$endcondition
     }
     opener.document.forms.simpleedit.submit();
@@ -393,7 +394,8 @@
 		$r->print(&movers($clen,$ctr));
 	    }
 	}
-	$r->print(&hidden($ctr-1,$resource->{'title'},$resource->{'url'}));
+	$r->print(&hidden($ctr-1,$resource->{'title'},$resource->{'url'},
+			  $resource->{'id'}));
 	if (($clen > 1)  || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
 	    $r->print("</td>");
             unless (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
@@ -425,12 +427,13 @@
 
 # --------------------------------------- Hidden values (returns scalar string)
 sub hidden {
-    my ($sel,$title,$filelink) = @_;
+    my ($sel,$title,$filelink,$id) = @_;
     my $string = '<input type="hidden" name="title'.$sel.'" value="'.$title.
 	'" />';
     $filelink=~s|^/ext/|http://|;
     $string .= '<input type="hidden" name="filelink'.$sel.'" value="'.
 	$filelink.'" />';
+    $string .= '<input type="hidden" name="id'.$sel.'" value="'.$id.'" />';
     return $string;
 }