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

www www at source.lon-capa.org
Wed Jul 18 16:37:45 EDT 2012


www		Wed Jul 18 20:37:45 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Recommendations for basket and individual resources
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.24 modules/gerd/harvesting/lonrecommender.pm:1.25
--- modules/gerd/harvesting/lonrecommender.pm:1.24	Wed Jul 18 19:24:05 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Wed Jul 18 20:37:44 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.24 2012/07/18 19:24:05 www Exp $
+# $Id: lonrecommender.pm,v 1.25 2012/07/18 20:37:44 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -319,6 +319,18 @@
    return &sorted_list(\@fittingids,@$baseids);
 }
 
+
+# =================================================================================
+# Return sorted list of associated IDs
+#
+
+sub associated_ids {
+   my ($filter,$baseids, at urlids)=@_;
+   my ($max,%output)=&associated(@urlids);
+   my @fittingids=keys(%output);
+   return &sorted_list(\@fittingids,@$baseids);
+}
+
 # =================================================================================
 #
 # Filter by resource type
@@ -755,6 +767,8 @@
     if (($cmd eq 'showbasket') || ($cmd=~/^rem\:/)) {
        $r->print("\n<h1>".&mt("Current Cart")."</h1>\n");
        &display_list($r,1,\%taxonomy_categories, at selectedurls);
+       my %list=&urlres((&associated_ids($filter,\@baseids,values(%selectedids)))[$lower..$lower+19]);
+       &display_list($r,0,\%taxonomy_categories,values(%list));
     } elsif ($cmd eq 'search') {
        my %list=&urlres((&keyword_search($filter,\@baseids,$env{'form.searchterm'}))[$lower..$lower+19]);
        &display_list($r,0,\%taxonomy_categories,values(%list));
@@ -765,6 +779,16 @@
     } elsif ($cmd=~/^dir\:(.*)$/) {
        &show_dir_list($r,\%taxonomy_categories,$filter,$1);
     } elsif ($cmd=~/^indiv\:/) {
+       if ($cmd=~/\:(.+)$/) {
+          my $url=$1;
+          $r->print('<h2>'.&Apache::lonnet::gettitle($url).'</h2>'.&submit_link(&mt('Add this resource'),'add:'.$url));
+          $r->print('<iframe src="'.$url.'?inhibitmenu=yes" width="100%" height="50%"></iframe>'."\n");
+          my %urlid=&urlres($url);
+          if ($urlid{$url}) {
+             my %list=&urlres((&associated_ids($filter,\@baseids,$urlid{$url}))[$lower..$lower+9]);
+             &display_list($r,0,\%taxonomy_categories,values(%list));
+          }
+       }
     }
 
 # ------ Close page




More information about the LON-CAPA-cvs mailing list