[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 13 Dec 2005 11:52:40 -0000


banghart		Tue Dec 13 06:52:40 2005 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  	Make display of course selection appear only when resource
  		not associated with course metadata framework.
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.136 loncom/interface/lonmeta.pm:1.137
--- loncom/interface/lonmeta.pm:1.136	Fri Dec  9 18:49:45 2005
+++ loncom/interface/lonmeta.pm	Tue Dec 13 06:52:37 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.136 2005/12/09 23:49:45 albertel Exp $
+# $Id: lonmeta.pm,v 1.137 2005/12/13 11:52:37 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -291,8 +291,8 @@
 }
 
 sub select_course {
-    my ($r)=@_;
     my %courses;
+    my $output;
     foreach my $key (keys (%env)) { 
         if ($key =~ m/\.metadata\./) {
             $key =~ m/^course\.(.+)(\.metadata.+$)/;
@@ -302,30 +302,30 @@
             $courses{$coursekey} = $value;
         }
     }
-    $r->print('<h3>Associate resource with a course</h3><br />');
-    $r->print('<form action="" method="post">');
-    $r->print('Select course <br />');
-    $r->print('<select name="metacourse" >');
+    $output = '<h3>Associate resource with a course</h3><br />';
+    $output .= '<form action="" method="post">';
+    $output .= 'Select course <br />';
+    $output .= '<select name="metacourse" >';
     my $meta_not_found = 1;
     foreach my $key (keys (%courses)) {    
         if ($meta_not_found) {
             undef($meta_not_found);
-            $r->print('<h3>Portfolio Meta-Data</h3><br />');
-            $r->print('<form action="" method="post">');
-            $r->print('Select your course<br />');
-            $r->print('<select name="metacourse" >');
+            $output .= '<h3>Portfolio Meta-Data</h3><br />';
+            $output .= '<form action="" method="post">';
+            $output .= 'Select your course<br />';
+            $output .= '<select name="metacourse" >';
         }
         $key =~ m/(^.+)\.description$/;
-        $r->print('<option value="'.$1.'">');
-        $r->print($courses{$key});
-        $r->print('</option>');
+        $output .= '<option value="'.$1.'">';
+        $output .= $courses{$key};
+        $output .= '</option>';
     }
     unless ($meta_not_found) {
-        $r->print('</select><br />');
-        $r->print('<input type="submit" value="Associate" />');
-        $r->print('</form>');
+        $output .= '</select><br />';
+        $output .= '<input type="submit" value="Associate" />';
+        $output .= '</form>';
     }
-    return 'ok';
+    return ($output);
 }
 # Pretty printing of metadata field
 
@@ -653,7 +653,6 @@
         $r->print(&Apache::loncommon::bodytag
           ('Edit Portfolio File Information','','','',$resdomain));
         &present_editable_metadata($r,$uri,'portfolio');
-        &select_course($r);
     } elsif ($uri=~/^\/\~/) { 
         # Construction space
         $r->print(&Apache::loncommon::bodytag
@@ -1003,6 +1002,7 @@
     # Header
     my $disuri=$uri;
     my $fn=&Apache::lonnet::filelocation('',$uri);
+    my $metacourse;
     $disuri=~s/^\/\~/\/priv\//;
     $disuri=~s/\.meta$//;
     $disuri=~s|^/editupload||;
@@ -1083,7 +1083,6 @@
                  'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
                  'obsolete','obsoletereplacement');
         }
-        my $metacourse;
         if ($env{'form.metacourse'} ) {
             $Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'};
             $metacourse = $env{'form.metacourse'};
@@ -1101,7 +1100,10 @@
                 'default';
         }
         if ($metacourse ne 'none') {
-             $r->print('Using: <strong> '.$env{$metacourse.".description"}."</strong> metadata framework<br />");
+            $r->print('Using: <strong> '.$env{$metacourse.".description"}.
+                        "</strong> metadata framework<br />");
+        } else {
+            $r->print("This resources is not associated with a metadata framework<br />");
         }
         foreach my $field_name(@fields) {
 
@@ -1135,6 +1137,7 @@
                 }
             }
         }
+
         if ($env{'form.store'}) {
             my $mfh;
             my $formname='store'; 
@@ -1196,10 +1199,14 @@
                 }
             }
         }
-	$r->print($output.'<br /><input type="submit" name="store" value="'.
+	    $r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Store Catalog Information').'">');
+        
     }
     $r->print('</form>');
+    if ($metacourse eq 'none') {
+        $r->print(&select_course());
+    }
     return;
 }