--- loncom/interface/lonmeta.pm 2005/11/22 19:43:53 1.132 +++ loncom/interface/lonmeta.pm 2005/12/13 11:52:37 1.137 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.132 2005/11/22 19:43:53 banghart Exp $ +# $Id: lonmeta.pm,v 1.137 2005/12/13 11:52:37 banghart Exp $ # # Copyright Michigan State University Board of Trustees # @@ -243,6 +243,7 @@ sub fieldnames { 'authorspace' => 'Author Space', 'modifyinguser' => 'Last Modifying User', 'subject' => 'Subject', + 'standards' => 'Standards', 'keywords' => 'Keyword(s)', 'notes' => 'Notes', 'abstract' => 'Abstract', @@ -254,7 +255,6 @@ sub fieldnames { %fields = (%fields, 'domain' => 'Domain', - 'standards' => 'Standards', 'mime' => 'MIME Type', 'language' => 'Language', 'creationdate' => 'Creation Date', @@ -284,15 +284,15 @@ 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); } sub select_course { - my ($r)=@_; my %courses; + my $output; foreach my $key (keys (%env)) { if ($key =~ m/\.metadata\./) { $key =~ m/^course\.(.+)(\.metadata.+$)/; @@ -302,30 +302,30 @@ sub select_course { $courses{$coursekey} = $value; } } - $r->print('

Course Related Meta-Data


'); - $r->print('
'); - $r->print('Select course restrictions
'); - $r->print(''; my $meta_not_found = 1; foreach my $key (keys (%courses)) { if ($meta_not_found) { undef($meta_not_found); - $r->print('

Portfolio Meta-Data


'); - $r->print(''); - $r->print('Select your course
'); - $r->print(''; } $key =~ m/(^.+)\.description$/; - $r->print(''); + $output .= ''; } unless ($meta_not_found) { - $r->print('
'); - $r->print(''); - $r->print('
'); + $output .= '
'; + $output .= ''; + $output .= ''; } - return 'ok'; + return ($output); } # Pretty printing of metadata field @@ -499,10 +499,10 @@ sub prettyinput { } # need to take instructor values out of list where instructor and student # values may be mixed. - if ($values && $stu_add) { + if ($values) { foreach my $item (split(/,/,$values)) { $item =~ s/^\s+//; - $meta_options{$item} = $type; + $meta_options{$item} = $item; } foreach my $item (split(/,/,$value)) { $item =~ s/^\s+//; @@ -520,10 +520,10 @@ sub prettyinput { } if (($type eq 'keywords') || ($type eq 'subject') || ($type eq 'author')||($type eq 'notes') - || ($type eq 'abstract')|| ($type eq 'title')) { + || ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards')) { if ($values) { if ($only_one) { - $output .= (&Apache::loncommon::select_form($value,'new_'.$type,%meta_options)); + $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)); } @@ -603,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')) { @@ -649,7 +653,6 @@ sub handler { $r->print(&Apache::loncommon::bodytag ('Edit Portfolio File Information','','','',$resdomain)); &present_editable_metadata($r,$uri,'portfolio'); - &select_course($r); } elsif ($uri=~/^\/\~/) { # Construction space $r->print(&Apache::loncommon::bodytag @@ -999,6 +1002,7 @@ sub present_editable_metadata { # Header my $disuri=$uri; my $fn=&Apache::lonnet::filelocation('',$uri); + my $metacourse; $disuri=~s/^\/\~/\/priv\//; $disuri=~s/\.meta$//; $disuri=~s|^/editupload||; @@ -1071,7 +1075,7 @@ ENDEDIT my @fields; if ($file_type eq 'portfolio') { @fields = ('author','title','subject','keywords','abstract','notes','lowestgradelevel', - 'highestgradelevel','courserestricted'); + 'highestgradelevel','standards','courserestricted'); } else { @fields = ('author','title','subject','keywords','abstract','notes', 'copyright','customdistributionfile','language', @@ -1079,7 +1083,6 @@ ENDEDIT 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', 'obsolete','obsoletereplacement'); } - my $metacourse; if ($env{'form.metacourse'} ) { $Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'}; $metacourse = $env{'form.metacourse'}; @@ -1097,7 +1100,10 @@ ENDEDIT 'default'; } if ($metacourse ne 'none') { - $r->print('Document metadata restricted by : '.$env{$metacourse.".description"}."
"); + $r->print('Using: '.$env{$metacourse.".description"}. + " metadata framework
"); + } else { + $r->print("This resources is not associated with a metadata framework
"); } foreach my $field_name(@fields) { @@ -1131,6 +1137,7 @@ ENDEDIT } } } + if ($env{'form.store'}) { my $mfh; my $formname='store'; @@ -1152,7 +1159,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.'"'; @@ -1166,7 +1173,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'}); @@ -1192,10 +1199,14 @@ ENDEDIT } } } - $r->print($output.'
'); + } $r->print(''); + if ($metacourse eq 'none') { + $r->print(&select_course()); + } return; }