[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm

www www at source.lon-capa.org
Thu Jul 19 11:52:20 EDT 2012


www		Thu Jul 19 15:52:20 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Division by zero avoided; logging
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.30 modules/gerd/harvesting/lonrecommender.pm:1.31
--- modules/gerd/harvesting/lonrecommender.pm:1.30	Thu Jul 19 14:48:35 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Thu Jul 19 15:52:20 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.30 2012/07/19 14:48:35 www Exp $
+# $Id: lonrecommender.pm,v 1.31 2012/07/19 15:52:20 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,7 +38,11 @@
 # PROTOTYPE USE --- will need to be modified
 
 use GDBM_File;
+
+# Need modification if datafiles elsewhere
 my $datapath='/home/www/loncapa/modules/gerd/harvesting/';
+# Transaction log, set to empty for no logging
+my $logfile='/home/httpd/perl/logs/recommender.log';
 
 use Apache::lonnet;
 use Apache::lonindexer();
@@ -55,6 +59,16 @@
 use GDBM_File;
 use LONCAPA qw(:DEFAULT :match);
 
+# Logging
+
+sub elog {
+   unless ($logfile) { return; }
+   open(OUT,">>$logfile");
+   print OUT time.'&'.$env{'request.course.id'}.'&'.join('&', at _)."\n";
+   close(OUT);
+   return;
+}
+
 # PROTOTYPE ROUTINES --- These are the routines needed to run the prototype
 # Accessing the data files in $datapath
 
@@ -116,13 +130,21 @@
 
 sub sorted_list {
    my ($baseids, at list)=@_;
+   &elog('base',values(%$baseids));
    my ($associations,$maxassoc)=&associated(values(%$baseids));
+   unless ($maxassoc) { $maxassoc=1; }
    my ($maxcount,%counts)=&counts(@list);
+   unless ($maxcount) { $maxcount=1; }
 
    my @newlist=sort {
          $$associations{$b}/$maxassoc+$counts{$b}/$maxcount 
      <=> $$associations{$a}/$maxassoc+$counts{$a}/$maxcount
    } (@list);
+   &elog('topsorted',$maxassoc,$maxcount,
+         $newlist[0],$$associations{$newlist[0]},$counts{$newlist[0]},
+         $newlist[1],$$associations{$newlist[1]},$counts{$newlist[1]},
+         $newlist[2],$$associations{$newlist[2]},$counts{$newlist[2]}
+        );
    return @newlist;
 }
 
@@ -730,7 +752,7 @@
         'custom' => &mt('Custom Response'),
         'math' => &mt('Math Response'));
     my $allprobs=join('|',keys(%problemtypes));
-    my $output='<select name="filter">'.
+    my $output='<select name="filter" onChange="this.form.cmd.value=\''.$env{'form.cmd'}.'\';this.form.submit();">'.
                '<option value="">'.&mt("None").'</option>'.
                '<option value="page|'.$allprobs.'">'.&mt('Pages and Problems').'</option>'.
                '<option value="'.$allprobs.'">'.&mt('Problems').'</option>'.
@@ -762,6 +784,8 @@
 # ------
 # Only advanced users should get here
     unless ($env{'user.adv'}) { return; }
+# Log transaction
+    &elog('is',$env{'form.cmd'},$env{'form.filter'},$env{'form.searchterm'});
 # ------
 # Get the existing basket
 # This is what the user already has in his or her folder
@@ -861,6 +885,7 @@
           }
        }
     } else {
+       &elog("first", at existingbasket);
        &display($r,\%taxonomy_categories,\%selectedids,$filter,$lower,20,&associated(@existingbasket));
     }
 




More information about the LON-CAPA-cvs mailing list