--- loncom/interface/lonmeta.pm 2006/11/20 19:39:22 1.188 +++ loncom/interface/lonmeta.pm 2008/11/20 15:19:39 1.216 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.188 2006/11/20 19:39:22 banghart Exp $ +# $Id: lonmeta.pm,v 1.216 2008/11/20 15:19:39 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,31 +39,12 @@ use Apache::lonpublisher; use Apache::lonlocal; use Apache::lonmysql; use Apache::lonmsg; -use lib '/home/httpd/lib/perl/'; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); -############################################################ -############################################################ -## -## &get_dynamic_metadata_from_sql($url) -## -## Queries sql database for dynamic metdata -## Returns a hash of hashes, with keys of urls which match $url -## Returned fields are given below. -## -## Examples: -## -## %DynamicMetadata = &Apache::lonmeta::get_dynmaic_metadata_from_sql -## ('/res/msu/korte/'); -## -## $DynamicMetadata{'/res/msu/korte/example.problem'}->{$field} -## -############################################################ -############################################################ sub get_dynamic_metadata_from_sql { my ($url) = shift(); - my ($authordom,$author)=($url=~m:^/res/(\w+)/(\w+)/:); + my ($authordom,$author)=($url=~m{^/res/($match_domain)/($match_username)/}); if (! defined($authordom)) { $authordom = shift(); } @@ -112,7 +93,7 @@ sub get_dynamic_metadata_from_sql { sub dynamicmeta { my $url=&Apache::lonnet::declutter(shift); $url=~s/\.meta$//; - my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//); + my ($adomain,$aauthor)=($url=~/^($match_domain)\/($match_username)\//); my $regexp=$url; $regexp=~s/(\W)/\\$1/g; $regexp='___'.$regexp.'___'; @@ -236,7 +217,7 @@ sub fieldnames { 'lowestgradelevel' => 'Lowest Grade Level', 'highestgradelevel' => 'Highest Grade Level'); - if (! defined($file_type) || $file_type ne 'portfolio') { + if ( !defined($file_type) || ($file_type ne 'portfolio' && $file_type ne 'groups') ) { %fields = (%fields, 'domain' => 'Domain', @@ -266,7 +247,7 @@ sub fieldnames { 'correct' => 'Material appears to be correct', 'technical' => 'Resource is technically correct', 'avetries' => 'Average number of tries till solved', - 'stdno' => 'Total number of students who have worked on this problem', + 'stdno' => 'Statistics calculated for number of students', 'difficulty' => 'Degree of difficulty', 'disc' => 'Degree of discrimination', 'dependencies' => 'Resources used by this resource', @@ -384,7 +365,40 @@ sub select_course { $Apache::lonpublisher::metadatafields{'courserestricted'}; my $selected = ($current_restriction eq 'none' ? 'selected="selected"' : ''); - + if ($current_restriction =~ /^course\.($match_domain\_$match_courseid)$/) { + my $assoc_crs = $1; + my $added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames($assoc_crs); + if (ref($added_metadata_fields) eq 'HASH') { + if (keys(%{$added_metadata_fields}) > 0) { + my $transfernotes; + foreach my $field_name (keys(%{$added_metadata_fields})) { + my $value = $Apache::lonpublisher::metadatafields{$field_name}; + if ($value) { + $transfernotes .= + &Apache::loncommon::start_data_table_row(). + ''. + $field_name.''.$value.''. + &Apache::loncommon::end_data_table_row(); + } + } + if ($transfernotes ne '') { + my %courseinfo = &Apache::lonnet::coursedescription($assoc_crs,{'one_time' => 1}); + my $assoc_crs_description = $courseinfo{'description'}; + $output .= &mt('This resource is currently associated with a course ([_1]) which includes added metadata fields specific to the course.',$assoc_crs_description).'
'."\n". + &mt('You can choose to transfer data from the added fields to the "Notes" field if you are planning to change the course association.').'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + 'Copy to notes?'."\n". + 'Field name'."\n". + 'Values'."\n". + &Apache::loncommon::end_data_table_header_row(). + $transfernotes. + &Apache::loncommon::end_data_table().'
'; + } + } + } + } $output .= ''); } - my $course = $env{'request.course.id'}; if (($type eq 'keywords') || ($type eq 'subject') || ($type eq 'author')||($type eq 'notes') || ($type eq 'abstract')|| ($type eq 'title')|| ($type eq 'standards') - || (exists($env{'course.'.$env{'request.course.id'}.'.metadata.'.$type.'.added'}))) { + || (exists($env{$course_key.'.metadata.'.$type.'.added'}))) { + if ($values) { if ($only_one) { $output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options)); @@ -732,14 +753,14 @@ sub handler { $r->send_http_header; return OK if $r->header_only; my ($resdomain,$resuser)= - (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//); + (&Apache::lonnet::declutter($uri)=~/^($match_domain)\/($match_username)\//); if ($uri=~m:/adm/bombs/(.*)$:) { $r->print(&Apache::loncommon::start_page('Error Messages')); # Looking for all bombs? &report_bombs($r,$uri); } elsif ($uri=~m|^/editupload/[^/]+/[^/]+/portfolio/|) { ($resdomain,$resuser)= - (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); + (&Apache::lonnet::declutter($uri)=~m|^($match_domain)/($match_name)/portfolio|); $r->print(&Apache::loncommon::start_page('Edit Portfolio File Catalog Information', undef, {'domain' => $resdomain,})); @@ -751,7 +772,6 @@ sub handler { %Apache::lonpublisher::metadatakeys=(); my $result=&Apache::lonnet::getfile($fn); &Apache::lonpublisher::metaeval($result); - &Apache::lonnet::logthis("restricted is: ".$Apache::lonpublisher::metadatafields{'courserestricted'}); if ((!$Apache::lonpublisher::metadatafields{'courserestricted'}) || ($env{'form.changecourse'} eq 'true')) { &pre_select_course($r,$uri); @@ -766,12 +786,14 @@ sub handler { &present_editable_metadata($r,$uri,'groups'); } elsif ($uri=~m|^/~|) { # Construction space - $r->print(&Apache::loncommon::start_page('Edit Catalog nformation', - undef, + $r->print(&Apache::loncommon::start_page('Edit Catalog Information', + "\n".'', {'domain' => $resdomain,})); &present_editable_metadata($r,$uri); } else { - $r->print(&Apache::loncommon::start_page('Catalog Information', + $r->print(&Apache::loncommon::start_page('Metadata', undef, {'domain' => $resdomain,})); &present_uneditable_metadata($r,$uri); @@ -793,16 +815,20 @@ sub report_bombs { $uri =~ s:/adm/bombs/::; $uri = &Apache::lonnet::declutter($uri); $r->print('

'.&Apache::lonnet::clutter($uri).'

'); - my ($domain,$author)=($uri=~/^(\w+)\/(\w+)\//); + my ($domain,$author)=($uri=~/^($match_domain)\/($match_username)\//); if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) { if ($env{'form.clearbombs'}) { &Apache::lonmsg::clear_author_res_msg($uri); } my $clear=&mt('Clear all Messages in Subdirectory'); - $r->print(<print(< - +$cancel +
ENDCLEAR my %brokenurls = &Apache::lonmsg::all_url_author_res_msg($author,$domain); @@ -986,17 +1012,17 @@ sub print_dynamic_metadata { # # New assessment statistics $r->print('

'. - &mt('Detailed Assessment Statistical Data'). + &mt('Recent Detailed Assessment Statistical Data'). '

'); my $table = ''. ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. ''.$/; foreach my $identifier (sort(keys(%{$dynmeta{'stats'}}))) { my $data = $dynmeta{'stats'}->{$identifier}; @@ -1034,7 +1060,7 @@ sub print_dynamic_metadata { $table .= '
CourseSection(s)Num StudentsMean TriesDegree of DifficultyDegree of DiscriminationTime of computation'.&mt('Course').''.&mt('Section(s)').''.&mt('Num Student').'s'.&mt('Mean Tries').''.&mt('Degree of Difficulty').''.&mt('Degree of Discrimination').''.&mt('Time of computation').'
'.$/; $r->print($table); } else { - $r->print('No new dynamic data found.'); + $r->print(&mt('No new dynamic data found.')); } } else { $r->print('

'. @@ -1060,7 +1086,7 @@ sub print_dynamic_metadata { } else { $r->print('

'.&mt('No Evaluation Data is available for this resource.').'

'); } - $uri=~/^\/res\/(\w+)\/(\w+)\//; + $uri=~/^\/res\/($match_domain)\/($match_username)\//; if ((($env{'user.domain'} eq $1) && ($env{'user.name'} eq $2)) || ($env{'user.role.ca./'.$1.'/'.$2})) { if (exists($dynmeta{'comments'})) { @@ -1172,17 +1198,20 @@ ENDBOMBS ENDDEL } else { - $r->print(''.$goback.''); + $r->print('

'.$goback.'

'); + if ($env{'form.clearmsg'}) { + my ($diruri) = ($disuri =~ m{(.*/)[^/]*}); + $r->print('

'. + &mt('Back To Directory').'

'); + } } $r->print('
'.$bombs); } else { - my $displayfile='Catalog Information for '.$disuri; + my $displayfile=&mt('Metadata for [_1]',$disuri); if ($disuri=~/\/default$/) { my $dir=$disuri; $dir=~s/default$//; - $displayfile= - &mt('Default Cataloging Information for Directory').' '. - $dir; + $displayfile=&mt('Default Metadata for Directory [_1]',$dir); } %Apache::lonpublisher::metadatafields=(); %Apache::lonpublisher::metadatakeys=(); @@ -1192,18 +1221,43 @@ ENDDEL } else { &Apache::lonpublisher::metaeval($result); } + if ($env{'form.new_courserestricted'}) { + my $new_assoc_course = $env{'form.new_courserestricted'}; + my $prev_courserestricted = $Apache::lonpublisher::metadatafields{'courserestricted'}; + if (($prev_courserestricted) && + ($prev_courserestricted ne $new_assoc_course)) { + my $transfers = []; + foreach my $key (keys(%env)) { + if ($key =~ /^form\.transfer_(.+)$/) { + push(@{$transfers},$1); + } + } + if (@{$transfers} > 0) { + &store_transferred_addedfields($fn,$uri,$transfers); + } + } + } $r->print(<$displayfile
ENDEDIT - $r->print(''); my %lt=&fieldnames($file_type); my $output; my @fields; my $added_metadata_fields; my @added_order; + if ($file_type eq 'groups') { + $Apache::lonpublisher::metadatafields{'courserestricted'}= + 'course.'.$env{'request.course.id'}; + } + if ((! $Apache::lonpublisher::metadatafields{'courserestricted'}) && + (! $env{'form.new_courserestricted'}) && (! $file_type eq 'groups')) { + $Apache::lonpublisher::metadatafields{'courserestricted'}= + 'none'; + } elsif ($env{'form.new_courserestricted'}) { + $Apache::lonpublisher::metadatafields{'courserestricted'}= + $env{'form.new_courserestricted'}; + } if ($file_type eq 'portfolio' || $file_type eq 'groups') { if(exists ($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'})) { # retrieve fieldnames (in order) from the course restricted list @@ -1213,11 +1267,14 @@ ENDEDIT @fields = ('author','title','subject','keywords','abstract', 'notes','lowestgradelevel', 'highestgradelevel','standards'); - $added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames(); - if ($env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}) { - @added_order = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}); - } - $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join(",",@fields); + if ($Apache::lonpublisher::metadatafields{'courserestricted'} =~ /^course\.($match_domain\_$match_courseid)$/) { + my $assoc_crs = $1; + $added_metadata_fields = &Apache::lonparmset::get_added_meta_fieldnames($assoc_crs); + if ($env{'course.'.$assoc_crs.'.metadata.addedorder'}) { + @added_order = split(/,/,$env{'course.'.$assoc_crs.'.metadata.addedorder'}); + } + $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'} = join(",",@fields); + } } } else { @fields = ('author','title','subject','keywords','abstract','notes', @@ -1226,18 +1283,6 @@ ENDEDIT 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', 'obsolete','obsoletereplacement'); } - if ($file_type eq 'groups') { - $Apache::lonpublisher::metadatafields{'courserestricted'}= - 'course.'.$env{'request.course.id'}; - } - if ((! $Apache::lonpublisher::metadatafields{'courserestricted'}) && - (! $env{'form.new_courserestricted'}) && (! $file_type eq 'groups')) { - $Apache::lonpublisher::metadatafields{'courserestricted'}= - 'none'; - } elsif ($env{'form.new_courserestricted'}) { - $Apache::lonpublisher::metadatafields{'courserestricted'}= - $env{'form.new_courserestricted'}; - } if (! $Apache::lonpublisher::metadatafields{'copyright'}) { $Apache::lonpublisher::metadatafields{'copyright'}= 'default'; @@ -1251,15 +1296,27 @@ ENDEDIT $Apache::lonpublisher::metadatafields{'owner'} = $env{'user.name'}.':'.$env{'user.domain'}; } - + if (! $Apache::lonpublisher::metadatafields{'author'}) { + $Apache::lonpublisher::metadatafields{'author'} = + &Apache::loncommon::plainname($env{'user.name'}, + $env{'user.domain'}); + } if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') { - $r->print(&mt('Associated with course [_1]', + + if ($file_type eq 'portfolio') { + $r->print(&mt('Associated with course [_1]', ''. $env{$Apache::lonpublisher::metadatafields{'courserestricted'}. ".description"}. '').'
'); + } else { + $r->print(&mt('Associated with course [_1]', + ''. + $env{$Apache::lonpublisher::metadatafields{'courserestricted'}. + ".description"}.'').'
'); + } } else { - $r->print('This resource is not associated with a course.
'); + $r->print(''.&mt('This resource is not associated with a course.').'
'); } } if (@added_order) { @@ -1273,14 +1330,19 @@ ENDEDIT $lt{$field_name} = $$added_metadata_fields{$field_name}; } } - $output.=''; + $output .= &Apache::loncommon::start_data_table(); my $row_alt = 1; foreach my $field_name (@fields) { - # $row_alt = ($row_alt) ? 0 : 1; - my $row_class = ($row_alt) ? ' class="LC_metadata_light" ' : ' class="LC_metadata_dark" '; if (defined($env{'form.new_'.$field_name})) { - $Apache::lonpublisher::metadatafields{$field_name}= - join(',',&Apache::loncommon::get_env_multiple('form.new_'.$field_name)); + my @values = &Apache::loncommon::get_env_multiple('form.new_'.$field_name); + my $newvalue = ''; + foreach my $item (@values) { + if ($item ne '') { + $newvalue .= $item.','; + } + } + $newvalue =~ s/,$//; + $Apache::lonpublisher::metadatafields{$field_name}=$newvalue; } if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none' && exists($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'})) { @@ -1289,87 +1351,42 @@ ENDEDIT ($field_name eq 'courserestricted'))&& (!($env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/))){ - $output.=("\n".''."\n"); + $Apache::lonpublisher::metadatafields{'courserestricted'}).''); + $output .= &Apache::loncommon::end_data_table_row(); } } else { - $output.=(''); + 'new_'.$field_name,'defaultmeta').''.&Apache::loncommon::end_data_table_row()); } } - $output.='
'. + $output .= "\n".&Apache::loncommon::start_data_table_row(); + $output .= (' '. &prettyinput($field_name, $Apache::lonpublisher::metadatafields{$field_name}, 'new_'.$field_name,'defaultmeta', undef,undef,undef,undef, - $Apache::lonpublisher::metadatafields{'courserestricted'}).'
'. + $output.=(&Apache::loncommon::start_data_table_row().' '. &prettyinput($field_name, $Apache::lonpublisher::metadatafields{$field_name}, - 'new_'.$field_name,'defaultmeta').'
'; + $output .= &Apache::loncommon::end_data_table(); if ($env{'form.store'}) { - my $mfh; - my $formname='store'; - my $file_content; - if (&Apache::loncommon::get_env_multiple('form.new_keywords')) { - $Apache::lonpublisher::metadatafields{'keywords'} = - join (',', &Apache::loncommon::get_env_multiple('form.new_keywords')); - } - foreach my $field (sort(keys(%Apache::lonpublisher::metadatafields))) { - next if ($field =~ /\./); - my $unikey=$field; - $unikey=~/^([A-Za-z_]+)/; - my $tag=$1; - $tag=~tr/A-Z/a-z/; - $file_content.= "\n\<$tag"; - foreach my $key (split(/\,/, - $Apache::lonpublisher::metadatakeys{$unikey}) - ) { - my $value= - $Apache::lonpublisher::metadatafields{$unikey.'.'.$key}; - $value=~s/\"/\'\'/g; - $file_content.=' '.$key.'="'.$value.'"' ; - } - $file_content.= '>'. - &HTML::Entities::encode - ($Apache::lonpublisher::metadatafields{$unikey}, - '<>&"'). - ''; - } - if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles|) { - my ($path, $new_fn); - if ($fn =~ m|\w+/groups/\w+/portfolio/|) { - ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); - } else { - ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); - } - $r->print(&store_portfolio_metadata($formname,$file_content,$path, - $new_fn)); - } else { - if (! ($mfh=Apache::File->new('>'.$fn))) { - $r->print('

'. - &mt('Could not write metadata').', '. - &mt('FAIL').'

'); - } else { - print $mfh ($file_content); - $r->print('

'.&mt('Wrote Metadata'). - ' '.&Apache::lonlocal::locallocaltime(time). - '

'); - } - } + my ($outcome,$result) = &store_metadata($fn,$uri,'store'); + $r->print($result); } - $r->print($output.'
'); + $r->print($output.'
'); - if ($file_type eq 'portfolio') { + if ($file_type eq 'portfolio' || $file_type eq 'groups') { my ($port_path,$group) = &get_port_path_and_group($uri); - if ($group) { + if ($group ne '') { $r->print(''); } $r->print(''); $r->print('


'); - if ($group) { + if ($group ne '') { $r->print(''); - } + } $r->print(''. ''); } @@ -1380,21 +1397,238 @@ ENDEDIT return; } +sub store_metadata { + my ($fn,$uri,$caller) = @_; + my $mfh; + my $formname='store'; + my ($file_content,$output,$outcome); + if (&Apache::loncommon::get_env_multiple('form.new_keywords')) { + $Apache::lonpublisher::metadatafields{'keywords'} = + join (',', &Apache::loncommon::get_env_multiple('form.new_keywords')); + } + foreach my $field (sort(keys(%Apache::lonpublisher::metadatafields))) { + next if ($field =~ /\./); + my $unikey=$field; + $unikey=~/^([A-Za-z_]+)/; + my $tag=$1; + $tag=~tr/A-Z/a-z/; + $file_content.= "\n\<$tag"; + foreach my $key (split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) { + my $value = $Apache::lonpublisher::metadatafields{$unikey.'.'.$key}; + $value=~s/\"/\'\'/g; + $file_content.=' '.$key.'="'.$value.'"' ; + } + $file_content.= '>'. + &HTML::Entities::encode + ($Apache::lonpublisher::metadatafields{$unikey},'<>&"'). + ''; + } + if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles|) { + my ($path, $new_fn); + if ($fn =~ m|$match_name/groups/\w+/portfolio/|) { + ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); + } else { + ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); + } + ($outcome,my $result) = + &store_portfolio_metadata($formname,$file_content, + $path,$new_fn,$uri,$caller); + $output .= $result; + } else { + if (! ($mfh=Apache::File->new('>'.$fn))) { + $output .= '

'; + if ($caller eq 'transfer') { + $output .= &mt('Could not transfer data in added fields to notes'); + } else { + $output .= &mt('Could not write metadata'); + } + $output .= ', '.&mt('FAIL').'

'; + $outcome = 'fail'; + } else { + print $mfh ($file_content); + close($mfh); + &update_metadata_table($uri); + $output .= '

'; + if ($caller eq 'transfer') { + $output .= &mt('Transferred data in added fields to notes'); + } else { + $output .= &mt('Wrote Metadata'); + } + $output .= ' '.&Apache::lonlocal::locallocaltime(time). + '

'; + $outcome = 'ok'; + } + } + return ($outcome,$output); +} + +sub store_transferred_addedfields { + my ($fn,$uri,$transfers) = @_; + foreach my $item (@{$transfers}) { + $Apache::lonpublisher::metadatafields{'notes'} .= + ' '.$item.' = '.$Apache::lonpublisher::metadatafields{$item}; + } + my ($outcome,$output) = &store_metadata($fn,$uri,'transfer'); + if ($outcome eq 'ok') { + foreach my $item (@{$transfers}) { + delete($Apache::lonpublisher::metadatafields{$item}); + } + } +} + sub store_portfolio_metadata { - my ($formname,$content,$path,$new_fn) = @_; + my ($formname,$content,$path,$new_fn,$uri,$caller) = @_; + my ($outcome,$output); $env{'form.'.$formname}=$content."\n"; $env{'form.'.$formname.'.filename'}=$new_fn; my $result =&Apache::lonnet::userfileupload($formname,'',$path); if ($result =~ /(error|notfound)/) { - return '

'. - &mt('Could not write metadata').', '. - &mt('FAIL').'

'; + $output = '

'; + if ($caller eq 'transfer') { + $output .= + &mt('Could not transfer data in added fields to notes'); + } else { + $output .= &mt('Could not write metadata'); + } + $output .= ', '.&mt('FAIL').'

'; + $outcome = 'fail'; } else { - return '

'.&mt('Wrote Metadata'). - ' '.&Apache::lonlocal::locallocaltime(time).'

'; + &update_metadata_table($uri); + $output = '

'; + if ($caller eq 'transfer') { + $output .= &mt('Transferred data in added fields to notes'); + } else { + $output .= &mt('Wrote Metadata'); + } + $output .= ' '.&Apache::lonlocal::locallocaltime(time). + '

'; + $outcome = 'ok'; + } + return ($outcome,$output); +} + +sub update_metadata_table { + my ($uri) = @_; + my ($type,$udom,$uname,$file_name,$group) = + &Apache::lonnet::parse_portfolio_url($uri); + $file_name =~ s/\.meta$//; + my $current_permissions = + &Apache::lonnet::get_portfile_permissions($udom,$uname); + my %access_controls = + &Apache::lonnet::get_access_controls($current_permissions,$group, + $file_name); + my $access_hash = $access_controls{$file_name}; + my $available = 0; + if (ref($access_hash) eq 'HASH') { + foreach my $key (keys(%{$access_hash})) { + my ($num,$scope,$end,$start) = + ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); + if ($scope eq 'public' || $scope eq 'guest') { + $available = 1; + last; + } + } + } + if ($available) { + my $result = + &Apache::lonnet::update_portfolio_table($uname,$udom, + $file_name,'portfolio_metadata',$group,'update'); } } + 1; __END__ + +=head1 NAME + +Apache::lonmeta - display meta data + +=head1 SYNOPSIS + +Handler to display meta data + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 SUBROUTINES + +=over + +=item &get_dynamic_metadata_from_sql($url) : + +Queries sql database for dynamic metdata +Returns a hash of hashes, with keys of urls which match $url +Returned fields are given below. + +Examples: + + %DynamicMetadata = &Apache::lonmeta::get_dynmaic_metadata_from_sql + ('/res/msu/korte/'); + + $DynamicMetadata{'/res/msu/korte/example.problem'}->{$field} + +=item dynamicmeta() + +Fetch and evaluate dynamic metadata + +=item access_count() + +=item alttag() + +Try to make an alt tag if there is none + +=item authordisplay() + +Author display + +=item evalgraph() + +Pretty display + +=item diffgraph() + +=item fieldnames() + +=item portfolio_linked_path() + +=item get_port_path_and_group() + +=item portfolio_display_uri() + +=item pre_select_course() + +=item select_course() + +=item prettyprint() + +Pretty printing of metadata field + +=item direct() + +Pretty input of metadata field + +=item selectbox() + +=item relatedfield() + +=item prettyinput() + +=item report_bombs() + +=item present_uneditable_metadata() + +=item present_editable_metadata() + +=item store_metadata() + +=item store_transferred_addedfields() + +=item store_portfolio_metadata() + +=item update_metadata_table() + +=back + +=cut