--- loncom/interface/lonmeta.pm 2005/05/09 01:51:44 1.97 +++ loncom/interface/lonmeta.pm 2005/11/15 19:20:12 1.127 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.97 2005/05/09 01:51:44 banghart Exp $ +# $Id: lonmeta.pm,v 1.127 2005/11/15 19:20:12 banghart Exp $ # # Copyright Michigan State University Board of Trustees # @@ -17,7 +17,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # @@ -33,7 +33,7 @@ use LONCAPA::lonmetadata(); use Apache::Constants qw(:common); use Apache::lonnet; use Apache::loncommon(); -use Apache::lonhtmlcommon(); +use Apache::lonhtmlcommon(); use Apache::lonmsg; use Apache::lonpublisher; use Apache::lonlocal; @@ -247,7 +247,9 @@ sub fieldnames { '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, @@ -288,6 +290,43 @@ sub fieldnames { return &Apache::lonlocal::texthash(%fields); } +sub select_course { + my ($r)=@_; + my %courses; + 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; + } + } + $r->print('
'.$lt{$_}.': '. - &prettyinput($_, + my $field_name = $_; + if ($metacourse ne 'none') { + # handle restrictions here + if ($env{$metacourse.'.metadata.'.$_.'.options'} =~ m/active/){ + $output.=('
'.$lt{$_}.': '. + &prettyinput($_, + $Apache::lonpublisher::metadatafields{$_}, + 'new_'.$_,'defaultmeta',undef,undef,undef,undef,$metacourse).'
'); + } elsif ($_ eq 'courserestricted') { + $output.=( + &prettyinput($field_name, + $Apache::lonpublisher::metadatafields{$_}, + 'new_'.$field_name,'defaultmeta',undef,undef,undef,undef,$metacourse)); + } + } else { + if ($_ ne 'courserestricted') { + $output.=(''.$lt{$_}.': '. + &prettyinput($_, $Apache::lonpublisher::metadatafields{$_}, 'new_'.$_,'defaultmeta').'
'); + } else { + $output.=&prettyinput($field_name, + $Apache::lonpublisher::metadatafields{$_}, + 'new_'.$field_name,'defaultmeta'); + } + } } + $output.=(''.$lt{$_}.': '. + &prettyinput($_, + $Apache::lonpublisher::metadatafields{$_}, + 'new_'.$_,'defaultmeta',undef,undef,undef,undef,$metacourse).'
'); + if ($env{'form.store'}) { my $mfh; - my $formname='store'; + my $formname='store'; my $file_content; + foreach my $meta_field (keys %env) { + 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) { next if ($_ =~ /\./); my $unikey=$_; @@ -992,7 +1172,6 @@ ENDEDIT $env{'form.'.$formname.'.filename'}=$new_fn; &Apache::lonnet::userfileupload('uploaddoc','', 'portfolio'.$env{'form.currentpath'}); - my $status =&Apache::lonnet::userfileupload($formname,'','portfolio'); if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') { $r->print(''. &mt('Could not write metadata').', '. @@ -1025,4 +1204,4 @@ ENDEDIT 1; __END__ - \ No newline at end of file +