Diff for /loncom/interface/lonmeta.pm between versions 1.68 and 1.75

version 1.68, 2004/04/14 18:30:36 version 1.75, 2004/04/19 16:47:43
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 193  sub fieldnames { Line 193  sub fieldnames {
          'technical'  => 'Resource is technically correct',            'technical'  => 'Resource is technically correct', 
          'avetries'   => 'Average number of tries till solved',           'avetries'   => 'Average number of tries till solved',
          'stdno'      => 'Total number of students who have worked on this problem',           'stdno'      => 'Total number of students who have worked on this problem',
          'difficulty' => 'Degree of difficulty'           'difficulty' => 'Degree of difficulty',
            'disc'       => 'Degree of discrimination',
          );           );
 }  }
   
Line 252  sub prettyprint { Line 253  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>'.              my $title = &Apache::lonnet::gettitle($url);
                 &Apache::lonhtmlcommon::crumbs($url,'preview','',undef,'+0');              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>'
         } split(/\s*\,\s*/,$value));          } split(/\s*\,\s*/,$value));
     }      }
     # Evaluations      # Evaluations
Line 266  sub prettyprint { Line 284  sub prettyprint {
  return &evalgraph($value);   return &evalgraph($value);
     }      }
     # Difficulty      # Difficulty
     if ($type eq 'difficulty') {      if ($type eq 'difficulty' || $type eq 'disc') {
  return &diffgraph($value);   return &diffgraph($value);
     }      }
     # List of courses      # List of courses
     if ($type=~/\_list/) {      if ($type=~/\_list/) {
  return join('<br />',map {          my @Courses = split(/\s*\,\s*/,$value);
     my %courseinfo=&Apache::lonnet::coursedescription($_);            my $Str;
     '<a href="/public/'.          foreach my $course (@Courses) {
  $courseinfo{'domain'}.'/'.$courseinfo{'num'}.'/syllabus" target="preview">'.              my %courseinfo = &Apache::lonnet::coursedescription($course);
  $courseinfo{'description'}.'</a>';              if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
  } split(/\s*\,\s*/,$value));                  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      # No pretty print found
     return $value;      return $value;
Line 320  sub relatedfield { Line 345  sub relatedfield {
   
 sub prettyinput {  sub prettyinput {
     my ($type,$value,$fieldname,$formname,      my ($type,$value,$fieldname,$formname,
  $relatedsearchflag,$relatedsep,$relatedvalue)=@_;   $relatedsearchflag,$relatedsep,$relatedvalue,$size)=@_;
       if (! defined($size)) {
           $size = 80;
       }
     # Language      # Language
     if ($type eq 'language') {      if ($type eq 'language') {
  return &selectbox($fieldname,   return &selectbox($fieldname,
Line 378  sub prettyinput { Line 406  sub prettyinput {
     $value=~s/\s+/ /gs;      $value=~s/\s+/ /gs;
     $value=~s/\"/\&quod\;/gs;      $value=~s/\"/\&quod\;/gs;
     return       return 
         '<input type="text" name="'.$fieldname.'" size="80" '.          '<input type="text" name="'.$fieldname.'" size="'.$size.'" '.
         'value="'.$value.'" />'.          'value="'.$value.'" />'.
         &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,          &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,
                       $relatedvalue);                         $relatedvalue); 
Line 450  sub report_bombs { Line 478  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 494  sub present_uneditable_metadata { Line 522  sub present_uneditable_metadata {
     } else {      } else {
         $versiondisplay='Version: '.$currentversion;          $versiondisplay='Version: '.$currentversion;
     }      }
     # crumbify displayed URL      # crumbify displayed URL               uri     target prefix form  size
     $disuri=&Apache::lonhtmlcommon::crumbs($disuri);      $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');
       $disuri =~ s:<br />::g;
     # obsolete      # obsolete
     my $obsolete=$content{'obsolete'};      my $obsolete=$content{'obsolete'};
     my $obsoletewarning='';      my $obsoletewarning='';
Line 507  sub present_uneditable_metadata { Line 536  sub present_uneditable_metadata {
     #      #
     my %lt=&fieldnames();      my %lt=&fieldnames();
     my $table='';      my $table='';
       my $title = $content{'title'};
       if (! defined($title)) {
           $title = 'Untitled Resource';
       }
     foreach ('title',       foreach ('title', 
              'author',                'author', 
              'subject',                'subject', 
Line 532  sub present_uneditable_metadata { Line 565  sub present_uneditable_metadata {
     }      }
     #      #
     $r->print(<<ENDHEAD);      $r->print(<<ENDHEAD);
 <h2>$content{'title'}</h2>  <h2>$title</h2>
 <h3><tt>$disuri</tt></h3>  <p>
   $disuri<br />
 $obsoletewarning  $obsoletewarning
 $versiondisplay<br />  $versiondisplay
   </p>
 <table cellspacing=2 border=0>  <table cellspacing=2 border=0>
 $table  $table
 </table>  </table>
Line 549  ENDHEAD Line 584  ENDHEAD
 sub print_dynamic_metadata {  sub print_dynamic_metadata {
     my ($r,$uri,$content) = @_;      my ($r,$uri,$content) = @_;
     #      #
     my %content = \$content;      my %content = %$content;
     my %lt=&fieldnames();      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);
       &Apache::lonnet::logthis('dynamic metadata keys:'.$/.
                                join("\n",keys(%dynmeta)));
     #      #
     # 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>');      #
       # Assessment statistics
     if ($uri=~/\.(problem|exam|quiz|assess|survey|form)$/) {      if ($uri=~/\.(problem|exam|quiz|assess|survey|form)$/) {
         # This is an assessment, print assessment data          if (exists($dynmeta{'stdno'}) ||
         $r->print(              exists($dynmeta{'avetries'}) ||
                   '<h4>'.&mt('Assessment Statistical Data').'</h4>'.              exists($dynmeta{'difficulty'}) ||
               exists($dynmeta{'disc'})) {
               # This is an assessment, print assessment data
               $r->print('<h4>'.
                         &mt('Overall Assessment Statistical Data').
                         '</h4>'.
                         '<table cellspacing=2 border=0>');
               $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{'stdno'}.'</td>'.
                         '<td bgcolor="#CCCCCC">'.
                         &prettyprint('stdno',$dynmeta{'stdno'}).
                         '</td>'."</tr>\n");
               foreach ('avetries','difficulty','disc') {
                   $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
                             '<td bgcolor="#CCCCCC">'.
                             &prettyprint($_,sprintf('%5.2f',$dynmeta{$_})).
                             '</td>'."</tr>\n");
               }
               $r->print('</table>');    
           }
           if (exists($dynmeta{'stats'})) {
               #
               # New assessment statistics
               $r->print('<h4>'.
                         &mt('Detailed Assessment Statistical Data').
                         '</h4>');
               my $table = '<table cellspacing=2 border=0>'.
                   '<tr>'.
                   '<th>Course</th>'.
                   '<th>Section(s)</th>'.
                   '<th>Num Students</th>'.
                   '<th>Mean Tries</th>'.
                   '<th>Degree of Difficulty</th>'.
                   '<th>Degree of Discrimination</th>'.
                   '<th>Time of computation</th>'.
                   '</tr>'.$/;
               foreach my $identifier (sort(keys(%{$dynmeta{'stats'}}))) {
                   my $data = $dynmeta{'stats'}->{$identifier};
                   my $course = $data->{'course'};
                   my %courseinfo = &Apache::lonnet::coursedescription($course);
                   if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
                       &Apache::lonnet::logthis('lookup for '.$course.' failed');
                       next;
                   }
                   $table .= '<tr>';
                   $table .= 
                       '<td><nobr>'.$courseinfo{'description'}.'</nobr></td>';
                   $table .= 
                       '<td align="right">'.$data->{'sections'}.'</td>';
                   $table .=
                       '<td align="right">'.$data->{'stdno'}.'</td>';
                   foreach ('avetries','difficulty','disc') {
                       $table .= '<td align="right">';
                       if (exists($data->{$_})) {
                           $table .= sprintf('%.2f',$data->{$_}).'&nbsp;';
                       } else {
                           $table .= '';
                       }
                       $table .= '</td>';
                   }
                   $table .=
                       '<td><nobr>'.
                       &Apache::lonlocal::locallocaltime($data->{'timestamp'}).
                       '</nobr></td>';
                   $table .=
                       '</tr>'.$/;
               }
               $table .= '</table>'.$/;
               $r->print($table);
           } else {
               $r->print('No new dynamic data found.');
           }
       } else {
           $r->print('<h4>'.
             &mt('No Assessment Statistical Data is available for this resource').
                     '</h4>');
       }
   
       #
       #
       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>');                    '<table cellspacing=2 border=0>');
         foreach ('stdno','avetries','difficulty') {          foreach ('clear','depth','helpful','correct','technical') {
             $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.              $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
                       '<td bgcolor="#CCCCCC">'.                        '<td bgcolor="#CCCCCC">'.
                       &prettyprint($_,$dynmeta{$_})."</td></tr>\n");                        &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
         }          }
         $r->print('</table>');              $r->print('</table>');
     }      } else {
               $r->print('<h4>'.&mt('No Evaluation 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");  
     }      }
     $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)').

Removed from v.1.68  
changed lines
  Added in v.1.75


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