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

www lon-capa-cvs@mail.lon-capa.org
Fri, 10 May 2002 19:46:52 -0000


www		Fri May 10 15:46:52 2002 EDT

  Modified files:              
    /rat	lonratedt.pm 
  Log:
  Simple View and Edit buttons
  
  
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.8 rat/lonratedt.pm:1.9
--- rat/lonratedt.pm:1.8	Fri May 10 14:58:04 2002
+++ rat/lonratedt.pm	Fri May 10 15:46:52 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.8 2002/05/10 18:58:04 www Exp $
+# $Id: lonratedt.pm,v 1.9 2002/05/10 19:46:52 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,21 +52,35 @@
     my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
     if ($errtext) { return ($errtext,2); }
 
+# -------------------------------------------------------------------- Read map
     foreach (split(/\<\&\>/,$outtext)) {
-	my ($command,$parms)=split(/\<\:\>/,$_);
-        my @item=split(/\:/,$parms);
+	my ($command,$number,$content)=split(/\<\:\>/,$_);
         if ($command eq 'objcont') {
+	    $resources[$number]=$content;
         }
         if ($command eq 'objlinks') {
-	    if (defined($links[$item[0]])) {
+            $links[$number]=$content;
+        }
+    }
+# ------------------------------------------------------- Is this a linear map?
+    my @starters=();
+    my @endings=();
+    undef @starters;
+    undef @endings;
+
+    foreach (@links) {
+        if (defined($_)) {
+	    my ($start,$end,$cond)=split(/\:/,$_);
+            if ((defined($starters[$start])) || (defined($endings[$end]))) { 
 		return
                  ('Map too complex, has branchings. Use advanced editor.',1);
             }
-	    if ($links[$item[2]]) {
+	    $starters[$start]=1;
+	    $endings[$end]=1;
+	    if ($cond) {
 		return
                  ('Map too complex, has conditions. Use advanced editor.',1);
             }
-	    $links[$item[0]]=$item[1];
 	}
 
     }
@@ -227,7 +241,20 @@
 sub viewmap {
     my ($r,$adv)=@_;
     $r->print('<html><body bgcolor="#FFFFFF">'.&buttons($adv));
-
+    foreach (@resources) {
+	if (defined($_)) {
+	    my ($title,$url)=split(/\:/,$_);
+            $title=~s/\&colon\;/\:/g;
+            $url=~s/\&colon\;/\:/g;
+            unless ($title) { $title='<i>Unknown</i>'; }
+            if ($url) {
+		$r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">');
+            }
+            $r->print(&Apache::lonratsrv::qtescape($title));
+            if ($url) { $r->print('</a>'); }
+            $r->print('<br>');
+        }
+    }
     $r->print('</body></html>');
 }