--- loncom/interface/lonmeta.pm 2005/12/19 23:19:18 1.148
+++ loncom/interface/lonmeta.pm 2006/01/04 05:43:19 1.150
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.148 2005/12/19 23:19:18 albertel Exp $
+# $Id: lonmeta.pm,v 1.150 2006/01/04 05:43:19 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -248,8 +248,13 @@ sub fieldnames {
'notes' => 'Notes',
'abstract' => 'Abstract',
'lowestgradelevel' => 'Lowest Grade Level',
- 'highestgradelevel' => 'Highest Grade Level',
- 'courserestricted' => 'Course Restricting Metadata');
+ 'highestgradelevel' => 'Highest Grade Level');
+
+ if (! defined($file_type) || $file_type ne 'portfolio') {
+ %fields =
+ (%fields,
+ 'courserestricted' => 'Course Restricting Metadata');
+ }
if (! defined($file_type) || $file_type ne 'portfolio') {
%fields =
@@ -353,36 +358,31 @@ sub pre_select_course {
return;
}
sub select_course {
- my %courses;
- my $output;
- my $selected;
- 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;
- }
- }
- my $meta_not_found = 1;
- if ($Apache::lonpublisher::metadatafields{'courserestricted'} eq 'none') {
- $selected = ' SELECTED ';
- } else {
- $selected = '';
- }
+ my $output=$/;
+ my $current_restriction=
+ $Apache::lonpublisher::metadatafields{'courserestricted'};
+ my $selected = ($current_restriction eq 'none' ? 'selected="selected"'
+ : '');
+
$output .= '
';
return ($output);
@@ -544,7 +544,8 @@ sub prettyinput {
$size = 80;
}
my $output;
- if (defined($course_key)) {
+ if (defined($course_key)
+ && exists($env{$course_key.'.metadata.'.$type.'.options'})) {
my $stu_add;
my $only_one;
my %meta_options;
@@ -1164,19 +1165,22 @@ ENDEDIT
$Apache::lonpublisher::metadatafields{'copyright'}=
'default';
}
- if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
- $r->print(&mt('Associated with course [_1]',''.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}.
- '').'
');
- } else {
- $r->print("This resource is not associated with a course.
");
- }
+ if ($file_type eq 'portfolio') {
+ if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
+ $r->print(&mt('Associated with course [_1]',''.$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.".description"}.
+ '').'
');
+ } else {
+ $r->print("This resource is not associated with a course.
");
+ }
+ }
foreach my $field_name (@fields) {
if (defined($env{'form.new_'.$field_name})) {
$Apache::lonpublisher::metadatafields{$field_name}=
join(',',&Apache::loncommon::get_env_multiple('form.new_'.$field_name));
}
- if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
+ if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none'
+ && exists($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'})) {
# handle restrictions here
if (($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/active/) ||
($field_name eq 'courserestricted')){
@@ -1260,12 +1264,14 @@ ENDEDIT
$r->print($output.'
');
- $r->print('
+ if ($file_type eq 'portfolio') {
+ $r->print('