cancel
Showing results for 
Search instead for 
Did you mean: 
sam_ofloinn
Community Participant

Find a Course by SIS Course ID, when given only part of that SIS ID?

Jump to solution

In my custom application, I have a program that successfully searches for and finds a course when given its SIS Course ID. Using this code written in PHP Laravel:

$sis_course_id = $request->sis_course_id; //gets the SIS Course ID
$courseURL = "https://my.instructure.com/api/v1/courses/sis_course_id:$sis_course_id"; //parsed into a cURL request, gets the data from this endpoint with the matching SIS Course ID.

This code works perfectly if I have the precise SIS Course ID as saved in the Canvas endpoint. But it fails if I type in only part of that SIS Course ID, which is what I've been asked to do. Instead of the full course name (e.g "xxx-somePhraseWithNumbers11Here"), they want it possible to search with just a fraction of that (i.e the "somePhraseWithNumbers11Here" part, without the "xxx-" portion.

I've been reviewing the Canvas documentation on the courses endpoint once again, but if what I am looking to do is listed in there as a function, I seem to have overlooked it.

Is it possible to find a course given only part of its SIS ID? Any thoughts would be very useful

Labels (3)
1 Solution

Accepted Solutions
pklove
Community Champion

Rather than the course endpoints, look at the account ones.  This might be of use:

     .../api/v1/accounts/1/courses?search_by=course&search_term=xyz

Results will be broader than you want as it searches names and codes as well as SIS IDs.  So you will need to filter the results.

View solution in original post

10 Replies
bneporadny
Community Champion

Hi Lee,

I am not aware for a way to use the canvas api‌ to search for a course by partial sis id Do you have the ability or option to download and store information from Canvas in a SQL table? If so there are couple ways (canvas data, #admin reports specifically the provisioning report) to get a list of all courses including their SIS ID's that you could then use to search for the course using the partial sis id. 

Hope this helps. 

sam_ofloinn
Community Participant

Brian, thank you very much. I will look into checking if we have the option to use an SQL table for this. While I wait to hear back, can I ask you to go into a bit more detail please on how I could use admin reports/the provisioning report? I admit this is a new Canvas concept to me.

EDIT: Would a SQLite table be able to do the job just as well?

Hi Lee,

I'm glad to help. The just in time provisioning report can be found in Canvas by going to Setting --> Reports. From there you can configure which report you want to run and which term or all terms you wish to run the report for. If you wish to automate this report or any other reports that are available in this tab you would want to use the reports api (Account Reports - Canvas LMS REST API Documentation ) Here you would need to call the report, retrieve the ID, then check to see if the report is finished running and download the #csv report file and import it into a SQL database. 

Hope this helps. Let me know if you have any other questions. 

331671_pastedImage_1.png

sam_ofloinn
Community Participant

Very interesting, thank you Brian. I've ran this report now, will look forward to the results.

But for clarity's sake, since I'm making a call from the instructure website directly here - instead of getting data from Canvas endpoints using my project - what would happen if the course details were to change? For instance, if a course SIS ID were to be altered, or a course were to be added/removed? I'd have to call this project again in that case, I imagine. Which would mean setting up a script that runs this report at some interval, gets the results from some email, and replaces the existing database values with the results from these. Which I admit sounds like a lot!

Do I have that right? And if so, am I missing anything there? 

Hi Lee

I will admit this isn't this method isn't perfect, but then again what in life is. From everything I can think of this is the best way to do it based on the information I have about your program and Canvas setup. 

While it may sound like a lot to create a script to call the report, check the status and then download the csv report file, it's actually not as bad as you might think and if you use postman‌ to test out the api‌ calls you can actually get a lot of the coding from there to copy and paste into your program. Once you have the code tested and in place you can sit back and let the magic happen automatically to update the data. I have code that has been in place for years now that does this and haven't had to touch the code except for when we decide we need more data and can get it from one of the reports available. 

331672_pastedImage_1.png

sam_ofloinn
Community Participant

Indeed, Brian, indeed! I'm willing to do it if necessary (and permitted), I just wish to first fully understand what it is I'm doing!

Speaking of permissions, about the database. I understand you're recommending these be stored in a MySQL table, but would a SQLite table be just as plausible? This project aims to be as low-maintenance as possible, and so I have a small SQLite one set up already for this project, so it'd be easier for me if I could use this instead of replacing it for a MySQL one.

I actually have Postman, but I've never used it to generate code snippets before. Are there any tutorials you'd recommend for precisely that?

Hi Lee,

You can use any database program you have available to you. Whether it be MySQL, SQL, Oracle, etc. 

I don't have any recommended tutorials for #postman at this time. I've used it over the years so I've become fairly familiar with the functions I have needed to use. My best recommendation is to get in there and play around with it and if/when needed do a google search for the specific functionality you're looking for within #postman 

sam_ofloinn
Community Participant

Thank you, I'll see what I can manage!

pklove
Community Champion

Rather than the course endpoints, look at the account ones.  This might be of use:

     .../api/v1/accounts/1/courses?search_by=course&search_term=xyz

Results will be broader than you want as it searches names and codes as well as SIS IDs.  So you will need to filter the results.

View solution in original post