cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mlattke
Instructure
Instructure

Good way to search content within a course?

Jump to solution

Does anyone have a good way to setup a search feature within a course?  I know that the Files tab has a search feature, but I'm looking more for content pages than files.  Here is the scenario.  We have a curriculum course with hundreds of pages of resources organized by grade level and subject.  A teacher can click through a series of buttons to browse to their desired resource, but the curriculum department wants teaches to be able to search for say "Poetry" and find all the pages on poetry.  I know this is not a built in feature, and I know I can submit a feature request, but I'm looking for an external tool or some other work around/clever idea that would let me do this in the short term.

Ideas I have thought of:

-Create an index page that lists all pages in a table of contents and use the browser search command on that page to locate a page. (downside -- hard to keep up as pages are added over time).

-Make sure pages are named with a clear naming convention and open the pages tab and use the browser search command on that page to locate a page. (downside -- when many pages are present, not all appear until you scroll, so you would not be able to search the ones that do not yet appear on the page using the browser search).

I don't think either of these ideas are particularly good, so I'm hoping that someone out there has an amazing idea for how to do this!

Thanks in advance!

ANOTHER THOUGHT:  Is it possible to use Google Site Search somehow?  I googled this, but couldn't find an answer.  😉

I thought maybe there was some custom javascript that could be embedded that would let site search crawl the pages.....anyone? anyone?

Message was edited by: Michelle Lattke

Tags (4)
2 Solutions

Accepted Solutions
orwinr
Community Champion

I have successfully integrated Google Custom Search into my Technology training resources site by creating an html file that includes the GCS javascript with a note telling users all results will open in a new tab. Once you have created the html file upload it to your course files area and use a module item to create a link to the html file you just uploaded. When you click on the link in the module you have a nice custom search page embedded in your course. If you want to take it further use the redirect LTI tool to create a link in the left navigation menu. You can see our example at: iSchool Technology Training and find the search link in the left nav menu.

The code that is currently in my search.html file is:

<p style="color: grey;">All results will open in a new tab or window.</p>

<div>

<script>

  (function() {

    var cx = 'your search engine ID goes here';

    var gcse = document.createElement('script');

    gcse.type = 'text/javascript';

    gcse.async = true;

    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +

        '//cse.google.com/cse.js?cx=' + cx;

    var s = document.getElementsByTagName('script')[0];

    s.parentNode.insertBefore(gcse, s);

  })();

</script>

<gcse:search linkTarget="_parent"></gcse:search>

</div>

I hope you find this useful until we get search functionality in courses themselves. Just a note that only the pages and announcements areas appear to be searchable via GCS, or at least that is what I am finding, which totally makes sense. I also believe that your course has to be public for Google to crawl it, which also takes some time to occur on new pages. You can change the behavior of the custom search script through your GCS management console.

Randy

View solution in original post

naren_salem
Community Participant

Hi Randy,

I love what you have done to embed the search. Your solution is perfect and I wanted to add "Search" to the sidebar using the Redirect. How were you able to get the redirect to open the search.html file you have uploaded to the course? I.e. how do I get the URL to enter into the Redirect plugin.

Thanks for the great solution!

Naren

View solution in original post

31 Replies
kona
Community Coach
Community Coach

Unfortunately I have no wonderful wisdom on this other than I'd love to have this feature and if you haven't already vote on this feature idea - !

Thanks for the link, Kona.  I hadn't seen that request and didn't find it when I searched the community, so I just voted it up!  That will be helpful for the future for sure if it turns into a real life thing.  I'm hoping maybe someone out there has a hack or creative idea.  It is a pipe dream, but there are so many smart people out there, I thought it was worth a shot!

James
Community Champion

I'm not exactly sure what you're looking for. I thought I knew (the title says search content, but your ideas are for searching page titles). Anyway, let me try throwing some ideas out and see if one sounds doable.

If you want to search the content of the pages ...

What if you downloaded all of the pages in a course and stored them in a single, really large, Word file. Then you could open up the word file and press Ctrl-F for find.

As part of my efforts to replace all the links to the old Guides with links to the new pages in the Community, I've already written the code that will obtain a list of all of the pages and then cycle through and download them one at a time. Right now, it just processes them internally, replacing the links, and then optionally replaces the existing page with the updated one. But that last portion of code could be modified to write them to a file.

If someone had the tools, there are indexing programs out there, and someone could populate the search tool with the pages rather than putting them into Word. I was just trying to make it (relatively) easy to do.

Another option would be to save the pages to your own local server and then have Google (or another search engine) index those pages.

You might also be able to do a course export into the common cartridge format. That's a zip file with a different extension. You could unzip it and have all of your files. However, someone posted earlier (I haven't verified) that you get random looking page names, so there might be more programming there to figure out everything than there would be to use the API.

If the list of words was predefined (like tags), then you could even create the index yourself as you download each page and not need to store the content of the pages.

If you just need to search the names of the pages ...

Life just got a whole lot easier. We can use the API call to get the list of pages and then write their titles with links into the course to a file. It could be Excel or Word or even an HTML file.

mpoole
Community Participant

I was able to create a google custom search that will search my course and return based on keyword and it seems to actually work well.  I just created the search and put my top level course URL as the site to be searched.  It returned files, page content, and assignments.

But, I don't know enough about the code side to know if I can then embed the search into my site in a way that is helpful.  I tried using the embed code generated and that doesn't work but I don't  know if it is something that could be converted to work within Canvas or not.

This is what the code looks like.

<script>

  (function() {

    var cx = '010804999352776858981:17kqd-2skl8';

    var gcse = document.createElement('script');

    gcse.type = 'text/javascript';

    gcse.async = true;

    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +

        '//cse.google.com/cse.js?cx=' + cx;

    var s = document.getElementsByTagName('script')[0];

    s.parentNode.insertBefore(gcse, s);

  })();

</script>

<gcse:search></gcse:search>

Here's the link to custom search engine

Hi James,

Sorry for my confusing wording!  Ideally, I would like to search the contents of the course/pages.  My very limited ideas (that didn't involve much intervention) were only ways to search titles, which is part of why I discarded both of them.  I was trying to list things I had already thought of so people would know where I was at.  But it sounds like that I made things less clear.  😉

You are awesome, because you have a lot of really amazing ideas for creatively solving the problem, which is exactly the kind of thinking I was hoping to find with this question!

I think some of the ideas may be beyond the scope of what I would be able to do in the short term, but it gives me a lot to think about!

Thanks again for sharing these ideas!

Michelle

 @mpoole ,

This is amazingly good news, and exactly what I was looking/hoping for.  I think if I could get that to work like you have described, I would be a seriously happy camper.

Before I added the Google bit to my question, I had tried to setup a custom search and to list the course URL  (as you describe), but it keeps returning no results when I search using the custom search page.  Did it take a few days for Google to index your course and for you to see results or did you get results right away?

Was there anything special you had to setup in your Google Account to make this work, or did you just add a new custom search, and it just worked?

The embed code you listed doesn't work b/c it is Javascript, and so it would get stripped out of a page, and you could only use it if you somehow incorporated it into the custom javascript file at the account or sub-account level.  However, you can totally link to the custom search page from within your course and pop it open in a new tab.

Thanks again!!!!

Michelle

mpoole
Community Participant

​I was able to search my course content right away And I didn't do anything special. Our canvas organization is pretty simple and my course is in the top rather than a sub, so that may have played a role? 

Hey  @mlattke ​​, I ran into the same issue you did when I tried this - no results when I search for stuff I know is there. 😕 But this is an awesome enough tool that I'm going to keep poking at it to see if I can get it to work the way  @mpoole ​ has it - and I'll share here if I discover anything.

Thanks,  @G_Petruzella ​!  I'm glad to know I'm not the only one!  Smiley Wink

I agree -- knowing it works for Melissa gives me hope to keep trying!

I tried making the course public to see if that would work, and I still get no results.

I'm going to keep at it too, and I will let you know if I figure anything out as well!!