Search functionality for a Canvas course with no backend databases or servers and minimal dependencies.
Tested on Chrome 83.0.
Built using lunr.js.
Content from Quercus Support Resources, University of Toronto.
Uses the Canvas API provided by Instructure.
Up to date source code on GitHub.
var courseURL
- Link to the Canvas Courses API for a single course.
link.download
- Name of the downloaded JSON file.
None
gtag
- Google Analytics Property ID. Used in 4 separate instances.
iframe src
- Download link to the qsr_search.html
file uploaded within the Canvas course. Can only be retrieved after the file has actually been uploaded to the Canvas course's Files.
Make sure the variables above are updated and corrected before proceeding.
- Copy entire contents of
qsr_search_getPages.js
. - Using Chrome, sign into Canvas and open the Developer Console (F12).
- Paste the code and press Enter.
- Verify that the ouput displays
"SUCCESS: ..."
andqsr_search_pages.json
is automatically downloaded. - Copy entire contents of
qsr_search_pages.json
and paste intovar pages
inqsr_search.html
. - Upload
qsr_search.html
into Canvas course. - In a new or existing Canvas Page, insert the iframe code from
qsr_page_iframe.html
. - Test the search functionality in the Canvas Page.
As this tool does not have a backend, the search index data must be manually updated as needed.
See Update QSR Search.docx or watch a video tutorial for more info.