--- loncom/interface/lonmeta.pm 2005/10/25 18:46:03 1.117
+++ loncom/interface/lonmeta.pm 2005/12/09 23:49:45 1.136
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.117 2005/10/25 18:46:03 albertel Exp $
+# $Id: lonmeta.pm,v 1.136 2005/12/09 23:49:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -243,16 +243,18 @@ sub fieldnames {
'authorspace' => 'Author Space',
'modifyinguser' => 'Last Modifying User',
'subject' => 'Subject',
+ 'standards' => 'Standards',
'keywords' => 'Keyword(s)',
'notes' => 'Notes',
'abstract' => 'Abstract',
'lowestgradelevel' => 'Lowest Grade Level',
- 'highestgradelevel' => 'Highest Grade Level');
+ 'highestgradelevel' => 'Highest Grade Level',
+ 'courserestricted' => 'Course Restricting Metadata');
+
if (! defined($file_type) || $file_type ne 'portfolio') {
%fields =
(%fields,
'domain' => 'Domain',
- 'standards' => 'Standards',
'mime' => 'MIME Type',
'language' => 'Language',
'creationdate' => 'Creation Date',
@@ -282,7 +284,7 @@ sub fieldnames {
'stdno' => 'Total number of students who have worked on this problem',
'difficulty' => 'Degree of difficulty',
'disc' => 'Degree of discrimination',
- 'dependencies' => 'Resources used by this resource',
+ 'dependencies' => 'Resources used by this resource',
);
}
return &Apache::lonlocal::texthash(%fields);
@@ -300,9 +302,9 @@ sub select_course {
$courses{$coursekey} = $value;
}
}
- $r->print('
Course Related Meta-Data
');
+ $r->print('Associate resource with a course
');
$r->print('');
}
return 'ok';
@@ -480,28 +483,59 @@ sub prettyinput {
if (! defined($size)) {
$size = 80;
}
+ my $output;
if (defined($course_key)) {
my $stu_add;
my $only_one;
- if ($env{$course_key.'.metadata.'.$_.'.options'} =~ m/stuadd/) {
+ my %meta_options;
+ my @cur_values_inst;
+ my $cur_values_stu;
+ my $values = $env{$course_key.'.metadata.'.$type.'.values'};
+ if ($env{$course_key.'.metadata.'.$type.'.options'} =~ m/stuadd/) {
$stu_add = 'true';
}
- if ($env{$course_key.'.metadata.'.$_.'.options'} =~ m/onlyone/) {
+ if ($env{$course_key.'.metadata.'.$type.'.options'} =~ m/onlyone/) {
$only_one = 'true';
}
- if ($type eq 'author') {
- }
- if ($type eq 'authorspace') {
- }
- if ($type eq 'modifyinguser') {
- }
- if ($type eq 'subject') {
+ # need to take instructor values out of list where instructor and student
+ # values may be mixed.
+ if ($values) {
+ foreach my $item (split(/,/,$values)) {
+ $item =~ s/^\s+//;
+ $meta_options{$item} = $item;
+ }
+ foreach my $item (split(/,/,$value)) {
+ $item =~ s/^\s+//;
+ if ($meta_options{$item}) {
+ push(@cur_values_inst,$item);
+ } else {
+ $cur_values_stu .= $item.',';
+ }
+ }
+ } else {
+ $cur_values_stu = $value;
}
- if ($type eq 'keywords') {
+ if ($type eq 'courserestricted') {
+ return ('');
}
- if ($type eq 'notes') {
+ if (($type eq 'keywords') || ($type eq 'subject')
+ || ($type eq 'author')||($type eq 'notes')
+ || ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')) {
+ if ($values) {
+ if ($only_one) {
+ $output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options));
+ } else {
+ $output .= (&Apache::loncommon::multiple_select_form('new_'.$type,\@cur_values_inst,undef,\%meta_options));
+ }
+ }
+ if ($stu_add) {
+ $output .= ''.
+ &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,
+ $relatedvalue);
+ }
+ return ($output);
}
- if ($type eq 'abstract') {
if (($type eq 'lowestgradelevel') ||
($type eq 'highestgradelevel')) {
return &Apache::loncommon::select_level_form($value,$fieldname).
@@ -569,6 +603,10 @@ sub prettyinput {
",'rights')\">".&mt('Select').''.
&relatedfield(0,$relatedsearchflag,$relatedsep);
}
+ if ($type eq 'courserestricted') {
+ return ('');
+ }
+
# Dates
if (($type eq 'creationdate') ||
($type eq 'lastrevisiondate')) {
@@ -1037,7 +1075,7 @@ ENDEDIT
my @fields;
if ($file_type eq 'portfolio') {
@fields = ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
- 'highestgradelevel');
+ 'highestgradelevel','standards','courserestricted');
} else {
@fields = ('author','title','subject','keywords','abstract','notes',
'copyright','customdistributionfile','language',
@@ -1045,30 +1083,56 @@ ENDEDIT
'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
'obsolete','obsoletereplacement');
}
- foreach (@fields) {
- if (defined($env{'form.new_'.$_})) {
- $Apache::lonpublisher::metadatafields{$_}=
- $env{'form.new_'.$_};
+ my $metacourse;
+ if ($env{'form.metacourse'} ) {
+ $Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'};
+ $metacourse = $env{'form.metacourse'};
+ } else {
+ if (! $Apache::lonpublisher::metadatafields{'courserestricted'}) {
+ $Apache::lonpublisher::metadatafields{'courserestricted'}=
+ 'none';
+ $metacourse = 'none';
+ } else {
+ $metacourse = $Apache::lonpublisher::metadatafields{'courserestricted'};
}
- if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
+ }
+ if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
$Apache::lonpublisher::metadatafields{'copyright'}=
- 'default';
+ 'default';
+ }
+ if ($metacourse ne 'none') {
+ $r->print('Using: '.$env{$metacourse.".description"}." metadata framework
");
+ }
+ 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 ($env{'form.metacourse'}) {
+ if ($metacourse ne 'none') {
# handle restrictions here
- $env{'form.metacourse'} =~ m/(^.+)\.description$/;
- my $key_base = $1;
- if ($env{$key_base.'.metadata.'.$_.'.options'} =~ m/active/) {
- $output.=(''.$lt{$_}.': '.
- &prettyinput($_,
- $Apache::lonpublisher::metadatafields{$_},
- 'new_'.$_,'defaultmeta',undef,undef,undef,undef,$key_base).'
');
- }
+ if ($env{$metacourse.'.metadata.'.$field_name.'.options'} =~ m/active/){
+ $output.=(''.$lt{$field_name}.': '.
+ &prettyinput($field_name,
+ $Apache::lonpublisher::metadatafields{$field_name},
+ 'new_'.$field_name,'defaultmeta',undef,undef,undef,undef,$metacourse).'
');
+ } elsif ($field_name eq 'courserestricted') {
+ $output.=(
+ &prettyinput($field_name,
+ $Apache::lonpublisher::metadatafields{$field_name},
+ 'new_'.$field_name,'defaultmeta',undef,undef,undef,undef,$metacourse));
+ }
} else {
- $output.=(''.$lt{$_}.': '.
- &prettyinput($_,
- $Apache::lonpublisher::metadatafields{$_},
- 'new_'.$_,'defaultmeta').'
');
+ if ($field_name ne 'courserestricted') {
+ $output.=(''.$lt{$field_name}.': '.
+ &prettyinput($field_name,
+ $Apache::lonpublisher::metadatafields{$field_name},
+ 'new_'.$field_name,'defaultmeta').'
');
+ } else {
+ $output.=&prettyinput($field_name,
+ $Apache::lonpublisher::metadatafields{$field_name},
+ 'new_'.$field_name,'defaultmeta');
+ }
}
}
if ($env{'form.store'}) {
@@ -1076,9 +1140,9 @@ ENDEDIT
my $formname='store';
my $file_content;
foreach my $meta_field (keys %env) {
- if (&Apache::loncommon::get_env_multiple('form.keywords')) {
- $Apache::lonpublisher::metadatafields{'coursekeyword'} =
- join (', ', &Apache::loncommon::get_env_multiple('form.keywords'));
+ if (&Apache::loncommon::get_env_multiple('form.new_keywords')) {
+ $Apache::lonpublisher::metadatafields{'keywords'} =
+ join (',', &Apache::loncommon::get_env_multiple('form.new_keywords'));
}
}
foreach (sort keys %Apache::lonpublisher::metadatafields) {
@@ -1092,7 +1156,7 @@ ENDEDIT
$Apache::lonpublisher::metadatakeys{$unikey})
) {
my $value=
- $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
+ $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
$value=~s/\"/\'\'/g;
$file_content.=' '.$_.'="'.$value.'"' ;
# print $mfh ' '.$_.'="'.$value.'"';
@@ -1106,7 +1170,7 @@ ENDEDIT
if ($fn =~ /\/portfolio\//) {
$fn =~ /\/portfolio\/(.*)$/;
my $new_fn = '/'.$1;
- $env{'form.'.$formname}=$file_content;
+ $env{'form.'.$formname}=$file_content."\n";
$env{'form.'.$formname.'.filename'}=$new_fn;
&Apache::lonnet::userfileupload('uploaddoc','',
'portfolio'.$env{'form.currentpath'});