--- loncom/interface/lonmeta.pm 2005/10/31 21:11:45 1.121 +++ loncom/interface/lonmeta.pm 2005/12/19 21:49:12 1.146 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.121 2005/10/31 21:11:45 banghart Exp $ +# $Id: lonmeta.pm,v 1.146 2005/12/19 21:49:12 albertel 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,16 +284,77 @@ 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 portfolio_linked_path { + my ($path) = @_; + my $result = &Apache::portfolio::make_anchor('portfolio','/'); + my $fullpath = '/'; + my (undef,@tree) = split('/',$path); + foreach my $dir (@tree) { + $fullpath .= $dir.'/'; + $result .= '/'; + $result .= &Apache::portfolio::make_anchor($dir,$fullpath); + } + return $result; +} + +sub portfolio_display_uri { + my ($uri,$as_links)=@_; + $uri =~ s|.*/(portfolio/.*)$|$1|; + my ($res_uri,$meta_uri) = ($uri,$uri); + + if ($uri =~ /\.meta$/) { + $res_uri =~ s/\.meta//; + } else { + $meta_uri .= '.meta'; + } + + my ($path) = ($res_uri =~ m|(.*)/[^/]*$|); + + if ($as_links) { + $res_uri = &portfolio_linked_path($res_uri); + $meta_uri = &portfolio_linked_path($meta_uri); + } + return ($res_uri,$meta_uri,$path); +} + +sub pre_select_course { + my ($r,$uri) = @_; + my $output; + my $fn=&Apache::lonnet::filelocation('',$uri); + my ($res_uri,$meta_uri,$path) = &portfolio_display_uri($uri); + %Apache::lonpublisher::metadatafields=(); + %Apache::lonpublisher::metadatakeys=(); + my $result=&Apache::lonnet::getfile($fn); + if ($result == -1){ + $r->print(&mt('Creating new file [_1]'),$meta_uri); + } else { + &Apache::lonpublisher::metaeval($result); + } + $r->print('
'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'',''.$res_uri.'').'
'.$lt{$_}.': '. - &prettyinput($_, - $Apache::lonpublisher::metadatafields{$_}, - 'new_'.$_,'defaultmeta',undef,undef,undef,undef,$metacourse).'
'.$lt{$field_name}.': '. + &prettyinput($field_name, + $Apache::lonpublisher::metadatafields{$field_name}, + 'new_'.$field_name,'defaultmeta', + undef,undef,undef,undef, + $Apache::lonpublisher::metadatafields{'courserestricted'}).'
'.$lt{$_}.': '. - &prettyinput($_, - $Apache::lonpublisher::metadatafields{$_}, - 'new_'.$_,'defaultmeta').'
'.$lt{$field_name}.': '. + &prettyinput($field_name, + $Apache::lonpublisher::metadatafields{$field_name}, + 'new_'.$field_name,'defaultmeta').'
'. - &mt('Could not write metadata').', '. - &mt('FAIL').'
'.&mt('Wrote Metadata'). - ' '.&Apache::lonlocal::locallocaltime(time). - '
'. + &mt('Could not write metadata').', '. + &mt('FAIL').'
'.&mt('Wrote Metadata'). ' '.&Apache::lonlocal::locallocaltime(time). '
'.&mt('Wrote Metadata'). + ' '.&Apache::lonlocal::locallocaltime(time). + '