--- loncom/interface/lonmeta.pm 2005/10/14 04:24:12 1.111
+++ loncom/interface/lonmeta.pm 2006/09/25 19:24:49 1.178
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.111 2005/10/14 04:24:12 banghart Exp $
+# $Id: lonmeta.pm,v 1.178 2006/09/25 19:24:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,6 +39,8 @@ use Apache::lonpublisher;
use Apache::lonlocal;
use Apache::lonmysql;
use Apache::lonmsg;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
############################################################
@@ -71,20 +73,7 @@ sub get_dynamic_metadata_from_sql {
if (! defined($authordom) || ! defined($author)) {
return ();
}
- my @Fields = ('url','count','course',
- 'goto','goto_list',
- 'comefrom','comefrom_list',
- 'sequsage','sequsage_list',
- 'stdno','stdno_list',
- 'dependencies',
- 'avetries','avetries_list',
- 'difficulty','difficulty_list',
- 'disc','disc_list',
- 'clear','technical','correct',
- 'helpful','depth');
- #
- my $query = 'SELECT '.join(',',@Fields).
- ' FROM metadata WHERE url LIKE "'.$url.'%"';
+ my $query = 'SELECT * FROM metadata WHERE url LIKE "'.$url.'%"';
my $server = &Apache::lonnet::homeserver($author,$authordom);
my $reply = &Apache::lonnet::metadata_query($query,undef,undef,
,[$server]);
@@ -106,13 +95,9 @@ sub get_dynamic_metadata_from_sql {
while (my $result = <$fh>) {
chomp($result);
next if (! $result);
- my @Data =
- map {
- &Apache::lonnet::unescape($_);
- } split(',',$result);
- my $url = $Data[0];
- for (my $i=0;$i<=$#Fields;$i++) {
- $ReturnHash{$url}->{$Fields[$i]}=$Data[$i];
+ my %hash=&LONCAPA::lonmetadata::metadata_col_to_hash(map { &unescape($_) } split(/\,/,$result));
+ foreach my $key (keys(%hash)) {
+ $ReturnHash{$hash{'url'}}->{$key}=$hash{$key};
}
}
$finished = 1;
@@ -185,7 +170,7 @@ sub authordisplay {
my ($aname,$adom)=@_;
return &Apache::loncommon::aboutmewrapper
(&Apache::loncommon::plainname($aname,$adom),
- $aname,$adom,'preview').' ['.$aname.'@'.$adom.']';
+ $aname,$adom,'preview').' ['.$aname.':'.$adom.']';
}
# Pretty display
@@ -243,16 +228,17 @@ sub fieldnames {
'authorspace' => 'Author Space',
'modifyinguser' => 'Last Modifying User',
'subject' => 'Subject',
+ 'standards' => 'Standards',
'keywords' => 'Keyword(s)',
'notes' => 'Notes',
'abstract' => 'Abstract',
'lowestgradelevel' => 'Lowest Grade Level',
'highestgradelevel' => 'Highest Grade Level');
+
if (! defined($file_type) || $file_type ne 'portfolio') {
%fields =
(%fields,
'domain' => 'Domain',
- 'standards' => 'Standards',
'mime' => 'MIME Type',
'language' => 'Language',
'creationdate' => 'Creation Date',
@@ -282,55 +268,144 @@ 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;
- foreach my $key (keys (%env)) {
-
- if ($key =~ m/^(course\..+)\.metadata\..+\.options/) {
- my $course_key = $1;
- $course_key .= '.description';
- $r->print($env{$course_key}.' of '.$course_key.'
');
- push @courses, $key;
- }
- }
- foreach (@courses) {
- $r->print($_.' was found
');
- }
- $r->print('