[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm
www
www at source.lon-capa.org
Wed Jul 18 11:26:03 EDT 2012
www Wed Jul 18 15:26:03 2012 EDT
Modified files:
/modules/gerd/harvesting lonrecommender.pm
Log:
Sorting by criteria
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.19 modules/gerd/harvesting/lonrecommender.pm:1.20
--- modules/gerd/harvesting/lonrecommender.pm:1.19 Tue Jul 17 23:20:04 2012
+++ modules/gerd/harvesting/lonrecommender.pm Wed Jul 18 15:26:02 2012
@@ -5,7 +5,7 @@
#
# MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
#
-# $Id: lonrecommender.pm,v 1.19 2012/07/17 23:20:04 www Exp $
+# $Id: lonrecommender.pm,v 1.20 2012/07/18 15:26:02 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -76,8 +76,8 @@
return @basket;
}
-#
-#
+
+# =================================================================================
# Return the resources that the resources in the argument are associated with
# by having been used in the same folder
# Takes an array of resource keys, returns maximum frequency and
@@ -110,6 +110,29 @@
return ($max,%output);
}
+# =================================================================================
+#
+# Return a list of recommendation-weighted resource IDs
+
+sub sorted_list {
+ my ($list, at baseids)=@_;
+ my ($maxassoc,%associations)=&associated(@baseids);
+ my ($maxcount,%counts)=&counts(@$list);
+
+ my @newlist=sort {
+ $associations{$b}/$maxassoc+$counts{$b}/$maxcount
+ <=> $associations{$a}/$maxassoc+$counts{$a}/$maxcount
+ } (@$list);
+
+ for (my $i=0; $i<=10; $i++) {
+ &Apache::lonnet::logthis($i.":".$newlist[$i].' -> '.$associations{$newlist[$i]}.' - '.$counts{$newlist[$i]});
+ }
+ for (my $i=90000; $i<=90010; $i++) {
+ &Apache::lonnet::logthis($i.":".$newlist[$i].' -> '.$associations{$newlist[$i]}.' - '.$counts{$newlist[$i]});
+ }
+
+ return @newlist;
+}
# =================================================================================
#
@@ -537,9 +560,11 @@
#
sub show_taxonomy_list {
- my ($cmd,$taxocats, at baseids)=@_;
+ my ($cmd,$taxocats,$filter, at baseids)=@_;
my ($current)=($cmd=~/^taxo\:(.+)$/);
- return join(',', at baseids);
+ my %fittingids=&taxonomy_members($1);
+ my @fittingids=keys(%fittingids);
+ return &sorted_list(\@fittingids, at baseids);
}
# =================================================================================
@@ -727,7 +752,7 @@
} elsif ($cmd eq 'search') {
} elsif ($cmd=~/^taxo\:/) {
$r->print(&list_nextlevel_cats($cmd,\%taxonomy_categories));
- $r->print(&show_taxonomy_list($cmd,\%taxonomy_categories, at baseids));
+ $r->print(join("<br />\n",&show_taxonomy_list($cmd,\%taxonomy_categories,$filter, at baseids)));
} elsif ($cmd=~/^dir\:(.*)$/) {
&show_dir_list($r,\%taxonomy_categories,$filter,$1);
} elsif ($cmd=~/^indiv\:/) {
More information about the LON-CAPA-cvs
mailing list