the new search - suggestion

the new search - suggestion

by Przemyslaw Stencel -
Number of replies: 19
Martin, I've noticed you're planning to re-design the search function. May I suggest that apart from implementing the search strings this new search could allow for searching of messages by the author?
Average of ratings: -
In reply to Przemyslaw Stencel

Re: the new search - suggestion

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Exactly, that is being done.  The format is

   user:stencel

There will also be other custom fields for each module, eg:

   Forums:       subject:Design
   Resources:   summary:Web
   Glossaries:   concept:PHP

People won't have to type these, there'll be a better GUI for it to get around the language problem.

The first version will focus on forums and I'm hoping will be in 1.4, but the function will be made to be generically available for other modules and later a site-wide search.
In reply to Martin Dougiamas

Re: the new search - suggestion

by Przemyslaw Stencel -

Thanks smile, but...

There is a saying in Polish (I don't know what the English equivalent could be, but I'm sure you'll get the meaning wink):

Give them a finger and they will ask you for the hand

So:
How about narrowing a search down to a particular forum? For example, if I wanted to find all messages by a person in a particular forum? Will this be possible as well?

In reply to Przemyslaw Stencel

Re: the new search - suggestion

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
How about I just give you the finger?   wink  surprise  lol

Seriously, that is something we should have,
In reply to Przemyslaw Stencel

Re: the new search - suggestion

by Ray Lawrence -
"Give them an inch and they'll take a mile" is the local equivalent around this neck of the woods. smile
In reply to Martin Dougiamas

Re: the new search - suggestion

by David Scotson -

I've got a Google Search block (attached) that I've been tinkering around with.

It's not much use to us, as all our courses prevent guest and Googlebot access, but it might be helpful for moodle.org and similar open sites.

It's simply the code that Google provides to webmasters for site search stuck into a block. It leverages the full power of Google search but has some limitations for this application:

  • the site needs its own domain, moodle.org should be fine, or moodle.yourdomain.edu, but restricting searches to yourdomain.edu/moodle/science isn't possible with Google.
  • it searches all public Moodle courses (and other webpages) in your domain, you can't restrict searches to a single course e.g. Using Moodle, unless you put the course title into the seach

but it does have some nice features too:

  • It searches anything it finds including static documents (HTML and PDF etc. included), forums, glossaries, profiles etc.
  • You get some benifit from Google's relevance ranking
  • You can sign up and customise your search results page to match your site and remove the Google ads as a public service if you are non-profit or educational

I've got some future plans:

  • safe-search option
  • automatically reverting to standard web only search if the site is private
  • localized and language specific search

but I think this might be useful on moodle.org even as it is. You can play around with it on our development site (I've hard coded it to search moodle.org). Searching for common Moodle error messages like "memory exhausted" gives good results but more general terms like "search" are less useful as it doesn't only search content (though I suppose that is a double edged sword).

Average of ratings: Useful (1)
In reply to David Scotson

Re: the new search - suggestion

by David Scotson -

I've made a couple of improvements:

  • it now hides the sitesearch option if your Moodle is closed to Google, leaving a simple Google web search.

  • it has a 'search only in my language' option that is useful in sites like moodle.org with multiple languages and no expectation that users will be able to read all of them. (It's not generally useful, I think, so I've left it commented out.)

In reply to David Scotson

Re: the new search - suggestion

by David Scotson -
I've made a couple more changes in case anyone's using this. It now fits in better with moodle theme's and is less Google branded (like Martin's implementation on Moodle.org). It also still acts as a simple Google Search for closed sites, and allows the choice of searching the web with Google.
In reply to David Scotson

Re: the new search - suggestion

by W Page -
Hi David!

I have not installed the Moodle-Google Search block as of yet. I am unclear about this. If anyone runs a Moodle-Google Search does that open my site up to Google to index the site and make the course files and User Profiles public?

WP1
In reply to W Page

Re: the new search - suggestion

by David Scotson -

If you want it to, yes, but you have to set an admin configuration option called opentogoogle and this defaults to no.

My Google block checks this variable, and if your site is closed to Google, it only allow you to search the web, since Google won't have any of your Moodle site indexed. But if Google is allowed access to your site, it gives you the option to search either your local domain or the web.

In reply to David Scotson

Re: the new search - suggestion

by Steve Relf -

Hi i have just installed this version of the block,

it works great exepect the block is named google is their anyway to change this, i have had a trawl through the PHP code but cant seem to sort it,

thanks in advance

Steve

In reply to Steve Relf

Re: the new search - suggestion

by David Scotson -

That's what happens when you don't have any languages defined for an element of Moodle. Every time there's a bit of code like this:

get_string('google', 'block_google');

It looks for the first string in a php file named for the second string (block_google.php in this case). A range of these files can be seen in the /lang/en/ (for english) directory.

So you could create a block_google.php file and add your own text, however, I believe that Martin's implementation of Google search, as seen on Moodle.org, is in CVS so you may prefer to use that.

And there is also a more advanced version that takes advantage of the Google API to display the search results within your Moodle that you may like to have a look at. There's [a post about it here].

In case anyone is intersted I discoverd a way around one of the drawbacks I listed above, namely that you can search within subdomains by using *inurl e.g. seaching for the following on Google

site:moodle.org inurl:moodle.org/mod/forum/

only returns hits from Moodle.org that have `moodle.org/mod/forum in the URL i.e. the content of forums and:

site:moodle.gla.ac.uk inurl:/guide/moodle

only returns hits (though not many because it's not open to the public) from one of the several moodle's hosted at moodle.gla.ac.uk with different urls of the form moodle.gla.ac.uk//moodle

In reply to David Scotson

Re: the new search - suggestion

by Anil Sharma -

Need help on your post above.  First, the hyperlink the the mentioned post on Goggle API is missing in your post.

Next, the google search block is important for us, if you could just give us the string to add to the moodle.php file in lang, would appreciate.

Thx

In reply to David Scotson

Re: the new search - suggestion

by Junaid Haroon -
you missed the major limitation...

google searches its cache of websites and never the real websites and the cache is remade every month for active sites so the results are not live. also google sometimes does not go too deep into the site missing some pages though its less often for active sites. however google does have a paid service where it refreshes the cache very often upto many times a day and caches the whole site. therefore google search cannot replace a comprehensive site search within moodle.
Average of ratings: Useful (1)
In reply to David Scotson

Re: the new search - suggestion

by Penny Leach -
Hi David - I couldn't see this block in contrib - are there any plans for it to go there? I would like to deploy it but it really helps if I can track it with some sort of version control.

Edit - I just downloaded the most recent version in this thread and it wouldn't work the latest 1.5.2 + - blocklib seems to think it's not compatible and wouldn't install it:

 
// Returns false if this block is incompatible with the current version of Moodle.
function block_is_compatible($blockname) {
global $CFG;

$file = file($CFG->dirroot.'/blocks/'.$blockname.'/block_'.$blockname.'.php');
if(empty($file)) {
return NULL;
}

foreach($file as $line) {
// If you find MoodleBlock (appearing in the class declaration) it's not compatible
if(strpos($line, 'MoodleBlock')) {
return false;
}
// But if we find a { it means the class declaration is over, so it's compatible
else if(strpos($line, '{')) {
return true;
}
}

return NULL;
}

Your block subclasses MoodleBlock, so the compatibility test failed sad
In reply to Penny Leach

Re: the new search - suggestion

by John Papaioannou -
Definitely needs to be updated for 1.5... blocklib doesn't install it because that would kill Moodle with a fatal error.
In reply to John Papaioannou

Re: the new search - suggestion

by Teemu Sumi -
contrib/block_googleapi_search is not same as that block used by moodle.org. Where can I find that version used by moodle.org?


thoughtful Teemu