[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm /metadata_database searchcat.pl

www lon-capa-cvs@mail.lon-capa.org
Sat, 27 Dec 2003 23:04:28 -0000


This is a MIME encoded message

--www1072566268
Content-Type: text/plain

www		Sat Dec 27 18:04:28 2003 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
    /loncom/metadata_database	searchcat.pl 
  Log:
  Bugs #789 and 1926: Trying to make new fields searchable, just saving my work.
  
  
--www1072566268
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20031227180428.txt"

Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.197 loncom/interface/lonsearchcat.pm:1.198
--- loncom/interface/lonsearchcat.pm:1.197	Sat Dec 27 12:32:08 2003
+++ loncom/interface/lonsearchcat.pm	Sat Dec 27 18:04:28 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.197 2003/12/27 17:32:08 www Exp $
+# $Id: lonsearchcat.pm,v 1.198 2003/12/27 23:04:28 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -293,11 +293,13 @@
         }
         # Set up table
         if (! defined(&create_results_table())) {
+	    my $errorstring=&Apache::lonmysql::get_error();
             $r->print(<<END);
 <html><head><title>Search Error</title></head>
 $bodytag
 Unable to create table in which to store search results.  
 The search has been aborted.
+<br />$errorstring
 </body>
 </html>
 END
@@ -646,6 +648,7 @@
                                              $ENV{'form.notes'});
     $scrout.=&searchphrasefield_with_related('abstract','abstract',
                                              $ENV{'form.abstract'});
+    $scrout.=&searchphrasefield('Standards','standards',$ENV{'form.standards'});
     # Hack - an empty table row.
     $scrout.="<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
     $scrout.=&searchphrasefield('file<br />extension','extension',
@@ -1899,10 +1902,36 @@
       { name => 'notes',     type=>'TEXT'},
       { name => 'abstract',  type=>'TEXT'},
       { name => 'mime',      type=>'TEXT'},
-      { name => 'lang',      type=>'TEXT'},
+      { name => 'language',  type=>'TEXT'},
       { name => 'owner',     type=>'TEXT'},
       { name => 'copyright', type=>'TEXT'},
-      { name => 'hostname',  type=>'TEXT'},
+      { name => 'dependencies',     type=>'TEXT'},
+      { name => 'modifyinguser', type=>'TEXT'},
+      { name => 'authorspace', type=>'TEXT'},
+      { name => 'lowestgradelevel',  type=>'INT'},
+      { name => 'highestgradelevel', type=>'INT'},
+      { name => 'standards', type=>'TEXT'},
+      { name => 'count',     type=>'INT'},
+      { name => 'course', type=>'INT'},
+      { name => 'course_list',  type=>'TEXT'},
+      { name => 'goto', type=>'INT'},
+      { name => 'goto_list',  type=>'TEXT'},
+      { name => 'comefrom', type=>'INT'},
+      { name => 'comefrom_list',  type=>'TEXT'},
+      { name => 'sequsage', type=>'INT'},
+      { name => 'sequsage_list',  type=>'TEXT'},
+      { name => 'stdno', type=>'INT'},
+      { name => 'stdno_list',  type=>'TEXT'},
+      { name => 'avetries', type=>'FLOAT'},
+      { name => 'avetries_list',  type=>'TEXT'},
+      { name => 'difficulty', type=>'FLOAT'},
+      { name => 'difficulty_list',  type=>'TEXT'},
+      { name => 'clear',  type=>'FLOAT'},
+      { name => 'technical',  type=>'FLOAT'},
+      { name => 'correct',  type=>'FLOAT'},
+      { name => 'helpful',  type=>'FLOAT'},
+      { name => 'depth',  type=>'FLOAT'},
+      { name => 'hostname', type=> 'TEXT'},
       #--------------------------------------------------
       { name => 'creationdate',     type=>'DATETIME'},
       { name => 'lastrevisiondate', type=>'DATETIME'},
@@ -2467,7 +2496,7 @@
         $Fields{$Datatypes[$i]->{'name'}}=&Apache::lonnet::unescape($Row[$i]);
     }
     $Fields{'language'} = 
-        &Apache::loncommon::languagedescription($Fields{'lang'});
+        &Apache::loncommon::languagedescription($Fields{'language'});
     $Fields{'copyrighttag'} =
         &Apache::loncommon::copyrightdescription($Fields{'copyright'});
     $Fields{'mimetag'} =
@@ -2483,13 +2512,10 @@
 =item &parse_raw_result()
 
 Takes a line from the file of results and parse it.  Returns a hash 
-with keys for the following fields:
-'title', 'author', 'subject', 'url', 'keywords', 'version', 'notes', 
-'abstract', 'mime', 'lang', 'owner', 'copyright', 'creationdate', 
-'lastrevisiondate'.
+with keys according to column labels
 
 In addition, the following tags are set by calling the appropriate 
-lonnet function: 'language', 'cprtag', 'mimetag'.
+lonnet function: 'language', 'copyrighttag', 'mimetag'.
 
 The 'title' field is set to "Untitled" if the title field is blank.
 
@@ -2510,27 +2536,15 @@
     my @fields=map {
         &Apache::lonnet::unescape($_);
     } (split(/\,/,$result));
-    my ($title,$author,$subject,$url,$keywords,$version,
-        $notes,$abstract,$mime,$lang,
-        $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;
-    my %Fields = 
-        ( title     => &Apache::lonnet::unescape($title),
-          author    => &Apache::lonnet::unescape($author),
-          subject   => &Apache::lonnet::unescape($subject),
-          url       => &Apache::lonnet::unescape($url),
-          keywords  => &Apache::lonnet::unescape($keywords),
-          version   => &Apache::lonnet::unescape($version),
-          notes     => &Apache::lonnet::unescape($notes),
-          abstract  => &Apache::lonnet::unescape($abstract),
-          mime      => &Apache::lonnet::unescape($mime),
-          lang      => &Apache::lonnet::unescape($lang),
-          owner     => &Apache::lonnet::unescape($owner),
-          copyright => &Apache::lonnet::unescape($copyright),
-          creationdate     => &Apache::lonnet::unescape($creationdate),
-          lastrevisiondate => &Apache::lonnet::unescape($lastrevisiondate)
-        );
+# conclude from self to others regarding fields
+    my @columns=&Apache::lonmysql::col_order('metadata');
+    my %Fields=();
+    for (my $i=0; $i<=$#columns; $i++) {
+	$Fields{$columns[$i]}=$fields[$i];
+    }
+# prettier display
     $Fields{'language'} = 
-        &Apache::loncommon::languagedescription($Fields{'lang'});
+        &Apache::loncommon::languagedescription($Fields{'language'});
     $Fields{'copyrighttag'} =
         &Apache::loncommon::copyrightdescription($Fields{'copyright'});
     $Fields{'mimetag'} =
@@ -2544,7 +2558,7 @@
         $Fields{'title'}='Untitled'; 
     }
     unless ($ENV{'user.adv'}) {
-        # What is this anyway?
+        # do not show descriptive information to non-advanced users
         $Fields{'keywords'} = '- not displayed -';
         $Fields{'notes'}    = '- not displayed -';
         $Fields{'abstract'} = '- not displayed -';
@@ -2836,7 +2850,7 @@
 <b>Notes:         </b> $values{'notes'}<br />
 <b>MIME Type:     </b> $values{'mimetag'}<br />
 <b>Language:      </b> $values{'language'}<br />
-<b>Copyright/Distribution:</b> $values{'cprtag'}<br />
+<b>Copyright/Distribution:</b> $values{'copyrighttag'}<br />
 </p>
 $values{'extrashow'}
 <p>
@@ -2965,8 +2979,8 @@
 &lt;mimetag&gt;$values{'mimetag'}&lt;/mimetag&gt;
 &lt;/mimeInfo&gt;
 &lt;languageInfo&gt;
-&lt;language&gt;$values{'lang'}&lt;/language&gt;
-&lt;languagetag&gt;$values{'language'}&lt;/languagetag&gt;
+&lt;language&gt;$values{'language'}&lt;/language&gt;
+&lt;languagetag&gt;$values{'languagetag'}&lt;/languagetag&gt;
 &lt;/languageInfo&gt;
 &lt;creationdate&gt;$values{'creationdate'}&lt;/creationdate&gt;
 &lt;lastrevisiondate&gt;$values{'lastrevisiondate'}&lt;/lastrevisiondate&gt;
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.52 loncom/metadata_database/searchcat.pl:1.53
--- loncom/metadata_database/searchcat.pl:1.52	Fri Dec 26 20:52:04 2003
+++ loncom/metadata_database/searchcat.pl	Sat Dec 27 18:04:28 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # searchcat.pl "Search Catalog" batch script
 #
-# $Id: searchcat.pl,v 1.52 2003/12/27 01:52:04 www Exp $
+# $Id: searchcat.pl,v 1.53 2003/12/27 23:04:28 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -296,7 +296,9 @@
         "difficulty FLOAT, difficulty_list TEXT, ".
 	"clear FLOAT, technical FLOAT, correct FLOAT, helpful FLOAT, depth FLOAT, ".
 	"comments TEXT, ".
-
+# For backward compatibility, only insert new fields below
+# ...
+# For backward compatibility, end new fields above
         "FULLTEXT idx_title (title), ".
         "FULLTEXT idx_author (author), FULLTEXT idx_subject (subject), ".
         "FULLTEXT idx_url (url), FULLTEXT idx_keywords (keywords), ".

--www1072566268--