[LON-CAPA-cvs] cvs: rat / lonratedt.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 20 May 2002 18:54:55 -0000


www		Mon May 20 14:54:55 2002 EDT

  Modified files:              
    /rat	lonratedt.pm 
  Log:
  Does save now
  
  
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.21 rat/lonratedt.pm:1.22
--- rat/lonratedt.pm:1.21	Sat May 18 14:24:34 2002
+++ rat/lonratedt.pm	Mon May 20 14:54:55 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.21 2002/05/18 18:24:34 www Exp $
+# $Id: lonratedt.pm,v 1.22 2002/05/20 18:54:55 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -305,6 +305,7 @@
 sub startfinish {
     foreach (@order) {
 	my ($name,$url,$ext)=split(/\:/,$resources[$_]);
+        if ($url=~/http\&colon\:\/\//) { $ext='true'; }
         $resources[$_]=$name.':'.$url.':'.$ext.':normal:res';
     }
    my ($name,$url,$ext)=split(/\:/,$resources[0]);
@@ -313,10 +314,35 @@
    $resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res';
 }
 
+# ------------------------------------------------------------------- Store map
+
+sub storemap {
+    my $fn=shift;
+    &startfinish();
+    my $output='graphdef<:>no';
+    my $k=1;
+    for (my $i=0; $i<=$#order; $i++) {
+        if (defined($resources[$order[$i]])) {
+	    $output.='<&>objcont<:>'.$order[$i].'<:>'.$resources[$order[$i]];
+        }
+        if (defined($order[$i+1])) {
+	    if (defined($resources[$order[$i+1]])) {
+               $output.='<&>objlinks<:>'.$k.'<:>'.
+		   $order[$i].':'.$order[$i+1].':0';
+	       $k++;
+            }
+        }
+    }
+    $output=~s/http\&colon\:\/\///g;
+    $ENV{'form.output'}=$output;
+    return 
+     &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
+}
+
 # ------------------------------------------------------- Simple edit processor
 
 sub smpedt {
-   my ($r,$errtext)=@_;
+   my ($r,$url,$errtext)=@_;
    my $buttons=&buttons(2);
 
 # ---------------------------------------------------------- Process form input
@@ -440,7 +466,7 @@
            $lastsel=$#order;
        }
        &pastetarget($lastsel,split(/\&/,$ENV{'form.importdetail'}));
-       &startfinish();
+       &storemap(&Apache::lonnet::filelocation('',$url));
 # ------------------------------------------------------------------------- Cut
    } elsif ($ENV{'form.cut'}) {
 # ----------------------------------------------------------------------- Paste
@@ -738,7 +764,7 @@
   if ($ENV{'form.forceadv'}) {
       &ratedt($r,$url);
   } elsif ($ENV{'form.forcesmp'}) {
-      &smpedt($r,$errtext);
+      &smpedt($r,$url,$errtext);
   } else {
       &viewmap($r,$url,$adv,$errtext);
   }