Diff for /loncom/interface/lonmeta.pm between versions 1.67 and 1.71

version 1.67, 2004/04/14 16:14:29 version 1.71, 2004/04/14 21:22:44
Line 114  sub evalgraph { Line 114  sub evalgraph {
         return '';          return '';
     }      }
     my $val=int($value*10.+0.5)-10;      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) {      if ($val>=20) {
  $output.='<td width=20 bgcolor="#555555">&nbsp&nbsp;</td>';   $output.='<td width="20" bgcolor="#555555">&nbsp&nbsp;</td>';
     } else {      } else {
         $output.='<td width='.($val).' bgcolor="#555555">&nbsp;</td>'.          $output.='<td width="'.($val).'" bgcolor="#555555">&nbsp;</td>'.
                  '<td width='.(20-$val).' bgcolor="#FF3333">&nbsp;</td>';                   '<td width="'.(20-$val).'" bgcolor="#FF3333">&nbsp;</td>';
     }      }
     $output.='<td bgcolor="#FFFF33">&nbsp;</td>';      $output.='<td bgcolor="#FFFF33">&nbsp;</td>';
     if ($val>20) {      if ($val>20) {
  $output.='<td width='.($val-20).' bgcolor="#33FF33">&nbsp;</td>'.   $output.='<td width="'.($val-20).'" bgcolor="#33FF33">&nbsp;</td>'.
                  '<td width='.(40-$val).' bgcolor="#555555">&nbsp;</td>';                   '<td width="'.(40-$val).'" bgcolor="#555555">&nbsp;</td>';
     } else {      } 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;      return $output;
 }  }
   
Line 140  sub diffgraph { Line 140  sub diffgraph {
     my $val=int(40.0*$value+0.5);      my $val=int(40.0*$value+0.5);
     my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',      my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
                 '#BBDD33','#CCCC33','#DDBB33','#EEAA33');                  '#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++) {      for (my $i=0;$i<8;$i++) {
  if ($val>$i*5) {   if ($val>$i*5) {
             $output.='<td width=5 bgcolor="'.$colors[$i].'">&nbsp;</td>';              $output.='<td width="5" bgcolor="'.$colors[$i].'">&nbsp;</td>';
         } else {          } 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;      return $output;
 }  }
   
Line 252  sub prettyprint { Line 252  sub prettyprint {
  ($type eq 'comefrom_list') ||   ($type eq 'comefrom_list') ||
  ($type eq 'sequsage_list')) {   ($type eq 'sequsage_list')) {
  return join('<br />',map {   return join('<br />',map {
             my $url=&Apache::lonnet::clutter($_);              my $url = &Apache::lonnet::clutter($_);
             '<b>'.&Apache::lonnet::gettitle($url).'</b>'.              $_ = '<b>'.&Apache::lonnet::gettitle($url).'</b> '.
                 &Apache::lonhtmlcommon::crumbs($url,'preview','',undef,'+0');                  '<a href="'.$url.'" target="preview">'.
                   '<font size="-1">'.$url.'</font>'.
                   '</a>'
         } split(/\s*\,\s*/,$value));          } split(/\s*\,\s*/,$value));
     }      }
     # Evaluations      # Evaluations
Line 450  sub report_bombs { Line 452  sub report_bombs {
             &Apache::lonmsg::all_url_author_res_msg($author,$domain);              &Apache::lonmsg::all_url_author_res_msg($author,$domain);
         foreach (sort(keys(%brokenurls))) {          foreach (sort(keys(%brokenurls))) {
             if ($_=~/^\Q$uri\E/) {              if ($_=~/^\Q$uri\E/) {
                 $r->print(&Apache::lonhtmlcommon::crumbs                  $r->print
                           (&Apache::lonnet::clutter($_)).                      ('<a href="'.&Apache::lonnet::clutter($_).'">'.$_.'</a>'.
                           &Apache::lonmsg::retrieve_author_res_msg($_).                       &Apache::lonmsg::retrieve_author_res_msg($_).
                           '<hr />');                       '<hr />');
             }              }
         }          }
     } else {      } else {
Line 541  $table Line 543  $table
 </table>  </table>
 ENDHEAD  ENDHEAD
     if ($ENV{'user.adv'}) {      if ($ENV{'user.adv'}) {
         &print_dynamic_metadata($r,$uri);          &print_dynamic_metadata($r,$uri,\%content);
     }      }
     return;      return;
 }  }
   
 sub print_dynamic_metadata {  sub print_dynamic_metadata {
     my ($r,$uri) = @_;      my ($r,$uri,$content) = @_;
       #
       my %content = %$content;
       my %lt=&fieldnames();
     #      #
     my $description = 'Dynamic Metadata (updated periodically)';      my $description = 'Dynamic Metadata (updated periodically)';
     $r->print('<h3>'.&mt($description).'</h3>'.      $r->print('<h3>'.&mt($description).'</h3>'.
               &mt('Processing').' ...<br />');                &mt('Processing'));
     $r->rflush();      $r->rflush();
     my %items=&fieldnames();      my %items=&fieldnames();
     my %dynmeta=&dynamicmeta($uri);      my %dynmeta=&dynamicmeta($uri);
     #      #
     # General Access and Usage Statistics      # General Access and Usage Statistics
     $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.      if (exists($dynmeta{'count'}) ||
               '<table cellspacing=2 border=0>');          exists($dynmeta{'sequsage'}) ||
     foreach ('count',          exists($dynmeta{'comefrom'}) ||
              'sequsage','sequsage_list',          exists($dynmeta{'goto'}) ||
              'comefrom','comefrom_list',          exists($dynmeta{'course'})) {
              'goto','goto_list',          $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.
              'course','course_list') {                    '<table cellspacing=2 border=0>');
         $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.          foreach ('count',
                   '<td bgcolor="#CCCCCC">'.                   'sequsage','sequsage_list',
                   &prettyprint($_,$dynmeta{$_})."</td></tr>\n");                   '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          # This is an assessment, print assessment data
         $r->print(          $r->print(
                   '<h4>'.&mt('Assessment Statistical Data').'</h4>'.                    '<h4>'.&mt('Assessment Statistical Data').'</h4>'.
Line 580  sub print_dynamic_metadata { Line 598  sub print_dynamic_metadata {
                       &prettyprint($_,$dynmeta{$_})."</td></tr>\n");                        &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
         }          }
         $r->print('</table>');              $r->print('</table>');    
       } else {
           $r->print('<h4>'.&mt('No Assessment Statistical Data is available for this resource').'</h4>');
     }      }
           if (exists($dynmeta{'clear'})   || 
     $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.          exists($dynmeta{'depth'})   || 
               '<table cellspacing=2 border=0>');          exists($dynmeta{'helpful'}) || 
     foreach ('clear','depth','helpful','correct','technical') {          exists($dynmeta{'correct'}) || 
         $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.          exists($dynmeta{'technical'})){ 
                   '<td bgcolor="#CCCCCC">'.          $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.
                   &prettyprint($_,$dynmeta{$_})."</td></tr>\n");                    '<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+)\//;       $uri=~/^\/res\/(\w+)\/(\w+)\//; 
     if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))      if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
         || ($ENV{'user.role.ca./'.$1.'/'.$2})) {          || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
         $r->print('<h4>'.&mt('Evaluation Comments').' ('.          if (exists($dynmeta{'comments'})) {
                   &mt('visible to author and co-authors only').              $r->print('<h4>'.&mt('Evaluation Comments').' ('.
                   ')</h4>'.                        &mt('visible to author and co-authors only').
                   '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');                        ')</h4>'.
         $r->print('<a name="bombs" /><h4>'.&mt('Error Messages').' ('.                        '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
                   &mt('visible to author and co-authors only').')'.          } else {
                   '</h4>'.              $r->print('<h4>'.&mt('There are no Evaluation Comments on this resource.').'</h4>');
                   &Apache::lonmsg::retrieve_author_res_msg($uri));          }
           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      # All other stuff
     $r->print('<h3>'.      $r->print('<h3>'.
               &mt('Additional Metadata (non-standard, parameters, exports)').                &mt('Additional Metadata (non-standard, parameters, exports)').
Line 747  ENDEDIT Line 783  ENDEDIT
     return;      return;
 }  }
   
 ##############################################################  
 ##############################################################  
 # MySQL table columns  
   
 my @columns;  
   
 BEGIN {  
     # Get columns of MySQL metadata table  
     @columns=&Apache::lonmysql::col_order('metadata');  
 }  
   
 #  
 # Turn MySQL row into hash  
 #     This routine should be moved to lonmetadata  
 #     a more generic place since it has nothing to do with metadata  
 sub metadata_col_to_hash {  
     my @cols=@_;  
     my %hash=();  
     for (my $i=0; $i<=$#columns; $i++) {  
  $hash{$columns[$i]}=$cols[$i];  
     }  
     return %hash;  
 }  
   
   
 1;  1;
 __END__  __END__

Removed from v.1.67  
changed lines
  Added in v.1.71


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>