Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
fernpena
New Member

Hi community. How I can get the course card from canvas data portal? Or some way to get this.

Jump to solution

We are thinking in automatic reports for courses and we need the course card in each report.
Thanks and greetings from Chile!

1 Solution

Accepted Solutions
James
Community Champion

That was very weird, it looks like entire reply I made to Robert got wiped out when I went to save it. I'll try to repeat as much of it as I can remember.

 @fernpena  

There are two ways to get a course card image into Canvas. Only one of those shows up as a file ID. Canvas supports Unsplash (used to support Flickr) and file uploads.

I wouldn't use Canvas Data to get it. Besides being out of date, it's problematic as Robert explained and doesn't include those that point to an external site.

The Get course settings endpoint of the Courses API returns three fields.

  • image_url is for an external image. Files from Unsplash and Flickr have this property, otherwise it's the empty string.
  • image_id is the file ID for a file uploaded to Canvas. Only files uploaded to Canvas have this property set, otherwise it's empty.
  • image is a URL that includes any extra parameters (like a JWT token needed to authorize access) to the file and is the one that should be used. This property is set for either technique and it's the one you would want to use with an external program.

If there is no course image, then all three properties are the empty string.

Here are some examples of what you'll get

My wife's flickr image:

350654_pastedImage_2.png

My file I uploaded to Canvas (I cut off the image - it was 3 lines long since it has the JWT authorization):

350655_pastedImage_3.png

View solution in original post

7 Replies
robotcars
Community Champion

Hi Fernando,

It does not look like the there is any specific identifier for course card in either Canvas Data or the API. It is a file and uploaded as an attachment with the Course context. 

The file shows up in file_dim, with a folder ID, but I didn't select a folder. So I looked in the Course files and found one called course_image, it can contain 1 or more images. Canvas Data doesn't seem to contain any references to folder names, which means there is no way to query WHERE folder_name = 'course_image'

You could, possibly shoot for all something like

SELECT folder_id FROM CanvasLMS.dbo.file_dim WHERE owner_entity_type = 'course'

Files - Canvas LMS REST API Documentation 

Then, do an API lookup for each folder_id, and get the name of each, which is commonly 

course files/course_image

store the folder name, or flag the file as a possible course card (could be multiple files in the folder, maybe versions?)

Or...

If you have control or communication, naming conventions would make it a snap with a standard file name or prefix to the file name.

cc: Canvas Developers, Canvas Data Services

robotcars
Community Champion

Since you'd have to go through the API to get the actual file, it might just be easier to use the API for the majority of the task and skip CD. Or use CD to get the courses for your report, then loop through courses, getting each folder, and getting the files in the course files/course_image folder.

James
Community Champion
robotcars
Community Champion

Jive ate your reply. I'm anxiously waiting to see if you found another way.

James
Community Champion

That was very weird, it looks like entire reply I made to Robert got wiped out when I went to save it. I'll try to repeat as much of it as I can remember.

 @fernpena  

There are two ways to get a course card image into Canvas. Only one of those shows up as a file ID. Canvas supports Unsplash (used to support Flickr) and file uploads.

I wouldn't use Canvas Data to get it. Besides being out of date, it's problematic as Robert explained and doesn't include those that point to an external site.

The Get course settings endpoint of the Courses API returns three fields.

  • image_url is for an external image. Files from Unsplash and Flickr have this property, otherwise it's the empty string.
  • image_id is the file ID for a file uploaded to Canvas. Only files uploaded to Canvas have this property set, otherwise it's empty.
  • image is a URL that includes any extra parameters (like a JWT token needed to authorize access) to the file and is the one that should be used. This property is set for either technique and it's the one you would want to use with an external program.

If there is no course image, then all three properties are the empty string.

Here are some examples of what you'll get

My wife's flickr image:

350654_pastedImage_2.png

My file I uploaded to Canvas (I cut off the image - it was 3 lines long since it has the JWT authorization):

350655_pastedImage_3.png

James
Community Champion

I've never had Jive do that completely before -- at least not that I remember. I thought for a minute my Internet had gone out, but everything else was working).

that is the answer that help us to get the url of courses cards! Very thank you