[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 15 Apr 2004 18:06:29 -0000
matthew Thu Apr 15 14:06:29 2004 EDT
Modified files:
/loncom/interface lonmeta.pm
Log:
Neater prettyprint output for resources and less whitespace in the
output from &print_dynamic_metadata.
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.71 loncom/interface/lonmeta.pm:1.72
--- loncom/interface/lonmeta.pm:1.71 Wed Apr 14 17:22:44 2004
+++ loncom/interface/lonmeta.pm Thu Apr 15 14:06:29 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.71 2004/04/14 21:22:44 matthew Exp $
+# $Id: lonmeta.pm,v 1.72 2004/04/15 18:06:29 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -253,7 +253,22 @@
($type eq 'sequsage_list')) {
return join('<br />',map {
my $url = &Apache::lonnet::clutter($_);
- $_ = '<b>'.&Apache::lonnet::gettitle($url).'</b> '.
+ my $title = &Apache::lonnet::gettitle($url);
+ if ($title eq '') {
+ $title = 'Untitled';
+ if ($url =~ /\.sequence$/) {
+ $title .= ' Sequence';
+ } elsif ($url =~ /\.page$/) {
+ $title .= ' Page';
+ } elsif ($url =~ /\.problem$/) {
+ $title .= ' Problem';
+ } elsif ($url =~ /\.html$/) {
+ $title .= ' HTML document';
+ } elsif ($url =~ m:/syllabus$:) {
+ $title .= ' Syllabus';
+ }
+ }
+ $_ = '<b>'.$title.'</b> '.
'<a href="'.$url.'" target="preview">'.
'<font size="-1">'.$url.'</font>'.
'</a>'
@@ -273,12 +288,19 @@
}
# List of courses
if ($type=~/\_list/) {
- return join('<br />',map {
- my %courseinfo=&Apache::lonnet::coursedescription($_);
- '<a href="/public/'.
- $courseinfo{'domain'}.'/'.$courseinfo{'num'}.'/syllabus" target="preview">'.
- $courseinfo{'description'}.'</a>';
- } split(/\s*\,\s*/,$value));
+ my @Courses = split(/\s*\,\s*/,$value);
+ my $Str;
+ foreach my $course (@Courses) {
+ my %courseinfo = &Apache::lonnet::coursedescription($course);
+ if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
+ next;
+ }
+ if ($Str ne '') { $Str .= '<br />'; }
+ $Str .= '<a href="/public/'.$courseinfo{'domain'}.'/'.
+ $courseinfo{'num'}.'/syllabus" target="preview">'.
+ $courseinfo{'description'}.'</a>';
+ }
+ return $Str;
}
# No pretty print found
return $value;
@@ -496,8 +518,9 @@
} else {
$versiondisplay='Version: '.$currentversion;
}
- # crumbify displayed URL
- $disuri=&Apache::lonhtmlcommon::crumbs($disuri);
+ # crumbify displayed URL uri target prefix form size
+ $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');
+ $disuri =~ s:<br />::g;
# obsolete
my $obsolete=$content{'obsolete'};
my $obsoletewarning='';
@@ -509,6 +532,10 @@
#
my %lt=&fieldnames();
my $table='';
+ my $title = $content{'title'};
+ if (! defined($title)) {
+ $title = 'Untitled Resource';
+ }
foreach ('title',
'author',
'subject',
@@ -534,10 +561,12 @@
}
#
$r->print(<<ENDHEAD);
-<h2>$content{'title'}</h2>
-<h3><tt>$disuri</tt></h3>
+<h2>$title</h2>
+<p>
+$disuri<br />
$obsoletewarning
-$versiondisplay<br />
+$versiondisplay
+</p>
<table cellspacing=2 border=0>
$table
</table>
@@ -589,13 +618,13 @@
exists($dynmeta{'avetries'}) ||
exists($dynmeta{'difficulty'}))) {
# This is an assessment, print assessment data
- $r->print(
- '<h4>'.&mt('Assessment Statistical Data').'</h4>'.
+ $r->print('<h4>'.&mt('Assessment Statistical Data').'</h4>'.
'<table cellspacing=2 border=0>');
foreach ('stdno','avetries','difficulty') {
$r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
'<td bgcolor="#CCCCCC">'.
- &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
+ &prettyprint($_,sprintf('%5.2f',$dynmeta{$_})).'</td>'.
+ "</tr>\n");
}
$r->print('</table>');
} else {