-
Notifications
You must be signed in to change notification settings - Fork 1
Home
The plugin was developed to provide a search field for text search in Moodle books with image-based slides. The plugin requires that a PDF of (almost) the same name is present in the same course section. The pages of the PDF need to correspond 1-1 to the pages in the book. Names of book and PDF need to be identical, except for text specified in brackets inside their names.
The plugin searches all PDFs for the text and then displays the search results as a list of links. Clicking on a link shows the respective page with the corresponding number inside the book.
In order for books and PDF files to be searchable via the booksearch, a few requirements must be met. The PDF and the book must be in the same section and the name must not differ except for text within () or [].
First activate the "Edit mode", the switch is located in the course view as well as on your dashboard, top right.
Next, open the "block drawer" by clicking on the marked button. Then, from the "block drawer" select "Booksearch".
You can now exit "Edit mode" again.
To use the block, open the "block drawer" in the course view or your dashboard. In the course view you can use the search function immediately, in the dashboard you first have to select a course you want to search via a dropdown menu.
Now you can get started and enter any terms in the search field. The result is displayed immediately and updates automatically. Results contain the name of the book/pdf, a link to the chapter and a small excerpt from the passage found.
To configure the web service, follow the instructions under Site administration > Server > Web services > Overview.
A request to the web service is made by a GET request to the following URL:
http://YourMoodleDomain/webservice/rest/server.php?wstoken=User-token&wsfunction=block_booksearch_get_searched_locations&moodlewsrestformat=json&search_string=Search&course_id=Course-ID&context_length=Excerpt-length
- YourMoodleDomain: Domain of your Moodle installation (core URL).
- User-token: User token created by Moodle during the web service configuration (previous step).
- Search: The word/letter string/phrase to search for.
- Course-ID: ID of the course to search in.
- Excerpt-length: The number of words to return as a context snippet.
Add a block to either your dashboard or a course.
If you are on your dashboard, you will have to first select the course you want to search in (this will trigger a site reload) using a dropdown menu.
You can use the input field to search for a text snippet you want to see results for. The results will get updated automatically.
The results will be displayed in the block just below the search bar and will update automatically. They are ordered under PDF/Book source and link to the respective book chapter.
To configure the web service, follow the instructions on Site Administration > Server > Web services > Overview to register the web service and set the right for a specified user to use it. This involves the following steps:
- Enable web services
- Enable protocols: Her, enable the REST protocol if not already enabled.
- Create a specified user
- Check user capability: The specified user has to have at least the webservice/rest:use capability.
- Select a service: Add the "Book Search" to custom services.
- Add functions: Add the "block_booksearch_get_searched_locations" function to the "Book Search" service.
- Select a specified user: Add the web services user as an authorised user.
- Create a token for a user: Create a token for the web services user.
Test it by sending an http GET request to 'http://[yourmoodle]/webservice/rest/server.php?wstoken=[user-token]&wsfunction=block_booksearch_get_searched_locations&moodlewsrestformat=json&search_string=[search_string]&course_id=[course_id]&context_length=[context_length]' where
- yourmoodle: domain of your moodle installation (as developer: probably localhost)
- user-token: token received from moodle for a user which is allowed to use the web service
- search_string: the search string which is used to search in moodle books and pdfs
- course_id: the id of the course the string is searched in
- context_length: the number of word before and after each found string
- Log in to your Moodle site as an admin and go to Site administration > Plugins > Install plugins.
- Upload the ZIP file with the plugin code. You should only be prompted to add extra details if your plugin type is not automatically detected.
- Check the plugin validation report and finish the installation.
The plugin can be also installed by putting the contents of this directory to
{your/moodle/dirroot}/blocks/booksearch
Afterwards, log in to your Moodle site as an admin and go to Site administration > Notifications to complete the installation.
Alternatively, you can run
$ php admin/cli/upgrade.php
to complete the installation from the command line.
Book Search plug-in relies on pdfparser package to extract data from PDF files. Pdfparser is a standalone PHP package under LGPLv3 license (see above: thirdpartylibs.xml for more details).
2022 Universtity of Stuttgart [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.