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

banghart lon-capa-cvs@mail.lon-capa.org
Mon, 19 Dec 2005 16:00:07 -0000


banghart		Mon Dec 19 11:00:07 2005 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  	Make metadata for portfolio files a two-step process.
  	1. select framework
  	2. display/edit metadata
  	Still needs label changes, testing, etc. 
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.139 loncom/interface/lonmeta.pm:1.140
--- loncom/interface/lonmeta.pm:1.139	Thu Dec 15 17:18:57 2005
+++ loncom/interface/lonmeta.pm	Mon Dec 19 11:00:05 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.139 2005/12/15 22:18:57 banghart Exp $
+# $Id: lonmeta.pm,v 1.140 2005/12/19 16:00:05 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -289,7 +289,26 @@
     }
     return &Apache::lonlocal::texthash(%fields);
 }
-
+sub pre_select_course {
+    my ($r,$uri) = @_;
+    my $output;
+    my $fn=&Apache::lonnet::filelocation('',$uri);
+    my $disuri=$uri;
+    %Apache::lonpublisher::metadatafields=();
+    %Apache::lonpublisher::metadatakeys=();
+    my $result=&Apache::lonnet::getfile($fn);
+    if ($result == -1){
+        $r->print('Creating new '.$disuri);
+    } else {
+        &Apache::lonpublisher::metaeval($result);
+    }
+    $r->print('<form method="post" action="" >');
+    $output = &select_course();
+    $r->print($output.'<br /><input type="submit" name="store" value="'.
+                  &mt('Select Metadata Course Restrictions').'">');
+    $r->print('</form>');
+    return;
+}
 sub select_course {
     my %courses;
     my $output;
@@ -303,6 +322,7 @@
             $courses{$coursekey} = $value;
         }
     }
+    &Apache::lonnet::logthis('the restricted is'.$Apache::lonpublisher::metadatafields{'courserestricted'});
     my $meta_not_found = 1;
     if ($Apache::lonpublisher::metadatafields{'courserestricted'} eq 'none') {
         $selected = ' SELECTED ';
@@ -648,11 +668,15 @@
         # Looking for all bombs?
         &report_bombs($r,$uri);
     } elsif ($uri=~/\/portfolio\//) {
-	($resdomain,$resuser)=
+	    ($resdomain,$resuser)=
 	    (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|);
         $r->print(&Apache::loncommon::bodytag
           ('Edit Portfolio File Information','','','',$resdomain));
-        &present_editable_metadata($r,$uri,'portfolio');
+        if ($env{'form.store'}) {
+            &present_editable_metadata($r,$uri,'portfolio');
+        } else {
+            &pre_select_course($r,$uri);
+        }
     } elsif ($uri=~/^\/\~/) { 
         # Construction space
         $r->print(&Apache::loncommon::bodytag
@@ -1074,7 +1098,7 @@
 	my @fields;
 	if ($file_type eq 'portfolio') {
 	    @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
-	                'highestgradelevel','standards','courserestricted');
+	                'highestgradelevel','standards');
 	} else {
 	    @fields = ('author','title','subject','keywords','abstract','notes',
                  'copyright','customdistributionfile','language',