--- loncom/interface/lonmeta.pm	2004/04/14 18:30:36	1.68
+++ loncom/interface/lonmeta.pm	2004/04/14 21:22:44	1.71
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.68 2004/04/14 18:30:36 matthew Exp $
+# $Id: lonmeta.pm,v 1.71 2004/04/14 21:22:44 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -114,21 +114,21 @@ sub evalgraph {
         return '';
     }
     my $val=int($value*10.+0.5)-10;
-    my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
+    my $output='<table border="0" cellpadding="0" cellspacing="0"><tr>';
     if ($val>=20) {
-	$output.='<td width=20 bgcolor="#555555">&nbsp&nbsp;</td>';
+	$output.='<td width="20" bgcolor="#555555">&nbsp&nbsp;</td>';
     } else {
-        $output.='<td width='.($val).' bgcolor="#555555">&nbsp;</td>'.
-                 '<td width='.(20-$val).' bgcolor="#FF3333">&nbsp;</td>';
+        $output.='<td width="'.($val).'" bgcolor="#555555">&nbsp;</td>'.
+                 '<td width="'.(20-$val).'" bgcolor="#FF3333">&nbsp;</td>';
     }
     $output.='<td bgcolor="#FFFF33">&nbsp;</td>';
     if ($val>20) {
-	$output.='<td width='.($val-20).' bgcolor="#33FF33">&nbsp;</td>'.
-                 '<td width='.(40-$val).' bgcolor="#555555">&nbsp;</td>';
+	$output.='<td width="'.($val-20).'" bgcolor="#33FF33">&nbsp;</td>'.
+                 '<td width="'.(40-$val).'" bgcolor="#555555">&nbsp;</td>';
     } else {
-        $output.='<td width=20 bgcolor="#555555">&nbsp&nbsp;</td>';
+        $output.='<td width="20" bgcolor="#555555">&nbsp&nbsp;</td>';
     }
-    $output.='<td> ('.$value.') </td></tr></table>';
+    $output.='<td> ('.sprintf("%5.2f",$value).') </td></tr></table>';
     return $output;
 }
 
@@ -140,15 +140,15 @@ sub diffgraph {
     my $val=int(40.0*$value+0.5);
     my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
                 '#BBDD33','#CCCC33','#DDBB33','#EEAA33');
-    my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
+    my $output='<table border="0" cellpadding="0" cellspacing="0"><tr>';
     for (my $i=0;$i<8;$i++) {
 	if ($val>$i*5) {
-            $output.='<td width=5 bgcolor="'.$colors[$i].'">&nbsp;</td>';
+            $output.='<td width="5" bgcolor="'.$colors[$i].'">&nbsp;</td>';
         } else {
-	    $output.='<td width=5 bgcolor="#555555">&nbsp;</td>';
+	    $output.='<td width="5" bgcolor="#555555">&nbsp;</td>';
 	}
     }
-    $output.='<td> ('.$value.') </td></tr></table>';
+    $output.='<td> ('.sprintf("%3.2f",$value).') </td></tr></table>';
     return $output;
 }
 
@@ -252,9 +252,11 @@ sub prettyprint {
 	($type eq 'comefrom_list') ||
 	($type eq 'sequsage_list')) {
 	return join('<br />',map {
-            my $url=&Apache::lonnet::clutter($_);
-            '<b>'.&Apache::lonnet::gettitle($url).'</b>'.
-                &Apache::lonhtmlcommon::crumbs($url,'preview','',undef,'+0');
+            my $url = &Apache::lonnet::clutter($_);
+            $_ = '<b>'.&Apache::lonnet::gettitle($url).'</b> '.
+                '<a href="'.$url.'" target="preview">'.
+                '<font size="-1">'.$url.'</font>'.
+                '</a>'
         } split(/\s*\,\s*/,$value));
     }
     # Evaluations
@@ -450,10 +452,10 @@ sub report_bombs {
             &Apache::lonmsg::all_url_author_res_msg($author,$domain);
         foreach (sort(keys(%brokenurls))) {
             if ($_=~/^\Q$uri\E/) {
-                $r->print(&Apache::lonhtmlcommon::crumbs
-                          (&Apache::lonnet::clutter($_)).
-                          &Apache::lonmsg::retrieve_author_res_msg($_).
-                          '<hr />');
+                $r->print
+                    ('<a href="'.&Apache::lonnet::clutter($_).'">'.$_.'</a>'.
+                     &Apache::lonmsg::retrieve_author_res_msg($_).
+                     '<hr />');
             }
         }
     } else {
@@ -549,30 +551,43 @@ ENDHEAD
 sub print_dynamic_metadata {
     my ($r,$uri,$content) = @_;
     #
-    my %content = \$content;
+    my %content = %$content;
     my %lt=&fieldnames();
     #
     my $description = 'Dynamic Metadata (updated periodically)';
     $r->print('<h3>'.&mt($description).'</h3>'.
-              &mt('Processing').' ...<br />');
+              &mt('Processing'));
     $r->rflush();
     my %items=&fieldnames();
     my %dynmeta=&dynamicmeta($uri);
     #
     # General Access and Usage Statistics
-    $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.
-              '<table cellspacing=2 border=0>');
-    foreach ('count',
-             'sequsage','sequsage_list',
-             'comefrom','comefrom_list',
-             'goto','goto_list',
-             'course','course_list') {
-        $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
-                  '<td bgcolor="#CCCCCC">'.
-                  &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
+    if (exists($dynmeta{'count'}) ||
+        exists($dynmeta{'sequsage'}) ||
+        exists($dynmeta{'comefrom'}) ||
+        exists($dynmeta{'goto'}) ||
+        exists($dynmeta{'course'})) {
+        $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.
+                  '<table cellspacing=2 border=0>');
+        foreach ('count',
+                 'sequsage','sequsage_list',
+                 'comefrom','comefrom_list',
+                 'goto','goto_list',
+                 'course','course_list') {
+            $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
+                      '<td bgcolor="#CCCCCC">'.
+                      &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
+        }
+        $r->print('</table>');
+    } else {
+        $r->print('<h4>'.&mt('No Access or Usages Statistics are available for this resource.').'</h4>');
     }
-    $r->print('</table>');
-    if ($uri=~/\.(problem|exam|quiz|assess|survey|form)$/) {
+    #
+    # Assessment statistics
+    if ($uri=~/\.(problem|exam|quiz|assess|survey|form)$/ &&
+        (exists($dynmeta{'stdno'}) ||
+         exists($dynmeta{'avetries'}) ||
+         exists($dynmeta{'difficulty'}))) {
         # This is an assessment, print assessment data
         $r->print(
                   '<h4>'.&mt('Assessment Statistical Data').'</h4>'.
@@ -583,28 +598,46 @@ sub print_dynamic_metadata {
                       &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
         }
         $r->print('</table>');    
+    } else {
+        $r->print('<h4>'.&mt('No Assessment Statistical Data is available for this resource').'</h4>');
     }
-    
-    $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.
-              '<table cellspacing=2 border=0>');
-    foreach ('clear','depth','helpful','correct','technical') {
-        $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
-                  '<td bgcolor="#CCCCCC">'.
-                  &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
+    if (exists($dynmeta{'clear'})   || 
+        exists($dynmeta{'depth'})   || 
+        exists($dynmeta{'helpful'}) || 
+        exists($dynmeta{'correct'}) || 
+        exists($dynmeta{'technical'})){ 
+        $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.
+                  '<table cellspacing=2 border=0>');
+        foreach ('clear','depth','helpful','correct','technical') {
+            $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
+                      '<td bgcolor="#CCCCCC">'.
+                      &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
+        }
+        $r->print('</table>');
+    } else {
+        $r->print('<h4>'.&mt('No Evaluation Data is available for this resource.').'</h4>');
     }
-    $r->print('</table>');
     $uri=~/^\/res\/(\w+)\/(\w+)\//; 
     if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
         || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
-        $r->print('<h4>'.&mt('Evaluation Comments').' ('.
-                  &mt('visible to author and co-authors only').
-                  ')</h4>'.
-                  '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
-        $r->print('<a name="bombs" /><h4>'.&mt('Error Messages').' ('.
-                  &mt('visible to author and co-authors only').')'.
-                  '</h4>'.
-                  &Apache::lonmsg::retrieve_author_res_msg($uri));
+        if (exists($dynmeta{'comments'})) {
+            $r->print('<h4>'.&mt('Evaluation Comments').' ('.
+                      &mt('visible to author and co-authors only').
+                      ')</h4>'.
+                      '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
+        } else {
+            $r->print('<h4>'.&mt('There are no Evaluation Comments on this resource.').'</h4>');
+        }
+        my $bombs = &Apache::lonmsg::retrieve_author_res_msg($uri);
+        if (defined($bombs) && $bombs ne '') {
+            $r->print('<a name="bombs" /><h4>'.&mt('Error Messages').' ('.
+                      &mt('visible to author and co-authors only').')'.
+                      '</h4>'.$bombs);
+        } else {
+            $r->print('<h4>'.&mt('There are currently no Error Messages for this resource.').'</h4>');
+        }
     }
+    #
     # All other stuff
     $r->print('<h3>'.
               &mt('Additional Metadata (non-standard, parameters, exports)').