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

www www at source.lon-capa.org
Tue Jul 17 19:20:04 EDT 2012


www		Tue Jul 17 23:20:04 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Taxonomy links, checkout
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.18 modules/gerd/harvesting/lonrecommender.pm:1.19
--- modules/gerd/harvesting/lonrecommender.pm:1.18	Tue Jul 17 14:34:13 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Tue Jul 17 23:20:04 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.18 2012/07/17 14:34:13 www Exp $
+# $Id: lonrecommender.pm,v 1.19 2012/07/17 23:20:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -515,6 +515,34 @@
 }
 
 # =================================================================================
+# List the nextlevel categories and their counts
+#
+
+sub list_nextlevel_cats {
+   my ($cmd,$taxocats)=@_;
+   my ($current)=($cmd=~/^taxo\:(.+)$/);
+   my $output='';
+   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);
+      }
+   }
+   return $output;
+}
+
+# =================================================================================
+# Show prioritized list of taxonomy members
+#
+
+sub show_taxonomy_list {
+   my ($cmd,$taxocats, at baseids)=@_;
+   my ($current)=($cmd=~/^taxo\:(.+)$/);
+   return join(',', at baseids);
+}
+
+# =================================================================================
 # A submitting link
 # 
 
@@ -531,7 +559,7 @@
 # 
 
 sub show_dir_list {
-   my ($r,$taxocats,$uri)=@_;
+   my ($r,$taxocats,$filter,$uri)=@_;
    my @list=();
    if ($uri=~/\.(page|sequence)$/) {
 # is a page or a sequence
@@ -666,14 +694,15 @@
        &write_groupimportfile(@selectedurls);
     }
 # ------ Add the resource IDs of the selected URLs to the existing ones
-    my @selectedids=&urlres(@selectedurls);
-    my @baseids=(@existingbasket, at selectedids);
+    my %selectedids=&urlres(@selectedurls);
+    my @baseids=(@existingbasket,values(%selectedids));
 # ------ Now @baseids has the IDs of the URLs the user selected for the folder,
 # ------ prior and during this call, with possible duplicates 
 # ------ if same URL selected twice
 # ------ @selectedurls has the current basket's URLs
 
-
+# ------ Evaluate filter
+    my $filter='';
 # ------ Start the page and the form, store backetcache from londocs
     $r->print(&Apache::loncommon::start_page("Recommender"));
     $r->print('<form method="post" name="recom">');
@@ -685,30 +714,22 @@
     $r->print("<table width='100%'><tr>\n");
     $r->print("<td><input type='text' size='40' name='searchterm' /><input type='submit' name='search' value='".
               &mt('Search')."' /></td>");
-    if (($cmd ne 'showbasket') && ($cmd!~/^rem\:/)) {
-       $r->print("<td rowspan='2' align='right' bgcolor='#DDDDFF'>".
-                 &submit_link(&mt('Your cart ([_1] item(s))',$#selectedurls+1),'showbasket').
-                 "</td>");
-    }
+    $r->print("<td rowspan='2' align='right' bgcolor='#DDDDFF'>".
+              "<font size='+1'><a href='/adm/groupsort?inhibitmenu=yes'>".&mt("Checkout")."</a></font><br /> <br />".
+              &submit_link(&mt('Your cart ([_1] item(s))',$#selectedurls+1),'showbasket').
+              "</td>");
     $r->print("</tr>\n<tr>");
     $r->print('<td>'.&list_toplevel_cats(\%taxonomy_categories).'</td>');
     $r->print("\n</tr></table>");
 # ------ End header row
-    &display_list($r,0,\%taxonomy_categories,
-      ('/res/bsu/physicstir3/Conceptual Questions/002 Car Path on Curve Ice Patch.problem',
-       '/res/purdue/liten/Biology III Cell Structure and Function/Prob_033_Transcription_Translation.problem',
-       '/res/mio/ehlertr/accounting 14 and 15/payrollprocedures.problem',
-       '/res/msu/physicslib/msuphysicslib/05_1D_Motion/msu-prob48.problem',
-       '/res/msu/physicslib/msuphysicslib/05_1D_Motion/msu-prob39.problem',
-       '/res/msu/physicslib/msuphysicslib/05_1D_Motion/msu-prob49.problem')
-    );
-
     if (($cmd eq 'showbasket') || ($cmd=~/^rem\:/)) {
        &display_list($r,1,\%taxonomy_categories, at selectedurls);
     } 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));
     } elsif ($cmd=~/^dir\:(.*)$/) {
-       &show_dir_list($r,\%taxonomy_categories,$1);
+       &show_dir_list($r,\%taxonomy_categories,$filter,$1);
     } elsif ($cmd=~/^indiv\:/) {
     }
 




More information about the LON-CAPA-cvs mailing list