--- loncom/interface/lonmeta.pm 2001/12/24 17:13:11 1.10
+++ loncom/interface/lonmeta.pm 2002/02/11 04:19:40 1.14
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.10 2001/12/24 17:13:11 www Exp $
+# $Id: lonmeta.pm,v 1.14 2002/02/11 04:19:40 harris41 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,7 +29,7 @@
#
# 05/29/00,05/30,10/11 Gerd Kortemeyer)
#
-# 10/19,10/21,10/23,11/27,08/09/01,12/22,12/24 Gerd Kortemeyer
+# 10/19,10/21,10/23,11/27,08/09/01,12/22,12/24,12/25 Gerd Kortemeyer
package Apache::lonmeta;
@@ -85,11 +85,59 @@ sub dynamicmeta {
}
my %returnhash=();
foreach (keys %cnt) {
-
+ if ($listitems{$_} eq 'avg') {
+ $returnhash{$_}=int(($sum{$_}/$cnt{$_})*100.0+0.5)/100.0;
+ } elsif ($listitems{$_} eq 'cnt') {
+ $returnhash{$_}=$cnt{$_};
+ } else {
+ $returnhash{$_}=$sum{$_};
+ }
}
return %returnhash;
}
+# -------------------------------------------------------------- Pretty display
+
+sub evalgraph {
+ my $value=shift;
+ unless ($value) { return ''; }
+ my $val=int($value*10.+0.5)-10;
+ my $output='
';
+ if ($val>=20) {
+ $output.='  | ';
+ } else {
+ $output.=' | '.
+ ' | ';
+ }
+ $output.=' | ';
+ if ($val>20) {
+ $output.=' | '.
+ ' | ';
+ } else {
+ $output.='  | ';
+ }
+ $output.=' ('.$value.') |
';
+ return $output;
+}
+
+sub diffgraph {
+ my $value=shift;
+ unless ($value) { return ''; }
+ my $val=int(40.0*$value+0.5);
+ my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
+ '#BBDD33','#CCCC33','#DDBB33','#EEAA33');
+ my $output='';
+ for (my $i=0;$i<8;$i++) {
+ if ($val>$i*5) {
+ $output.=' | ';
+ } else {
+ $output.=' | ';
+ }
+ }
+ $output.=' ('.$value.') |
';
+ return $output;
+}
+
# ================================================================ Main Handler
sub handler {
@@ -106,16 +154,16 @@ sub handler {
# ------------------------------------------------------------------- Read file
my $uri=$r->uri;
- map {
+ foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
$content{$_}=&Apache::lonnet::metadata($uri,$_);
- } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
+ }
# ------------------------------------------------------------------ Hide stuff
unless ($ENV{'user.adv'}) {
- map {
+ foreach ('keywords','notes','abstract','subject') {
$content{$_}='- not displayed -';
- } ('keywords','notes','abstract','subject');
+ }
}
# --------------------------------------------------------------- Render Output
@@ -124,25 +172,38 @@ my $creationdate=localtime($content{'cre
my $lastrevisiondate=localtime($content{'lastrevisiondate'});
my $language=&Apache::loncommon::languagedescription($content{'language'});
my $mime=&Apache::loncommon::filedescription($content{'mime'});
+my $disuri=&Apache::lonnet::declutter($uri);
+ $disuri=~s/\.meta$//;
$r->print(<Catalog Information
Catalog Information
$content{'title'}
-Author(s): $content{'author'}
-Subject: $content{'subject'}
-Keyword(s): $content{'keywords'}
-Notes: $content{'notes'}
-Abstract:
-$content{'abstract'}
-
-MIME Type: $mime ($content{'mime'})
-Language: $language
-Creation Date: $creationdate
-Last Revision Date: $lastrevisiondate
-Publisher/Owner: $content{'owner'}
-Copyright/Distribution: $content{'copyright'}
-
+$disuri
+
+Author(s) |
+$content{'author'} |
+Subject |
+$content{'subject'} |
+Keyword(s) |
+$content{'keywords'} |
+Notes |
+$content{'notes'} |
+Abstract |
+$content{'abstract'} |
+MIME Type |
+$mime ($content{'mime'}) |
+Language |
+$language |
+Creation Date |
+$creationdate |
+
+Last Revision Date | $lastrevisiondate |
+Publisher/Owner |
+$content{'owner'} |
+Copyright/Distribution |
+$content{'copyright'}
+ |
ENDHEAD
delete($content{'title'});
delete($content{'author'});
@@ -157,41 +218,59 @@ ENDHEAD
delete($content{'owner'});
delete($content{'copyright'});
if ($ENV{'user.adv'}) {
+# ------------------------------------------------------------ Dynamic Metadata
$r->print('Dynamic Metadata (updated periodically)
');
my %items=(
'count' => 'Network-wide number of accesses (hits)',
'course' => 'Network-wide number of courses using resource',
'usage' => 'Number of resources using or importing resource',
- 'clear' => 'Evaluation: presented in clear way',
- 'depth' => 'Evaluation: material covered with sufficient depth',
- 'helpful' => 'Evaluation: material is helpful',
- 'correct' => 'Evaluation: material appears to be correct',
- 'technical' => 'Evaluation: material is technically correct',
+ 'clear' => 'Material presented in clear way',
+ 'depth' => 'Material covered with sufficient depth',
+ 'helpful' => 'Material is helpful',
+ 'correct' => 'Material appears to be correct',
+ 'technical' => 'Resource is technically correct',
'avetries' => 'Average number of tries till solved',
'stdno' => 'Total number of students who have worked on this problem',
'difficulty' => 'Degree of difficulty');
my %dynmeta=&dynamicmeta($uri);
- $r->print('Access and Usage Statistics
');
+ $r->print(
+'Access and Usage Statistics
');
foreach ('count','usage','course') {
- $r->print(''.$items{$_}.':'."
\n");
- }
+ $r->print(
+''.$items{$_}.' | '.
+$dynmeta{$_}." |
\n");
+ }
+ $r->print('
');
if ($uri=~/\.(problem|exam|quiz|assess|survey|form)\.meta$/) {
- $r->print('Assessment Statistical Data
');
- foreach ('stdno','avetries','difficulty') {
- $r->print(''.$items{$_}.':'."
\n");
- }
+ $r->print(
+'Assessment Statistical Data
');
+ foreach ('stdno','avetries') {
+ $r->print(
+''.$items{$_}.' | '.
+$dynmeta{$_}." |
\n");
+ }
+ foreach ('difficulty') {
+ $r->print(
+''.$items{$_}.' | '.
+&diffgraph($dynmeta{$_})." |
\n");
+ }
+ $r->print('
');
}
- $r->print('Evaluation Data
');
+ $r->print('Evaluation Data
');
foreach ('clear','depth','helpful','correct','technical') {
- $r->print(''.$items{$_}.':'."
\n");
+ $r->print(
+''.$items{$_}.' | '.
+&evalgraph($dynmeta{$_})." |
\n");
}
- &Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//;
+ $r->print('
');
+ $disuri=~/^(\w+)\/(\w+)\//;
if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
|| ($ENV{'user.role.ca./'.$1.'/'.$2})) {
$r->print(
'Evaluation Comments (visible to author and co-authors only)
'.
- $dynmeta{'comments'});
+ ''.$dynmeta{'comments'}.'
');
}
+# ------------------------------------------------------------- All other stuff
$r->print(
'Additional Metadata (non-standard, parameters, exports)
');
foreach (sort keys %content) {
@@ -199,12 +278,12 @@ ENDHEAD
my $display=&Apache::lonnet::metadata($uri,$name.'.display');
unless ($display) { $display=$name; };
my $otherinfo='';
- map {
+ foreach ('name','part','type','default') {
if (defined(&Apache::lonnet::metadata($uri,$name.'.'.$_))) {
$otherinfo.=' '.$_.'='.
&Apache::lonnet::metadata($uri,$name.'.'.$_).'; ';
}
- } ('name','part','type','default');
+ }
$r->print(''.$display.': '.$content{$name});
if ($otherinfo) {
$r->print(' ('.$otherinfo.')');