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

www www at source.lon-capa.org
Sun Jul 15 06:29:25 EDT 2012


www		Sun Jul 15 10:29:25 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Reading current shopping basket, structure for editing
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.5 modules/gerd/harvesting/lonrecommender.pm:1.6
--- modules/gerd/harvesting/lonrecommender.pm:1.5	Sat Jul 14 15:04:34 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Sun Jul 15 10:29:24 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.5 2012/07/14 15:04:34 www Exp $
+# $Id: lonrecommender.pm,v 1.6 2012/07/15 10:29:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -357,6 +357,38 @@
 }
 
 # =================================================================================
+# Read a file in groupimport format
+#
+
+sub read_groupimportfile {
+   my $diropendb =
+        "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db";
+   my %dbfile;
+   my @urls=();
+# Tie the file and write into it
+   if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_READER(),0640)) {
+      foreach my $fkey (keys(%dbfile)) {
+         if ($fkey=~/^storectr\_(.+)$/) {
+            $urls[$fkey]=$1;
+         }
+      }
+      untie(%dbfile);
+   }
+   return @urls;
+}
+
+# =================================================================================
+# Execute any edit commands (at the moment only remove)
+#
+
+sub edit_commands {
+   my @urls=@_;
+# logic will go here
+   return @urls;
+}
+
+
+# =================================================================================
 #
 
 sub handle_request {
@@ -369,7 +401,7 @@
     my @existingbasket=();
     if ($basket eq 'cached') {
 # We have been here before
-       @existingbasket=split(/\,/,$env{'form.cachedbasket'});
+       @existingbasket=split(/\,/,$env{'form.basketcache'});
     } else {
 # Read the basket and evaluate
        my ($cnum,$cdom,$folder)=split(/\,/,$basket);
@@ -387,9 +419,28 @@
 # ------ Now have array @existingbasket and string $basketcache
 # ------ Read in the taxonomy lookup table
     my %taxonomy_categories=&taxonomy_categories();
+# ------ Now we have the taxonomies
+# ------ Read the URLs selected thus far ...
+    my @selectedurls=&read_groupimportfile();
+# ------ ... and execute any editing commands
+    @selectedurls=&edit_commands(@selectedurls);
+# ------ Add the resource IDs of the selected URLs to the existing ones
+    my @selectedids=&urlres(@selectedurls);
+    my @baseids=(@existingbasket, at selectedurls);
+# ------ 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
+
+
 
 
+
+# ------ Start the page and the form, store backetcache from londocs
     $r->print(&Apache::loncommon::start_page("Recommender"));
+    $r->print('<form method="post">');
+    $r->print('<input type="hidden" name="basket" value="cached" />');
+    $r->print('<input type="hidden" name="basketcache" value="'.$basketcache.'" />');
+
     $r->print("<h1>Hello World!</h1>");
 
     my %taxos=&taxoids(3,5,8,90,900,1450,13624,31415);
@@ -400,7 +451,8 @@
        $r->print($key.' '.$urls{$key}.' '.$counts{$key}.' => '.$taxos{$key}.' '.$taxonomy_categories{'cleartext_'.$taxos{$key}}."<br />\n");
     }
 
-    
+# ------ Close form, done with page
+    $r->print('</form>');
     $r->print(&Apache::loncommon::end_page());
     return 1;
 }




More information about the LON-CAPA-cvs mailing list