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

www www at source.lon-capa.org
Wed Jul 18 13:24:47 EDT 2012


www		Wed Jul 18 17:24:47 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Prioritized search results
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.22 modules/gerd/harvesting/lonrecommender.pm:1.23
--- modules/gerd/harvesting/lonrecommender.pm:1.22	Wed Jul 18 16:54:35 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Wed Jul 18 17:24:47 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.22 2012/07/18 16:54:35 www Exp $
+# $Id: lonrecommender.pm,v 1.23 2012/07/18 17:24:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -299,7 +299,7 @@
 #
 
 sub keyword_search {
-   my ($filter, at keywords)=@_;
+   my ($filter,$baseids, at keywords)=@_;
    my %output=();
    my $skey=join(',', at keywords);
    $skey=~s/^\W+//gs;
@@ -315,7 +315,8 @@
       }
    }
    untie(%hash);
-   return(%output);
+   my @fittingids=keys(%output);
+   return &sorted_list(\@fittingids,@$baseids);
 }
 
 # =================================================================================
@@ -538,12 +539,17 @@
 sub list_nextlevel_cats {
    my ($cmd,$taxocats)=@_;
    my ($current)=($cmd=~/^taxo\:(.+)$/);
-   my $output='';
+   my $output='<b>'.$current.' ...</b><br />';
    foreach my $key (sort(keys(%$taxocats))) {
       if ($key=~/^count\_(.+)$/) {
          my $cat=$1;
          unless ($cat=~/^\Q$current\E/) { next; }
-         $output.=' '.&submit_link($cat.' ('.$$taxocats{$key}.')','taxo:'.$cat);
+         my $displaycat=$cat;
+         $displaycat=~s/^\Q$current\E//;
+         $displaycat=~s/^\://;
+         if ($displaycat) {
+            $output.=' '.&submit_link($displaycat.' ('.$$taxocats{$key}.')','taxo:'.$cat);
+         }
       }
    }
    return $output;
@@ -553,7 +559,7 @@
 # Show prioritized list of taxonomy members
 #
 
-sub show_taxonomy_list {
+sub taxonomy_list {
    my ($cmd,$taxocats,$filter, at baseids)=@_;
    my ($current)=($cmd=~/^taxo\:(.+)$/);
    my %fittingids=&taxonomy_members($1);
@@ -747,11 +753,11 @@
        $r->print("\n<h1>".&mt("Current Cart")."</h1>\n");
        &display_list($r,1,\%taxonomy_categories, at selectedurls);
     } elsif ($env{'form.search'}) {
-       my %list=&urlres((&keyword_search($filter,$env{'form.searchterm'}))[0..9]);
+       my %list=&urlres((&keyword_search($filter,\@baseids,$env{'form.searchterm'}))[0..9]);
        &display_list($r,0,\%taxonomy_categories,values(%list));
     } elsif ($cmd=~/^taxo\:/) {
        $r->print(&list_nextlevel_cats($cmd,\%taxonomy_categories));
-       my %list=&urlres((&show_taxonomy_list($cmd,\%taxonomy_categories,$filter, at baseids))[0..9]);
+       my %list=&urlres((&taxonomy_list($cmd,\%taxonomy_categories,$filter, at baseids))[0..9]);
        &display_list($r,0,\%taxonomy_categories,values(%list));
     } elsif ($cmd=~/^dir\:(.*)$/) {
        &show_dir_list($r,\%taxonomy_categories,$filter,$1);




More information about the LON-CAPA-cvs mailing list