[LON-CAPA-cvs] cvs: loncom /interface groupsort.pm lonsearchcat.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 16 Sep 2002 20:57:28 -0000


matthew		Mon Sep 16 16:57:28 2002 EDT

  Modified files:              
    /loncom/interface	groupsort.pm lonsearchcat.pm 
  Log:
  Fixes for bug 775.
  
  lonsearchcat.pm was modified to take a new parameter, cleargroupsort, which
  causes it to clear the GDBM file used by the groupsort.pm handler.
  &catalogmode_output was modified to take two new parameters which identify
  uniquely the radiobutton it produces and the resource the radiobutton 
  refers to.
  The javascript function queue was modified to take two parameters which
  correspond to the two new ones passed to &catalogmode_output.
  
  groupsort.pm was modified to pass 'cleargroupsort' to lonspreadsheet.pm
  when the 'new search' button is hit.
  
  
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.15 loncom/interface/groupsort.pm:1.16
--- loncom/interface/groupsort.pm:1.15	Tue Aug 27 08:18:13 2002
+++ loncom/interface/groupsort.pm	Mon Sep 16 16:57:28 2002
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.15 2002/08/27 12:18:13 www Exp $
+# $Id: groupsort.pm,v 1.16 2002/09/16 20:57:28 matthew Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -302,10 +302,10 @@
     }
     if ($ENV{'form.catalogmode'} eq 'groupsearch') {
 	$r->print(<<END);
-<input type="button" name="alter" value="GO BACK"
- onClick="window.location='/adm/searchcat?catalogmode=groupsearch'" />&nbsp;
+<input type="button" name="alter" value="New Search"
+ onClick="window.location='/adm/searchcat?catalogmode=groupsearch&cleargroupsort=1'" />&nbsp;
 END
-}
+    }
 # ---
 
     $r->print(<<END);
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.157 loncom/interface/lonsearchcat.pm:1.158
--- loncom/interface/lonsearchcat.pm:1.157	Mon Sep 16 16:09:45 2002
+++ loncom/interface/lonsearchcat.pm	Mon Sep 16 16:57:28 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.157 2002/09/16 20:09:45 www Exp $
+# $Id: lonsearchcat.pm,v 1.158 2002/09/16 20:57:28 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -191,7 +191,8 @@
     ##
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
              ['catalogmode','launch','acts','mode','form','element','pause',
-              'phase','persistent_db_id','table','start','show']);
+              'phase','persistent_db_id','table','start','show',
+              'cleargroupsort']);
     ##
     ## The following is a trick - we wait a few seconds if asked to so
     ##     the daemon running the search can get ahead of the daemon
@@ -242,11 +243,13 @@
     ## Clear out old values from groupsearch database
     ##
     untie %groupsearch_db if (tied(%groupsearch_db));
-    if (($ENV{'form.launch'} eq '1') && 
-        ($ENV{'form.catalogmode'} eq 'groupsearch')) {
+    if (($ENV{'form.cleargroupsort'} eq '1') || 
+        (($ENV{'form.launch'} eq '1') && 
+         ($ENV{'form.catalogmode'} eq 'groupsearch'))) {
 	if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
 	    &start_fresh_session();
 	    untie %groupsearch_db;
+            delete($ENV{'form.cleargroupsort'});
 	} else {
             # This is a stupid error to give to the user.  
             # It really tells them nothing.
@@ -1871,6 +1874,7 @@
     $revise_phase = 'disp_adv' if ($ENV{'form.searchmode'} eq 'advanced');
     my $newloc = '/adm/searchcat'.
         '?persistent_db_id='.$ENV{'form.persistent_db_id'}.
+            '&cleargroupsort=1'.
             '&phase='.$revise_phase;
     my $result = qq{<input type="button" value="Revise search" name="revise"} .
         qq{ onClick="parent.location='$newloc';" /> };
@@ -2144,6 +2148,10 @@
         return;
     }
     ##
+    ## $checkbox_num is a count of the number of checkboxes output on the 
+    ## page this is used only during catalogmode=groupsearch.
+    my $checkbox_num = 0;
+    ##
     ## Get the catalog controls setup
     ##
     my $action = "/adm/searchcat?phase=results";
@@ -2222,7 +2230,8 @@
         }
         my %Fields = %{&parse_row(@$row)};
         my $output="<p>\n";
-        my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'});
+        my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'},
+                                       $Fields{'id'},$checkbox_num++);
         # Render the result into html
         $output.= &$viewfunction($prefix,%Fields);
         # Print them out as they come in.
@@ -2253,22 +2262,18 @@
 
 =pod
 
-=item &catalogmode_output($title,$url)
+=item &catalogmode_output($title,$url,$fnum,$checkbox_num)
 
 Returns html needed for the various catalog modes.  Gets inputs from
-$ENV{'form.catalogmode'}.  Stores data in %groupsearch_db and $fnum 
-(local variable).
+$ENV{'form.catalogmode'}.  Stores data in %groupsearch_db.
 
 =cut
 
 ######################################################################
 ######################################################################
-{ 
-my $fnum = 0;
-
 sub catalogmode_output {
     my $output = '';
-    my ($title,$url) = @_;
+    my ($title,$url,$fnum,$checkbox_num) = @_;
     if ($ENV{'form.catalogmode'} eq 'interactive') {
         $title=~ s/\'/\\\'/g;
         if ($ENV{'form.catalogmode'} eq 'interactive') {
@@ -2284,15 +2289,12 @@
         $output.=<<END;
 <font size='-1'>
 <input type="checkbox" name="returnvalues" value="SELECT"
-onClick="javascript:queue($fnum)" />
+onClick="javascript:queue($checkbox_num,$fnum)" />
 </font>
 END
-        $fnum++;
     }
     return $output;
 }
-
-}
 ######################################################################
 ######################################################################
 
@@ -2540,8 +2542,8 @@
     }
     $result.=<<SCRIPT if $ENV{'form.catalogmode'} eq 'groupsearch';
 <script type="text/javascript">
-    function queue(val) {
-        if (document.forms.results.returnvalues[val].checked) {
+    function queue(checkbox_num,val) {
+        if (document.forms.results.returnvalues[checkbox_num].checked) {
             parent.statusframe.document.forms.statusform.elements.Queue.value +='1a'+val+'b';
         } else {
             parent.statusframe.document.forms.statusform.elements.Queue.value +='0a'+val+'b';
@@ -2596,6 +2598,7 @@
 <head>
 <script>
 var targetwin = opener;
+var queue = '';
 </script>
 <title>LON-CAPA Digital Library Search Results</title>
 </head>