--- loncom/interface/lonsearchcat.pm 2004/07/19 16:38:07 1.231 +++ loncom/interface/lonsearchcat.pm 2004/08/20 15:45:51 1.232 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.231 2004/07/19 16:38:07 raeburn Exp $ +# $Id: lonsearchcat.pm,v 1.232 2004/08/20 15:45:51 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2633,10 +2633,74 @@ sub display_results { &hidden_field('persistent_db_id'). &hidden_field('start') ); + # + # Build sorting selector + my @field_order = ('default', + 'title', + 'author', + 'subject', + 'url', + 'keywords', + 'version', + 'language', + 'creationdate'=>, + 'lastrevisiondate', + 'owner', + 'copyright', + 'authorspace', + 'lowestgradeleve', + 'highestgradelevel', + 'standards', + 'count', + 'stdno', + 'avetries', + 'difficulty', + 'disc', + 'clear', + 'technical', + 'correct', + 'helpful', + 'depth', + ); + my %sort_fields = ('default' => 'Default', + 'title' => 'Title', + 'author' => 'Author', + 'subject' => 'Subject', + 'url' => 'URL', + 'keywords' => 'Keywords', + 'version' => 'Version', + 'language' => 'Language', + 'creationdate'=> 'Creation Date', + 'lastrevisiondate' => 'Last Revision Date', + 'owner' => 'Owner', + 'copyright' => 'Copyright', + 'authorspace' => 'Authorspace', + 'lowestgradeleve' => 'Lowest Grade Level', + 'highestgradelevel' => 'Highest Grade Level', + 'standards' => 'Standards', + 'count' => 'Number of Accesses', + 'stdno' => 'Students Attempting', + 'avetries' => 'Average Number of Tries', + 'difficulty' => 'Mean Degree of Difficulty', + 'disc' => 'Mean Degree of Discrimination', + 'clear' => 'Evaluation: Clear', + 'technical' => 'Evaluation: Technically Correct', + 'correct' => 'Evaluation: Material is Correct', + 'helpful' => 'Evaluation: Material is Helpful', + 'depth' => 'Evaluation: Material has Depth', + 'select_form_order' => \@field_order, + ); + + my $sortform = &mt('Sort by [_1]', + &Apache::loncommon::select_form($ENV{'form.sortfield'}, + 'sortfield', + %sort_fields)); ## ## Output links (if necessary) for 'prev' and 'next' pages. $r->print - ('
'. + ('
'. + $sortform. + ''. &prev_next_buttons($min,$ENV{'form.show'},$total_results). ''. &viewoptions().'
' @@ -2647,13 +2711,21 @@ sub display_results { ""); return; } else { - $r->print - ("
Results $min to $max out of $total_results
\n"); + $r->print('
'. + mt('Results [_1] to [_2] out of [_3]', + $min,$max,$total_results). + "
\n"); } ## ## Get results from MySQL table - my @Results = &Apache::lonmysql::get_rows($table, - 'id>='.$min.' AND id<='.$max); + my $sort_command = 'id>='.$min.' AND id<='.$max; + if ($ENV{'form.sortfield'} ne 'default' && + exists($sort_fields{$ENV{'form.sortfield'}})) { + $sort_command = $ENV{'form.sortfield'}.' IS NOT NULL '. + 'ORDER BY '.$ENV{'form.sortfield'}. + ' LIMIT '.($min-1).','.($max-$min); + } + my @Results = &Apache::lonmysql::get_rows($table,$sort_command); ## ## Loop through the results and output them. foreach my $row (@Results) {