--- loncom/interface/lonmeta.pm	2005/10/06 22:20:30	1.110
+++ loncom/interface/lonmeta.pm	2005/10/17 21:36:44	1.113
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.110 2005/10/06 22:20:30 albertel Exp $
+# $Id: lonmeta.pm,v 1.113 2005/10/17 21:36:44 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -237,8 +237,11 @@ sub diffgraph {
 # The field names
 sub fieldnames {
     my $file_type=shift;
-    my %fields = 
-        ('title' => 'Title',
+    my %fields;
+    if ($file_type eq 'portfolio') {
+        %fields = 
+        (%fields,
+         'title' => 'Title',
          'author' =>'Author(s)',
          'authorspace' => 'Author Space',
          'modifyinguser' => 'Last Modifying User',
@@ -248,6 +251,21 @@ sub fieldnames {
          'abstract' => 'Abstract',
          'lowestgradelevel' => 'Lowest Grade Level',
          'highestgradelevel' => 'Highest Grade Level');
+    }
+    if ($file_type eq 'restrictedportfolio') {
+        %fields = 
+        (%fields,
+         'metadata.title' => 'Title',
+         'metadata.author' =>'Author(s)',
+         'metadata.authorspace' => 'Author Space',
+         'metadata.modifyinguser' => 'Last Modifying User',
+         'metadata.subject' => 'Subject',
+         'metadata.keywords' => 'Keyword(s)',
+         'metadata.notes' => 'Notes',
+         'metadata.abstract' => 'Abstract',
+         'metadata.lowestgradelevel' => 'Lowest Grade Level',
+         'metadata.highestgradelevel' => 'Highest Grade Level');
+    }        
     if (! defined($file_type) || $file_type ne 'portfolio') {
         %fields = 
         (%fields,
@@ -290,30 +308,36 @@ sub fieldnames {
 
 sub select_course {
     my ($r)=@_;
-    $r->print('<h3>Instructor Selected Meta-Data</h3><br />');
+    my %courses;
+    foreach my $key (keys (%env)) { 
+        if ($key =~ m/\.metadata\./) {
+            $key =~ m/^course\.(.+)(\.metadata.+$)/;
+            my $course = $1;
+            my $coursekey = 'course.'.$course.'.description';
+            my $value = $env{$coursekey};
+            $courses{$coursekey} = $value;
+        }
+    }
+    $r->print('<h3>Course Related Meta-Data</h3><br />');
     $r->print('<form action="" method="post">');
-    $r->print('Select your course<br />');
+    $r->print('Select your test course<br />');
     $r->print('<select name="metacourse" >');
     my $meta_not_found = 1;
-    foreach my $key (keys %env) {        
-        if ($key =~ /\.metadata\./) {
-            if ($meta_not_found) {
-                undef($meta_not_found);
-                $r->print('<h3>Instructor Selected Meta-Data</h3><br />');
-                $r->print('<form action="" method="post">');
-                $r->print('Select your course<br />');
-                $r->print('<select name="metacourse" >');
-            }
-            my $course_key = $key;
-            $course_key =~ s/\.metadata\..*//;
-            $r->print('<option value="'.$course_key.'">');
-            $r->print($env{$course_key.'.description'});
-            $r->print('</option>');
+    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" >');
         }
+        $r->print('<option value="'.$key.'">');
+        $r->print($courses{$key});
+        $r->print('</option>');
     }
     unless ($meta_not_found) {
         $r->print('</select><br />');
-        $r->print('<input type="submit" value="Assign Instructor Metadata" />');
+        $r->print('<input type="submit" value="Assign Portfolio Metadata" />');
         $r->print('</form>');
     }
     return 'ok';