[LON-CAPA-cvs] cvs: loncom /metadata_database searchcat.pl

www lon-capa-cvs@mail.lon-capa.org
Thu, 25 Dec 2003 13:11:56 -0000


www		Thu Dec 25 08:11:56 2003 EDT

  Modified files:              
    /loncom/metadata_database	searchcat.pl 
  Log:
  Slowing getting there. Still needs subjective evaluation data included.
  
  
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.47 loncom/metadata_database/searchcat.pl:1.48
--- loncom/metadata_database/searchcat.pl:1.47	Wed Dec 24 23:06:52 2003
+++ loncom/metadata_database/searchcat.pl	Thu Dec 25 08:11:56 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # searchcat.pl "Search Catalog" batch script
 #
-# $Id: searchcat.pl,v 1.47 2003/12/25 04:06:52 www Exp $
+# $Id: searchcat.pl,v 1.48 2003/12/25 13:11:56 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,8 +56,7 @@
 the C<loncapa:metadata> table if it is deprecated.
 
 This script evaluates dynamic metadata from the authors'
-F<nohist_resevaldata.db> database file in order to store it in MySQL, as
-well as to compress the filesize (add up all "count"-type metadata).
+F<nohist_resevaldata.db> database file in order to store it in MySQL.
 
 This script is playing an increasingly important role for a loncapa
 library server.  The proper operation of this script is critical for a smooth
@@ -131,7 +130,23 @@
 sub dynamicmeta {
     my $url=&declutter(shift);
     $url=~s/\.meta$//;
-    my %returnhash=();
+    my %returnhash=(
+		    'count' => 0,
+		    'course' => 0,
+		    'course_list' => '',
+		    'avetries' => 0,
+		    'avetries_list' => '',
+		    'stdno' => 0,
+		    'stdno_list' => '',
+		    'usage' => 0,
+		    'usage_list' => '',
+		    'goto' => 0,
+		    'goto_list' => '',
+		    'comefrom' => 0,
+		    'comefrom_list' => '',
+		    'difficulty' => 0,
+		    'difficulty_list' => ''
+		    );
     my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);
     my $prodir=&propath($adomain,$aauthor);
 
@@ -187,8 +202,14 @@
 	untie(%evaldata);
 # transfer gathered data to returnhash, calculate averages where applicable
 	while (my $cat=each(%cnt)) {
+	    if ($cnt{$cat} eq 'nan') { next; }
+	    if ($sum{$cat} eq 'nan') { next; }
 	    if ($listitems{$cat} eq 'avg') {
-		$returnhash{$cat}=int(($sum{$cat}/$cnt{$cat})*100.0+0.5)/100.0;
+		if ($cnt{$cat}) {
+		    $returnhash{$cat}=int(($sum{$cat}/$cnt{$cat})*100.0+0.5)/100.0;
+		} else {
+		    $returnhash{$cat}='NULL';
+		}
 	    } elsif ($listitems{$cat} eq 'cnt') {
 		$returnhash{$cat}=$cnt{$cat};
 	    } else {
@@ -260,7 +281,7 @@
         "course INTEGER UNSIGNED, course_list TEXT, ".
         "goto INTEGER UNSIGNED, goto_list TEXT, ".
         "comefrom INTEGER UNSIGNED, comefrom_list TEXT, ".
-        "fusage INTEGER UNSIGNED, fusage_list TEXT, ".
+        "sequsage INTEGER UNSIGNED, sequsage_list TEXT, ".
         "stdno INTEGER UNSIGNED, stdno_list TEXT, ".
 	"avetries FLOAT, avetries_list TEXT, ".
         "difficulty FLOAT, difficulty_list TEXT, ".
@@ -319,7 +340,8 @@
      "?,".   # avetries
      "?,".   # avetries_list
      "?,".   # difficulty
-     "?,"    # difficulty_list
+     "?".    # difficulty_list
+     ")"
      );
 
 foreach my $user (@homeusers) {