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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 27 Apr 2004 15:24:10 -0000


This is a MIME encoded message

--matthew1083079450
Content-Type: text/plain

matthew		Tue Apr 27 11:24:10 2004 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  Removed old help code pending help rewrite.
  Added and implemented dynamic metadata search capability.
  
  
--matthew1083079450
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20040427112410.txt"

Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.216 loncom/interface/lonsearchcat.pm:1.217
--- loncom/interface/lonsearchcat.pm:1.216	Fri Apr 23 13:52:55 2004
+++ loncom/interface/lonsearchcat.pm	Tue Apr 27 11:24:09 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.216 2004/04/23 17:52:55 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.217 2004/04/27 15:24:09 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -405,8 +405,7 @@
 
 sub course_search {
     my $r=shift;
-    my $bodytag=&Apache::loncommon::bodytag('Course Search').
-	&Apache::loncommon::help_open_bug('Searching');
+    my $bodytag=&Apache::loncommon::bodytag('Course Search');
     my $pretty_search_string = '<b>'.$ENV{'form.courseexp'}.'</b>';
     my $search_string = $ENV{'form.courseexp'};
     my @New_Words;
@@ -504,13 +503,6 @@
 <html>
 <head>
 <title>The LearningOnline Network with CAPA</title>
-<script type="text/javascript">
-    function openhelp(val) {
-	openhelpwin=open('/adm/help/searchcat.html','helpscreen',
-	     'scrollbars=1,width=600,height=300');
-	openhelpwin.focus();
-    }
-</script>
 </head>
 ENDHEADER
     return $Str;
@@ -532,7 +524,7 @@
 sub print_basic_search_form {
     my ($r,$closebutton,$hidden_fields) = @_;
     my $bodytag=&Apache::loncommon::bodytag('Search').
-        &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Finding_Resources',
+        &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Searching',
                                             undef,undef,! $ENV{'form.launch'});
     my $scrout = &search_html_header().$bodytag;
     if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {
@@ -656,45 +648,46 @@
 ######################################################################
 sub print_advanced_search_form{
     my ($r,$closebutton,$hidden_fields) = @_;
+    my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search').
+        &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',
+                                            'Searching',
+                                            undef,undef,
+                                            ! $ENV{'form.launch'});
+
     my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
 				       'reset' => 'Reset',
 				       'help' => 'Help');
-    my $advanced_buttons = <<"END";
-<p>
+    my $advanced_buttons=<<"END";
 <input type="submit" name="advancedsubmit" value='$lt{"srch"}' />
 <input type="reset" name="reset" value='$lt{"reset"}' />
 $closebutton
-<input type="button" value="$lt{'help'}" onClick="openhelp()" />
 END
-    my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search').
-        &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',
-                                            'Finding_Resources',
-                                            undef,undef,
-                                            ! $ENV{'form.launch'});
-    my $searchhelp=&searchhelp();
     my $scrout=&search_html_header();
     $scrout .= <<"ENDHEADER";
 $bodytag
 <form method="post" action="/adm/searchcat" name="advsearch">
+<p>
 $advanced_buttons
 ENDHEADER
     $scrout.=('&nbsp;'x2).&viewoptions().'</p>'.$hidden_fields. 
         '<input type="hidden" name="phase" value="adv_search" />';
     my %fields=&Apache::lonmeta::fieldnames();
     #
-    $scrout.= '<p>'.$searchhelp.'</p>'.
-        "<table>\n";
+    $scrout .= '<h3>'.&mt('Standard Metadata').'</h3>';
+    $scrout .= "<table>\n";
+    $scrout .= '<tr><td>&nbsp;</td><td colspan="2"><font size="-1">'.
+        ('&nbsp;'x2).&searchhelp()."</font></td></tr>\n";
     my %related_word_search = 
-        ('title'=>1,
-         'author'=>0,
-         'owner'=>0,
-         'authorspace'=>0,
-         'modifyinguser'=>0,
-         'keywords'=>1,
-         'notes'=>1,
-         'abstract'=>1,
-         'standards'=>1,
-         'mime'=>1,
+        ('title'    => 1,
+         'author'   => 0,
+         'owner'    => 0,
+         'authorspace'  => 0,
+         'modifyinguser'=> 0,
+         'keywords' => 1,
+         'notes'    => 1,
+         'abstract' => 1,
+         'standards'=> 1,
+         'mime'     => 1,
          );
     #
     foreach my $field ('title','author','owner','authorspace','modifyinguser',
@@ -736,9 +729,79 @@
 	    &Apache::loncommon::domain_select('domains',
 						   $ENV{'form.domains'},1).
 	    '</td></tr>'.$/;
-    $scrout .= "</table>\n<br />";
+    #
+    # Misc metadata
+    $scrout.='<tr><td align="right" valign="top">'.
+	&titlefield(&mt('Copyright/Distribution')).'</td><td colspan="2">'.
+        &Apache::lonmeta::selectbox('copyright',
+                                    '',,
+                                    \&Apache::loncommon::copyrightdescription,
+                                    ( undef,
+                                      &Apache::loncommon::copyrightids)
+                                    ).'</td></tr>'.$/;
+    $scrout.='<tr><td align="right" valign="top">'.
+	&titlefield(&mt('Language')).'</td><td colspan="2">'.
+        &Apache::lonmeta::selectbox('language',
+                                    'notset',,
+                                    \&Apache::loncommon::languagedescription,
+                                    ('any',&Apache::loncommon::languageids)
+                                    ).'</td></tr>';
+    $scrout .= "</table>\n";    
+    #
+    # Dynamic metadata
+    $scrout .= '<h3>'.&mt('Problem Statistics').'</h3>';
+    $scrout .= "<table>\n";
+    $scrout .= '<tr><td>&nbsp;</td><td align="center">'.&mt('Minimum').'</td>'.
+        '<td align="center">'.&mt('Maximum').'</td></tr>'."\n";
+    foreach my $statistic 
+        ({ name=>'stdno',
+           description=>'Number of Students',},
+         { name => 'avetries',
+           description=>'Average tries to answer correctly',},
+         { name => 'difficulty',
+           description=>'Degree of difficulty',},
+         { name => 'disc',
+           description=>'Degree of discrimination'}) {
+        $scrout .= '<tr><td align="right">'.
+            &titlefield(&mt($statistic->{'description'})).
+            '</td><td align="center">'.
+            '<input type="text" name="'.$statistic->{'name'}.'_min" '.
+            'value="" size="6" />'.
+            '</td><td align="center">'.
+            '<input type="text" name="'.$statistic->{'name'}.'_max" '.
+            'value="" size="6" />'.
+            '</td></tr>'.$/;
+    }
+    $scrout .= "</table>\n";
+    $scrout .= '<h3>'.&mt('Evaluation Data').'</h3>';
+    $scrout .= "<table>\n";
+    $scrout .= '<tr><td>&nbsp;</td><td align="center">'.&mt('Minimum').'</td>'.
+        '<td align="center">'.&mt('Maximum').'</td></tr>'."\n";
+    foreach my $evaluation
+        ( { name => 'clear',
+            description => 'Material presented in clear way'},
+          { name =>'depth',
+            description => 'Material covered with sufficient depth'},
+          { name => 'helpful',
+            description => 'Material is helpful'},
+          { name => 'correct',
+            description => 'Material appears to be correct'},
+          { name => 'technical',
+            description => 'Resource is technically correct'}){
+        $scrout .= '<tr><td align="right">'.
+            &titlefield(&mt($evaluation->{'description'})).
+            '</td><td align="center">'.
+            '<input type="text" name="'.$evaluation->{'name'}.'_min" '.
+            'value="" size="6" />'.
+            '</td><td align="center">'.
+            '<input type="text" name="'.$evaluation->{'name'}.'_max" '.
+            'value="" size="6" />'.
+            '</td></tr>'.$/;
+    }
+    $scrout .= "</table>\n";
     #
     # Creation/Modification date limits
+    $scrout .= '<h3>'.&mt('Creation and Modification dates').'</h3>';
     $scrout .= "\n<table>\n";
     my $cafter = 
         &Apache::lonhtmlcommon::date_setter('advsearch',         # formname
@@ -1082,10 +1145,12 @@
 sub parse_advanced_search {
     my ($r,$closebutton,$hidden_fields)=@_;
     my @BasicFields = ('title','author','subject','keywords','url','version',
-                       'notes','abstract','extension','language','owner',
+                       'notes','abstract','extension','owner',
 #                       'custommetadata','customshow',
                        'modifyinguser','standards','mime');
-                       
+    my @StatsFields = ('stdno','avetries','difficulty','disc');
+    my @EvalFields = ('clear','depth','helpful','correct','technical');
+    my @ContextFields = ('courses','dependencies');
     my $fillflag=0;
     my $pretty_search_string = "<br />\n";
     # Clean up fields for safety
@@ -1198,6 +1263,31 @@
                 "<br \>\n";
     }
     #
+    # Statistics
+    foreach my $field (@StatsFields,@EvalFields) {
+        my ($min,$max);
+        if (exists($ENV{'form.'.$field.'_min'}) && 
+            $ENV{'form.'.$field.'_min'} ne '') {
+            $min = $ENV{'form.'.$field.'_min'};
+        }
+        if (exists($ENV{'form.'.$field.'_max'}) &&
+            $ENV{'form.'.$field.'_max'} ne '') {
+            $max = $ENV{'form.'.$field.'_max'};
+        }
+        next if (! defined($max) && ! defined($min));
+        if (defined($min) && defined($max)) {
+            ($min,$max) = sort {$a <=>$b} ($min,$max);
+        }
+        if (defined($min) && $min =~ /^(\d+\.\d+|\d+|\.\d+)$/) {
+            push(@queries,'('.$field.'>'.$min.')');
+            $pretty_search_string.=$font.$field.'</font>&gt;'.$min.'<br />';
+        }
+        if (defined($max) && $max =~ /^(\d+\.\d+|\d+|\.\d+)$/) {
+            push(@queries,'('.$field.'<'.$max.')');
+            $pretty_search_string.=$font.$field.'</font>&lt;'.$max.'<br />';
+        }
+    }
+    #
     # Evaluate date windows
     my $cafter =
         &Apache::lonhtmlcommon::get_date_from_form('creationdate1');
@@ -1262,6 +1352,7 @@
     } elsif ($customquery) {
         $query = '';
     }
+#    &Apache::lonnet::logthis('query = '.$/.$query);
     return ($query,$customquery,$customshow,$libraries_to_query,
             $pretty_search_string);
 }

--matthew1083079450--