After an outage on September 1, the Instructure Community is now fully available, including guides, release notes, forums, and groups. If some styling still looks unusual, clear your cache and cookies.
I probably just missed it but, I cannot find anywhere in the API documentation for showing Grade comments or rubric instructor comments. Is it even possible?
I am attempting to make a report card using the API and google docs. Right now they are selecting individually 300+ students and expanding "Show All Details" then Print grades to get that info. I was hoping to help if I could generate a big spreadsheet they could just mail merge into a final report. I think I have figured out how to GET everything they need except those comments.
Solved! Go to Solution.
ilovell,
I think you're talking about this screen. If not, please let me know.
There are a few API calls you can make to get the information.
The important thing in all of those is the include[] parameter.
If you choose include[]=submission_comments, you get a "submission_comments" array of objects that is returned. Each submission comment has its own entry in the array. All of them contain a "comment" that contains the comment.
If you include[]=rubric_assessment, you get a "rubric_assessment" object. Each entry is keyed, but it is not an array. It would also contain any comments for that specific rubric entry here. Sorry for the simplicity, I'm using a really simple rubric for grading.
If you include[]=assignment, you get an "assignment" object. Inside that object is a "rubric" entry that contains an array. Each entry in the array has an "id" that corresponds to the key in the rubric_assessment. Again, my rubric is simple with only one criteria, but that also means it fits on a screen capture.
The includes[]=assignment should be the same for each student so you could retrieve it once rather than with each student. It depends on how you're doing the processing.
By the way, the score details section appears to be done through a presenter and not a controller. In plain language, not available directly through the API, but available through the web interface. I'm about to wrap up a project that will fetch the user Access Reports for an entire class. I could find that information at all in the API, so I'm grabbing it directly from Canvas (which has the side benefit that an instructor can use it without messing with the API). The page I'm using returns the output in either HTML or JSON formats, so choosing JSON made it easier to work with. Unfortunately, the grade summary page seems to only be available in HTML format. Luckily, if you're downloading all the information through the API, then you can manually compute the Score Details if you want it. Another option would be to download the HTML page and then parse it to get all the information you need in one shot -- the problem with that is it's not available through the API and subject to change if they modify they underlying report.
Another option, one you probably don't want to pursue since you've already invested so much time in this one, is using a headless browser like PhantomJS or CasperJS to load the grade summary page that Canvas provides, toggle the Show All Details, and then save it to a PDF file. You do that for each student and then you can print them with all the fanciness that is Canvas.
I hope this gets you headed in the right direction.
ilovell,
I think you're talking about this screen. If not, please let me know.
There are a few API calls you can make to get the information.
The important thing in all of those is the include[] parameter.
If you choose include[]=submission_comments, you get a "submission_comments" array of objects that is returned. Each submission comment has its own entry in the array. All of them contain a "comment" that contains the comment.
If you include[]=rubric_assessment, you get a "rubric_assessment" object. Each entry is keyed, but it is not an array. It would also contain any comments for that specific rubric entry here. Sorry for the simplicity, I'm using a really simple rubric for grading.
If you include[]=assignment, you get an "assignment" object. Inside that object is a "rubric" entry that contains an array. Each entry in the array has an "id" that corresponds to the key in the rubric_assessment. Again, my rubric is simple with only one criteria, but that also means it fits on a screen capture.
The includes[]=assignment should be the same for each student so you could retrieve it once rather than with each student. It depends on how you're doing the processing.
By the way, the score details section appears to be done through a presenter and not a controller. In plain language, not available directly through the API, but available through the web interface. I'm about to wrap up a project that will fetch the user Access Reports for an entire class. I could find that information at all in the API, so I'm grabbing it directly from Canvas (which has the side benefit that an instructor can use it without messing with the API). The page I'm using returns the output in either HTML or JSON formats, so choosing JSON made it easier to work with. Unfortunately, the grade summary page seems to only be available in HTML format. Luckily, if you're downloading all the information through the API, then you can manually compute the Score Details if you want it. Another option would be to download the HTML page and then parse it to get all the information you need in one shot -- the problem with that is it's not available through the API and subject to change if they modify they underlying report.
Another option, one you probably don't want to pursue since you've already invested so much time in this one, is using a headless browser like PhantomJS or CasperJS to load the grade summary page that Canvas provides, toggle the Show All Details, and then save it to a PDF file. You do that for each student and then you can print them with all the fanciness that is Canvas.
I hope this gets you headed in the right direction.
Thank you! Perfect! Your in depth description much appreciated. I didn't even think to look in Submissions. Testing in api live, I think I can get it to do what we need it to do with includes. Now to make this work in google docs should be interesting.
ilovell,
I'm glad it helped. Things in the API sometimes aren't where you or I might think to place them.
Getting the information into Google Sheets isn't too bad. You might want to look at what some other people have already done. You can always get the code by opening up what someone has posted on here, or I've got a Canvancement site on GitHub where I try to keep the latest version of some of mine. I've got an canvasAPI.gs library that I use in all the Google Sheet stuff I write that automatically handles pagination and variable substitution.
I finally ran into an issue yesterday that @jblumberg talked about at the 2015 InstructureCon -- the 5 minute execution timeout on any script. Mine was a relatively small project compared to some schools -- 41 students with a discussion of 368 posts. It was okay fetching the full discussion 41 times and then writing joining the unread array and the ratings (likes) object into a comma separated string and storing it. But when I tried to split it into one line per post/user combination, it timed out on me after about 24 students. The sheet.appendRow() method was the bottleneck. I didn't have time to refactor the code since I needed to get the assignment graded, so I just disabled it and left it in the comma separated format. I wasn't using that information anyway - just the percent of posts they hadn't read and the number of times they liked something.
But I can see that with 300+ students and all of the API calls that you have to make to get the data, that you might run into that issue.
Sorry, but I can't offer any pre-attack suggestions for the mail merge part.
Thanks! Bookmarked your gitHub
I have been using this template by Brian Whitmer as my starting point. I watched a couple videos from past Instructurecon too. With my minimal programming knowledge I have had the best results with Brian's template. I have been able to put a blurb in the first cell and he has 2 generic methods I can call. Working on making my own functions now. Not sure what will happen with the timeouts when I am ready to run the real one. Good to know when it stops and I am confused again.
Hi Iva,
I wanted to follow up to see if you were able to get this developed, it would be very useful at my institution.
Thank you,
Angie
Sorry for the late response. Yes and no. I got my script to work but, it is a mess to be functional for making a gradebook with rubric comments. My lack of any skills using spreadsheets and minimal programming expertise, it ended up faster to just manually make pdf for each student.
I created 2 sheets using this template by Brian Whitmer as my starting point. You have to run 2 functions to get all the info. One sheet I did the rubric info the other one with the assignment info. Then tried to merge them together playing the number matching game in excel.
/************************
GETS ASSIGNMENT RUBRIC DATA FROM CANVAS API
************************/
//lists user id, user overall grade, assignment id, assignment grade and include rubric grades
//This one pulls by assignment need course ID and assignment ID
function canvasRubric(course_id,assignment_id,options){
return canvasList("/api/v1/courses/" + course_id + "/assignments/" + assignment_id + "/submissions?include[]=rubric_assessment", options);
};
//This one pulls entire course with all the assignments need course ID
function canvasWholeCourseRubric(course_id, options){
return canvasList("/api/v1/courses/" + course_id + "/students/submissions?student_ids[]=all&include[]=rubric_assessment", options);
};
/************************
GETS ASSIGNMENT INFORMATION FROM CANVAS API
************************/
//list the assigment info in the supplied course and assignment ID
function canvasAssignment(course_id,assignment_id,options){
return canvasList("/api/v1/courses/" + course_id + "/assignments/" + assignment_id, options);
};
If you have more than 10 students you will need to add a ,"results=124". Depending on how many criteria and ratings I could get around 124 before timing issues with google.
Hi Iva,
Thank you for sharing your work, you have saved me a lot of time! I was struggling with how to code include[] parameters in Google Apps Script.
Angie
Excellent!
If you run into issues with not enough columns being generated because of too many criteria ratings I have a workaround for that.
Hi Iva - are you able to share a copy of the template? The link you provided in previous posts leads to a login screen. I am looking to my my submission comments to students and what you are using sounds like it might be helpful.
Thank you!
Hello
Maybe this one works better.
It does! I actually "hacked" the other url and found within it where to go
Have you had luck getting the actual submission comments to show up using this tool? I get it pull the headers but the columns below all the submission comment headers are just blank but when I do the same in Canvas Live API I see the comments I am trying to get onto the Google sheet.
I am new to API and JS and read and experimented till my eyes fell off, but simply can't get sub comments into a Google sheet . Maybe I need to add another Key after include[]=submission_comments to specificy I want the comment itself?
Canvas API live was a savior to let me know that I was calling the data correctly, so that felt good...
Lol, I should clarify that I didn't hack anything, I meant that I simply found a url within the link you provided that brought me to the sheet
Something is odd. It used to work... if I run it as a function from the script it doesn't work anymore.
If I just type
=canvasList("/api/v1/courses/1760/assignments/13465/submissions?include[]=submission_comments&include[]=rubric_assessment", options)
In the first cell of the sheet, it works (1760 is course number and 13465 assignment number those would need changed to yours), and fills in both comments and rubric comments. So I don't think I hacked anything just confused what breaks it the other way.
Hi @James ,
I am attempting to make the API call for "List submissions for multiple assignments" through Postman and Google Sheets. I am able to successfully send a GET request for the "courses/:course_id/students" and it returns the list of students in the course, in both Postman and Google Sheets. However, as soon as I try to send the "courses/:course_id/students/submissions?include[]=submission_comments" request, it returns a "401 unauthorized" error. I am not sure what I'm doing wrong, as my account is at the root admin level and I checked my token in my account settings and it wasn't expired. Do you have an idea of what could be causing the issue?
My guess is that you're not specifying the student_ids[] parameter.
student_ids[] needs repeated multiple times, once for each student, or with student_ids[]=all to get all current enrollments. There is a note that says "If this argument is omitted, return submissions for the calling user." The calling user (the person with the root token) doesn't have any submissions in that class, so it's getting a 401 error.
@James ,
Thank you for your help! I was able to get it to return results.
However, I am coming across a new issue. I can't seem to return past 100 results. I tried to handle pagination by adding the "&per_page=10000", as recommended from a InstructureCon video (https://www.youtube.com/watch?v=g8XRYqzj6Qo) and add the "&page=2". But it won't display more than 100, even though I know that there are more than 100 submissions for the course. I even tried testing it by including "&per_page=1&page=2", but it doesn't change the result to the next result...it just stays the same result that came first in the list. It is almost like pagination doesn't matter and no matter which "page" you are on, it keeps the same order (not going to the next set of results) and only shows up to 100 results.
How would I get more than 100 results?
This has explained in the Canvas Developer's group many times and I don't have time right now to go into depth.
The short version is that you do pagination the way it is in the documentation, not the way someone shows in a video. There are a lot of people out there doing things that work in their case but don't always work. There are link headers returned that contain links to the next page. Submissions don't use pages, they use bookmarks, so you have to follow them in order rather than just blindly going through and trying page numbers.
Most of the time, you can only request 100 items at a time. Requesting more than that and then trying to blindly use page=2 is going to lead to bad (at least confusing) results.
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.