version 1.218, 2004/04/27 15:45:04
|
version 1.222, 2004/05/05 14:14:10
|
Line 117 sub handler {
|
Line 117 sub handler {
|
|
|
my $loaderror=&Apache::lonnet::overloaderror($r); |
my $loaderror=&Apache::lonnet::overloaderror($r); |
if ($loaderror) { return $loaderror; } |
if ($loaderror) { return $loaderror; } |
|
# |
my $closebutton; # button that closes the search window |
my $closebutton; # button that closes the search window |
# This button is different for the RAT compared to |
# This button is different for the RAT compared to |
# normal invocation. |
# normal invocation. |
Line 185 sub handler {
|
Line 185 sub handler {
|
bug=>'Searching',}); |
bug=>'Searching',}); |
} |
} |
# |
# |
if (! &get_persistent_form_data($persistent_db_file)) { |
if ($ENV{'form.phase'} !~ m/(basic|adv|course)_search/) { |
if ($ENV{'form.phase'} =~ /(run_search|results)/) { |
if (! &get_persistent_form_data($persistent_db_file)) { |
&Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". |
if ($ENV{'form.phase'} =~ /(run_search|results)/) { |
"from $persistent_db_file"); |
&Apache::lonnet::logthis('lonsearchcat:'. |
$r->print(<<END); |
'Unable to recover data from '. |
|
$persistent_db_file); |
|
$r->print(<<END); |
<html> |
<html> |
<head><title>LON-CAPA Search Error</title></head> |
<head><title>LON-CAPA Search Error</title></head> |
$bodytag |
$bodytag |
Line 198 error and has been logged. Please alert
|
Line 200 error and has been logged. Please alert
|
</body> |
</body> |
</html> |
</html> |
END |
END |
return OK; |
return OK; |
|
} |
} |
} |
|
} else { |
|
&clean_up_environment(); |
} |
} |
## |
## |
## Clear out old values from groupsearch database |
## Clear out old values from groupsearch database |
Line 286 END
|
Line 291 END
|
$ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'})); |
$ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'})); |
$ENV{'form.show'} = 20 if (! exists($ENV{'form.show'})); |
$ENV{'form.show'} = 20 if (! exists($ENV{'form.show'})); |
# |
# |
$ENV{'form.searchmode'} = 'basic'; |
$ENV{'form.searchmode'} = 'basic' if (! exists($ENV{'form.searchmode'})); |
if ($ENV{'form.phase'} eq 'adv_search' || |
if ($ENV{'form.phase'} eq 'adv_search' || |
$ENV{'form.phase'} eq 'disp_adv') { |
$ENV{'form.phase'} eq 'disp_adv') { |
$ENV{'form.searchmode'} = 'advanced'; |
$ENV{'form.searchmode'} = 'advanced'; |
Line 389 END
|
Line 394 END
|
return OK; |
return OK; |
} |
} |
|
|
|
# |
|
# The mechanism used to store values away and retrieve them does not |
|
# handle the case of missing environment variables being significant. |
|
# |
|
# This routine sets non existant checkbox form elements to ''. |
|
# |
|
sub clean_up_environment { |
|
if ($ENV{'form.phase'} eq 'basic_search') { |
|
if (! exists($ENV{'form.related'})) { |
|
$ENV{'form.related'} = ''; |
|
} |
|
if (! exists($ENV{'form.domains'})) { |
|
$ENV{'form.domains'} = ''; |
|
} |
|
} elsif ($ENV{'form.phase'} eq 'adv_search') { |
|
foreach my $field ('title','keywords','notes', |
|
'abstract','standards','mime') { |
|
if (! exists($ENV{'form.'.$field.'_related'})) { |
|
$ENV{'form.'.$field.'_related'} = ''; |
|
} |
|
} |
|
} elsif ($ENV{'form.phase'} eq 'course_search') { |
|
if (! exists($ENV{'form.crsrelated'})) { |
|
$ENV{'form.crsrelated'} = ''; |
|
} |
|
} |
|
} |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
## |
## |
Line 532 sub print_basic_search_form {
|
Line 565 sub print_basic_search_form {
|
my $userelatedwords= |
my $userelatedwords= |
&mt('[_1] use related words', |
&mt('[_1] use related words', |
&Apache::lonhtmlcommon::checkbox |
&Apache::lonhtmlcommon::checkbox |
('related',$ENV{'form.related'})); |
('related',$ENV{'form.related'},'related')); |
my $onlysearchdomain= |
my $onlysearchdomain= |
&mt('[_1] only search domain [_2]', |
&mt('[_1] only search domain [_2]', |
&Apache::lonhtmlcommon::checkbox |
&Apache::lonhtmlcommon::checkbox('domains', |
('domains',$ENV{'form.domains'}), |
$ENV{'form.domains'}, |
$r->dir_config('lonDefDomain')); |
$r->dir_config('lonDefDomain') |
|
), |
|
$r->dir_config('lonDefDomain') |
|
); |
my $adv_search_link = |
my $adv_search_link = |
'<a href="/adm/searchcat?'. |
'<a href="/adm/searchcat?'. |
'phase=disp_adv&'. |
'phase=disp_adv&'. |
Line 754 ENDHEADER
|
Line 790 ENDHEADER
|
$scrout .= '<tr><td> </td><td align="center">'.&mt('Minimum').'</td>'. |
$scrout .= '<tr><td> </td><td align="center">'.&mt('Minimum').'</td>'. |
'<td align="center">'.&mt('Maximum').'</td></tr>'."\n"; |
'<td align="center">'.&mt('Maximum').'</td></tr>'."\n"; |
foreach my $statistic |
foreach my $statistic |
({ name=>'stdno', |
({ name=>'count', |
description=>'Number of Students',}, |
description=>'Network-wide number of accesses (hits)',}, |
|
{ name=>'stdno', |
|
description=> |
|
'Total number of students who have worked on this problem',}, |
{ name => 'avetries', |
{ name => 'avetries', |
description=>'Average tries to answer correctly',}, |
description=>'Average number of tries till solved',}, |
{ name => 'difficulty', |
{ name => 'difficulty', |
description=>'Degree of difficulty',}, |
description=>'Degree of difficulty',}, |
{ name => 'disc', |
{ name => 'disc', |
Line 1148 sub parse_advanced_search {
|
Line 1187 sub parse_advanced_search {
|
'notes','abstract','extension','owner', |
'notes','abstract','extension','owner', |
# 'custommetadata','customshow', |
# 'custommetadata','customshow', |
'modifyinguser','standards','mime'); |
'modifyinguser','standards','mime'); |
my @StatsFields = ('stdno','avetries','difficulty','disc'); |
my @StatsFields = &statfields(); |
my @EvalFields = ('clear','depth','helpful','correct','technical'); |
my @EvalFields = &evalfields(); |
my $fillflag=0; |
my $fillflag=0; |
my $pretty_search_string = "<br />\n"; |
my $pretty_search_string = "<br />\n"; |
# Clean up fields for safety |
# Clean up fields for safety |
Line 1161 sub parse_advanced_search {
|
Line 1200 sub parse_advanced_search {
|
'lastrevisiondatestart_year','lastrevisiondateend_month', |
'lastrevisiondatestart_year','lastrevisiondateend_month', |
'lastrevisiondateend_day','lastrevisiondateend_year') { |
'lastrevisiondateend_day','lastrevisiondateend_year') { |
$ENV{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
$ENV{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\']//g; |
|
$ENV{'form.'.$field}=~s/(not\s*$|^\s*(and|or)|)//gi; |
} |
} |
foreach ('mode','form','element') { |
foreach ('mode','form','element') { |
# is this required? Hmmm. |
# is this required? Hmmm. |
Line 1173 sub parse_advanced_search {
|
Line 1213 sub parse_advanced_search {
|
ref($ENV{'form.category'})); |
ref($ENV{'form.category'})); |
# |
# |
# Check to see if enough information was filled in |
# Check to see if enough information was filled in |
for my $field (@BasicFields) { |
foreach my $field (@BasicFields) { |
if (&filled($ENV{'form.'.$field})) { |
if (&filled($ENV{'form.'.$field})) { |
$fillflag++; |
$fillflag++; |
} |
} |
} |
} |
|
foreach my $field (@StatsFields,@EvalFields) { |
|
if (&filled($ENV{'form.'.$field.'_max'})) { |
|
$fillflag++; |
|
} |
|
if (&filled($ENV{'form.'.$field.'_min'})) { |
|
$fillflag++; |
|
} |
|
} |
|
|
for my $field ('lowestgradelevel','highestgradelevel') { |
for my $field ('lowestgradelevel','highestgradelevel') { |
if ( $ENV{'form.'.$field} =~ /^\d+$/ && |
if ( $ENV{'form.'.$field} =~ /^\d+$/ && |
$ENV{'form.'.$field} > 0) { |
$ENV{'form.'.$field} > 0) { |
Line 1360 sub parse_domain_restrictions {
|
Line 1409 sub parse_domain_restrictions {
|
my $libraries_to_query = undef; |
my $libraries_to_query = undef; |
# $ENV{'form.domains'} can be either a scalar or an array reference. |
# $ENV{'form.domains'} can be either a scalar or an array reference. |
# We need an array. |
# We need an array. |
if (! exists($ENV{'form.domains'})) { |
if (! exists($ENV{'form.domains'}) || $ENV{'form.domains'} eq '') { |
return (undef,''); |
return (undef,''); |
} |
} |
my @allowed_domains; |
my @allowed_domains; |
Line 1425 sub parse_basic_search {
|
Line 1474 sub parse_basic_search {
|
&parse_domain_restrictions(); |
&parse_domain_restrictions(); |
# |
# |
# Check to see if enough of a query is filled in |
# Check to see if enough of a query is filled in |
unless (&filled($ENV{'form.basicexp'})) { |
my $search_string = $ENV{'form.basicexp'}; |
|
$search_string =~ s/(not\s*$|^\s*(and|or)|)//gi; |
|
if (! &filled($search_string)) { |
&output_blank_field_error($r,$closebutton,'phase=disp_basic'); |
&output_blank_field_error($r,$closebutton,'phase=disp_basic'); |
return OK; |
return OK; |
} |
} |
my $pretty_search_string = '<b>'.$ENV{'form.basicexp'}.'</b>'; |
my $pretty_search_string = '<b>'.$ENV{'form.basicexp'}.'</b>'; |
my $search_string = $ENV{'form.basicexp'}; |
|
if ($ENV{'form.related'}) { |
if ($ENV{'form.related'}) { |
my @New_Words; |
my @New_Words; |
($search_string,@New_Words) = &related_version($ENV{'form.basicexp'}); |
($search_string,@New_Words) = &related_version($ENV{'form.basicexp'}); |
Line 2836 sub detailed_citation_view {
|
Line 2886 sub detailed_citation_view {
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
|
sub has_stat_data { |
|
my ($values) = @_; |
|
if ( (defined($values->{'count'}) && $values->{'count'} ne '') || |
|
(defined($values->{'stdno'}) && $values->{'stdno'} ne '') || |
|
(defined($values->{'disc'}) && $values->{'disc'} ne '') || |
|
(defined($values->{'avetries'}) && $values->{'avetries'} ne '') || |
|
(defined($values->{'difficulty'}) && $values->{'difficulty'} ne '')) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub statfields { |
|
return ('count','stdno','disc','avetries','difficulty'); |
|
} |
|
|
|
sub has_eval_data { |
|
my ($values) = @_; |
|
if ( (defined($values->{'clear'}) && $values->{'clear'} ne '') || |
|
(defined($values->{'technical'}) && $values->{'technical'} ne '') || |
|
(defined($values->{'correct'}) && $values->{'correct'} ne '') || |
|
(defined($values->{'helpful'}) && $values->{'helpful'} ne '') || |
|
(defined($values->{'depth'}) && $values->{'depth'} ne '')) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub evalfields { |
|
return ('clear','technical','correct','helpful','depth'); |
|
} |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
=pod |
=pod |
|
|
=item &summary_view() |
=item &summary_view() |
Line 2896 END
|
Line 2981 END
|
sub fielded_format_view { |
sub fielded_format_view { |
my ($prefix,%values) = @_; |
my ($prefix,%values) = @_; |
my $icon=&Apache::loncommon::icon($values{'url'}); |
my $icon=&Apache::loncommon::icon($values{'url'}); |
|
my %Translated = &Apache::lonmeta::fieldnames(); |
my $result=<<END; |
my $result=<<END; |
$prefix <img src="$icon" /> |
$prefix <img src="$icon" /> |
<b>URL: </b> <a href="http://$ENV{'HTTP_HOST'}$values{'url'}" |
<dl> |
target='search_preview'>$values{'url'}</a> |
<dt>URL:</dt> |
<br /> |
<dd><a href="http://$ENV{'HTTP_HOST'}$values{'url'}" |
<b>Title:</b> $values{'title'}<br /> |
target='search_preview'>$values{'url'}</a></dd> |
<b>Author(s):</b> $values{'author'}<br /> |
|
<b>Subject:</b> $values{'subject'}<br /> |
|
<b>Keyword(s):</b> $values{'keywords'}<br /> |
|
<b>Notes:</b> $values{'notes'}<br /> |
|
<b>MIME Type:</b> $values{'mimetag'}<br /> |
|
<b>Language:</b> $values{'language'}<br /> |
|
<b>Creation Date:</b> $values{'creationdate'}<br /> |
|
<b>Last Revision Date:</b> $values{'lastrevisiondate'}<br /> |
|
<b>Publisher/Owner:</b> $values{'owner'}<br /> |
|
<b>Copyright/Distribution:</b> $values{'copyrighttag'}<br /> |
|
<b>Repository Location:</b> $values{'hostname'}<br /> |
|
<b>Abstract:</b> $values{'shortabstract'}<br /> |
|
$values{'extrashow'} |
|
</p> |
|
<hr align='left' width='200' noshade /> |
|
END |
END |
|
foreach my $field ('title','author','subject','keywords','notes', |
|
'mimetag','language','creationdate','lastrevisiondate', |
|
'owner','copyrighttag','hostname','abstract') { |
|
$result .= (' 'x4).'<dt>'.$Translated{$field}.'</dt>'."\n". |
|
(' 'x8).'<dd>'.$values{$field}.'</dd>'."\n"; |
|
} |
|
if (&has_stat_data(\%values)) { |
|
foreach my $field (&statfields()) { |
|
$result .= (' 'x4).'<dt>'.$Translated{$field}.'</dt>'."\n". |
|
(' 'x8).'<dd>'.$values{$field}.'</dd>'."\n"; |
|
} |
|
} |
|
if (&has_eval_data(\%values)) { |
|
foreach my $field (&evalfields()) { |
|
$result .= (' 'x4).'<dt>'.$Translated{$field}.'</dt>'."\n". |
|
(' 'x8).'<dd>'.$values{$field}.'</dd>'."\n"; |
|
} |
|
} |
|
$result .= "</dl>\n"; |
|
$result .= $values{'extrashow'}; |
|
$result .= '<hr align="left" width="200" noshade />'."\n"; |
return $result; |
return $result; |
} |
} |
|
|
Line 2936 END
|
Line 3028 END
|
###################################################################### |
###################################################################### |
sub xml_sgml_view { |
sub xml_sgml_view { |
my ($prefix,%values) = @_; |
my ($prefix,%values) = @_; |
my $xml = <<END; |
my $xml = '<LonCapaResource>'."\n"; |
<LonCapaResource> |
# The usual suspects |
<url>$values{'url'}</url> |
foreach my $field ('url','title','author','subject','keywords','notes') { |
<title>$values{'title'}</title> |
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
<author>$values{'author'}</author> |
} |
<subject>$values{'subject'}</subject> |
# |
<keywords>$values{'keywords'}</keywords> |
$xml .= "<mimeInfo>\n"; |
<notes>$values{'notes'}</notes> |
foreach my $field ('mime','mimetag') { |
<mimeInfo> |
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
<mime>$values{'mime'}</mime> |
} |
<mimetag>$values{'mimetag'}</mimetag> |
$xml .= "</mimeInfo>\n"; |
</mimeInfo> |
# |
<languageInfo> |
$xml .= "<languageInfo>\n"; |
<language>$values{'language'}</language> |
foreach my $field ('language','languagetag') { |
<languagetag>$values{'languagetag'}</languagetag> |
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
</languageInfo> |
} |
<creationdate>$values{'creationdate'}</creationdate> |
$xml .= "</languageInfo>\n"; |
<lastrevisiondate>$values{'lastrevisiondate'}</lastrevisiondate> |
# |
<owner>$values{'owner'}</owner> |
foreach my $field ('creationdate','lastrevisiondate','owner') { |
<copyrightInfo> |
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
<copyright>$values{'copyright'}</copyright> |
} |
<copyrighttag>$values{'copyrighttag'}</copyrighttag> |
# |
</copyrightInfo> |
$xml .= "<copyrightInfo>\n"; |
<repositoryLocation>$values{'hostname'}</repositoryLocation> |
foreach my $field ('copyright','copyrighttag') { |
<shortabstract>$values{'shortabstract'}</shortabstract> |
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
</LonCapaResource> |
} |
END |
$xml .= "</copyrightInfo>\n"; |
|
$xml .= qq{<repositoryLocation>$values{'hostname'}</repositoryLocation>}. |
|
"\n"; |
|
$xml .= qq{<shortabstract>$values{'shortabstract'}</shortabstract>}."\n"; |
|
# |
|
if (&has_stat_data(\%values)){ |
|
$xml .= "<problemstatistics>\n"; |
|
foreach my $field (&statfields()) { |
|
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
|
} |
|
$xml .= "</problemstatistics>\n"; |
|
} |
|
# |
|
if (&has_eval_data(\%values)) { |
|
$xml .= "<evaluation>\n"; |
|
foreach my $field (&evalfields) { |
|
$xml .= qq{<$field>$values{$field}</$field>}."\n"; |
|
} |
|
$xml .= "</evaluation>\n"; |
|
} |
|
# |
|
$xml .= "</LonCapaResource>\n"; |
$xml = &HTML::Entities::encode($xml,'<>&'); |
$xml = &HTML::Entities::encode($xml,'<>&'); |
my $result=<<END; |
my $result=<<END; |
$prefix |
$prefix |