--- loncom/interface/lonmeta.pm 2006/12/05 02:55:53 1.190
+++ loncom/interface/lonmeta.pm 2007/01/12 20:04:16 1.195
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.190 2006/12/05 02:55:53 albertel Exp $
+# $Id: lonmeta.pm,v 1.195 2007/01/12 20:04:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -235,7 +235,7 @@ sub fieldnames {
'lowestgradelevel' => 'Lowest Grade Level',
'highestgradelevel' => 'Highest Grade Level');
- if (! defined($file_type) || $file_type ne 'portfolio') {
+ if ( !defined($file_type) || ($file_type ne 'portfolio' && $file_type ne 'groups') ) {
%fields =
(%fields,
'domain' => 'Domain',
@@ -1203,6 +1203,18 @@ ENDEDIT
my @fields;
my $added_metadata_fields;
my @added_order;
+ if ($file_type eq 'groups') {
+ $Apache::lonpublisher::metadatafields{'courserestricted'}=
+ 'course.'.$env{'request.course.id'};
+ }
+ if ((! $Apache::lonpublisher::metadatafields{'courserestricted'}) &&
+ (! $env{'form.new_courserestricted'}) && (! $file_type eq 'groups')) {
+ $Apache::lonpublisher::metadatafields{'courserestricted'}=
+ 'none';
+ } elsif ($env{'form.new_courserestricted'}) {
+ $Apache::lonpublisher::metadatafields{'courserestricted'}=
+ $env{'form.new_courserestricted'};
+ }
if ($file_type eq 'portfolio' || $file_type eq 'groups') {
if(exists ($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'})) {
# retrieve fieldnames (in order) from the course restricted list
@@ -1212,11 +1224,14 @@ ENDEDIT
@fields = ('author','title','subject','keywords','abstract',
'notes','lowestgradelevel',
'highestgradelevel','standards');
- $added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames();
- if ($env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}) {
- @added_order = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'});
- }
- $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join(",",@fields);
+ if ($Apache::lonpublisher::metadatafields{'courserestricted'} =~ /^course\.($match_domain\_$match_courseid)$/) {
+ my $assoc_crs = $1;
+ $added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames($assoc_crs);
+ if ($env{'course.'.$assoc_crs.'.metadata.addedorder'}) {
+ @added_order = split(/,/,$env{'course.'.$assoc_crs.'.metadata.addedorder'});
+ }
+ $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join(",",@fields);
+ }
}
} else {
@fields = ('author','title','subject','keywords','abstract','notes',
@@ -1225,18 +1240,6 @@ ENDEDIT
'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
'obsolete','obsoletereplacement');
}
- if ($file_type eq 'groups') {
- $Apache::lonpublisher::metadatafields{'courserestricted'}=
- 'course.'.$env{'request.course.id'};
- }
- if ((! $Apache::lonpublisher::metadatafields{'courserestricted'}) &&
- (! $env{'form.new_courserestricted'}) && (! $file_type eq 'groups')) {
- $Apache::lonpublisher::metadatafields{'courserestricted'}=
- 'none';
- } elsif ($env{'form.new_courserestricted'}) {
- $Apache::lonpublisher::metadatafields{'courserestricted'}=
- $env{'form.new_courserestricted'};
- }
if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
$Apache::lonpublisher::metadatafields{'copyright'}=
'default';
@@ -1252,11 +1255,18 @@ ENDEDIT
}
if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
- $r->print(&mt('Associated with course [_1]',
+ if ($file_type eq 'portfolio') {
+ $r->print(&mt('Associated with course [_1]',
''.
$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.
".description"}.
'').'
');
+ } else {
+ $r->print(&mt('Associated with course [_1]',
+ ''.
+ $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.
+ ".description"}.'').'
');
+ }
} else {
$r->print('This resource is not associated with a course.
');
}
@@ -1342,7 +1352,7 @@ ENDEDIT
($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);
}
$r->print(&store_portfolio_metadata($formname,$file_content,$path,
- $new_fn));
+ $new_fn,$uri));
} else {
if (! ($mfh=Apache::File->new('>'.$fn))) {
$r->print('
'. @@ -1350,6 +1360,8 @@ ENDEDIT &mt('FAIL').'
'); } else { print $mfh ($file_content); + close($mfh); + &update_metadata_table($uri); $r->print(''.&mt('Wrote Metadata'). ' '.&Apache::lonlocal::locallocaltime(time). '
'); @@ -1359,16 +1371,16 @@ ENDEDIT $r->print($output.'