--- loncom/interface/lonmeta.pm 2007/03/12 19:10:48 1.204
+++ loncom/interface/lonmeta.pm 2009/03/21 21:37:13 1.227
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.204 2007/03/12 19:10:48 banghart Exp $
+# $Id: lonmeta.pm,v 1.227 2009/03/21 21:37:13 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,24 +42,6 @@ use Apache::lonmsg;
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/($match_domain)/($match_username)/});
@@ -182,7 +164,7 @@ sub evalgraph {
my $val=int($value*10.+0.5)-10;
my $output='
';
if ($val>=20) {
- $output.='
 
';
+ $output.='
'.(' ' x2).'
';
} else {
$output.='
'.
'
';
@@ -192,7 +174,7 @@ sub evalgraph {
$output.='
'.
'
';
} else {
- $output.='
 
';
+ $output.='
'.(' ' x2).'
';
}
$output.='
('.sprintf("%5.2f",$value).')
';
return $output;
@@ -265,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',
@@ -356,7 +338,7 @@ sub pre_select_course {
&Apache::lonpublisher::metaeval($result);
}
$r->print('
+$cancel
+
ENDCLEAR
my %brokenurls =
&Apache::lonmsg::all_url_author_res_msg($author,$domain);
- foreach (sort(keys(%brokenurls))) {
- if ($_=~/^\Q$uri\E/) {
+ foreach my $key (sort(keys(%brokenurls))) {
+ if ($key=~/^\Q$uri\E/) {
$r->print
- (''.$_.''.
- &Apache::lonmsg::retrieve_author_res_msg($_).
+ (''.$key.''.
+ &Apache::lonmsg::retrieve_author_res_msg($key).
'');
}
}
@@ -873,8 +860,8 @@ sub present_uneditable_metadata {
my $uploaded = ($uri =~ m|/uploaded/|);
my %content=();
# Read file
- foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
- $content{$_}=&Apache::lonnet::metadata($uri,$_);
+ foreach my $key (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
+ $content{$key}=&Apache::lonnet::metadata($uri,$key);
}
# Render Output
# displayed url
@@ -902,9 +889,9 @@ sub present_uneditable_metadata {
my $obsolete=$content{'obsolete'};
my $obsoletewarning='';
if (($obsolete) && ($env{'user.adv'})) {
- $obsoletewarning='
'.
+ $obsoletewarning='
'.
&mt('This resource has been marked obsolete by the author(s)').
- '
';
+ '';
}
#
my %lt=&fieldnames();
@@ -940,24 +927,27 @@ sub present_uneditable_metadata {
'obsolete',
'obsoletereplacement');
}
+ my $rownum = 0;
foreach my $field (@fields) {
- $table.='
');
}
}
$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=();
@@ -1312,6 +1327,11 @@ 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') {
if ($file_type eq 'portfolio') {
@@ -1327,7 +1347,7 @@ ENDEDIT
".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) {
@@ -1385,8 +1405,8 @@ ENDEDIT
my ($outcome,$result) = &store_metadata($fn,$uri,'store');
$r->print($result);
}
- $r->print($output.' ');
+ $r->print($output.' ');
if ($file_type eq 'portfolio' || $file_type eq 'groups') {
my ($port_path,$group) = &get_port_path_and_group($uri);
@@ -1447,26 +1467,26 @@ sub store_metadata {
$output .= $result;
} else {
if (! ($mfh=Apache::File->new('>'.$fn))) {
- $output .= '
';
+ $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').'
';
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';
}
}
@@ -1494,25 +1514,25 @@ sub store_portfolio_metadata {
$env{'form.'.$formname.'.filename'}=$new_fn;
my $result =&Apache::lonnet::userfileupload($formname,'',$path);
if ($result =~ /(error|notfound)/) {
- $output = '
';
+ $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').'