cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

An API for a graded discussion board...

Hello. I am wondering if Canvas or an external application has the capability to show me how many posts all students have made throughout the semester in a graded discussion forum. At the end of the semester, I create a curve based on the average number of posts students make and thus I need to know how many posts each student has made throughout the semester. For example, the number of posts made throughout the semester often range from 0 to 70. In Blackboard and Moodle, when grading the discussion board posts, I am given a summary that includes a list of students with how many posts each student has made. I am also provided with the average number of posts and other statistics related to their discussion board posts. This allows me to quickly determine where to set the curve.

Thank you for any help you can provide.

24 Replies
Highlighted
Navigator

peeksas@jmu.edu​,

The answer is yes, it can do this, but you need to make API calls to do it.

You start off with a list of the discussion topics and then iterate through each one of those, obtaining the entries for each one. Every post by a student appears there and so you just count how many times each student posted.

I've been working on a Google Spreadsheet for another project that Deactivated user asked about in Up for a challenge? Grade Distribution Spreadsheet, but became too busy with the conclusion of my summer course. Now that classes are over, I took a little time this morning and got it working enough to do what you asked for.

To use it, do the following:

  1. Make sure you're logged into Google Drive and then open the spreadsheet Discussion Counts - Google Sheets
  2. Go to File and choose Make a Copy. Name it whatever you like.
  3. In cell A1 enter the Canvas Course ID for the course you want to count the discussions for.
  4. In cell A2 tell it whether or not to also include completed students (this does not included deleted students, just concluded ones)
  5. Go to Tools > Script editor
  6. In the canvasAPI.gs file, find the userConfiguration() function and enter your Canvas hostname and your Access Token. If you don't have an access token, then see How do I obtain an API access token for my account? These will get stored in the Google userProperties(), which is specific to this spreadsheet and your user. After running the program once, you can delete the credentials and not have to worry about someone else copying your file.
  7. Switch over to the discussionCounts.gs script and then click the Run triangle. Tell Google you authorize it to access your spreadsheet and to make external calls.
  8. Go back to your spreadsheet and look for a new sheet called "Data" that has your counts in a pivot-table style format.
  9. If there are any problems, go back to the Script editor and press Ctrl-Enter to see the log file.

You can also watch the video I made that demonstrates this. I've obscured key aspects for privacy and security.

Now, a few disclaimers.

I've only tested this with my courses, which were small, and not much discussion went on. I think I've allowed for pagination, but you may find there are issues. I use threaded discussions and it's not tested with non-threaded discussions. Your mileage may vary, but it works for me.

Update: It turns out it didn't work for me, but my students didn't participate in the discussions like I had hope so it appeared to work. kona@richland.edu​ had me test it on her courses and now it's really working. Pagination issues are fixed and it now returns a correct count on threaded discussions.

I was intending to use this as a framework for other projects because it seems a lot of my responses in the Community are "Yes, you can do that through the API and here's how" and then I write a really technical explanation that may never get implemented. But if there was an easy way to share it, like a Google Spreadsheet, it might encourage people more.

This is, however, my first time sharing code like this and I really have no idea if I did it right or not. I'm also not a Javascript programmer, so I basically spent a lot of time looking at the Google Apps Scripts codes and then the Mozilla javascript documentation. I originally decided I would look at someone else's code and then found it too complicated for me to follow, so I wrote my own from scratch. I didn't do the sums through the spreadsheet, I found them by hand within my code. It definitely could be improved upon, but it's a first attempt. The problem is that I tend to be a perfectionist and so things never get done because they're not perfect. I'm stepping out of my comfort zone here, so hopefully the code works for you.

Only the GET functionality of the API has been tested. It might work, but until I have a need for a POST, PUT, or DELETE, I won't know for sure.

People can do what they would like with the code, but it would be really awesome if someone who did know Javascript or Google Apps wanted to collaborate and improve it. I would like for there to be a single copy of the canvasAPI.gs file that is reasonably up to date and then modify the other script to do the actual processing. The only thing I ask is that you don't sue me if it doesn't work.

Highlighted

Update: If you downloaded this in the 5.5 hours between when I first posted it, got 3.5 hours of sleep, and then debugged it, there were some issues. kona@richland.edu​ graciously double-checked it against her discussions, which were more numerous than mine, and found that pagination wasn't working and that threaded responses weren't coming through properly. Those issues have been fixed and she says the results look right now.

The canvasAPI stuff is now ugly because I wanted to get the code working rather than make it pretty. It should be okay to download, but anyone runs into problems, let me know.

Highlighted
Community Member

Thanks so much James. I look forward to testing this out. I have 160 students in my course and thus having this feature will potentially allow me to use Canvas come the Fall. Kona would you be willing to upload a screen shot of the final product so I can see what the end product looks like? Thanks again James for your work on this issue I was having.

Best,

  Aaron

Highlighted

peeksas@jmu.edu​, here is a copy of the final results from Kona's course. I've just written a blog post about this whole thing and it's part of that post, but the post has to be approved by a moderator before it can be seen.

discussion_counts_xtab.png

Highlighted
Community Coach
Community Coach

peeksas@jmu.edu​, James is correct that I used the Google spreadsheet and directions James provided and was able to get the above results. Individual students are in the first column and individual discussions are going across in the first row. The last column (total) is the total number of posts per student and the last row (total) is the total number of posts per discussion. I did a quick check against some of my discussions and it is correct.

I think this is pretty awesome and I hope it helps!

Kona

Community Member

I was wondering if anyone that is using this solution is experiencing any problems. I got it to work earlier this semester but now when I try to run it nothing happens (i.e., I get no list of the students or the number of posts). The error log suggests that it is an access token issue but I have an access token so I am not sure what is going on. Just wondering if it is just me or if others are experiencing a problem as well. Thanks!

Highlighted

Is this a change since last week? I noticed some API changes with the October 31 update that reworked permission checking and some of the things I'm trying are now returning "Not authorized" (I'm the teacher of the course plus a Canvas Admin) when I clearly am.

Highlighted

I did just go in check my copy and it worked as expected -- although it returned "undefined" for a discussion that is open but no one has started yet. I can live with that, I guess, but it did function.


But that doesn't mean that it's not a permission error on another aspect -- that is, I may have the right combinations as a Canvas Admin, but it might not be enough for a teacher.

Did the log file give any indication of which line wasn't working so we could track down which API call was failing?

By the way, some day -- unknown when -- I will have a nicer version of the spreadsheet. I've improved the interface so you don't have to go in and manually set the token, it will prompt you for it. I'm also modifying it to make a second spreadsheet that will give much more detail about a single discussion like the number of likes received, top posts, replies, etc. Unfortunately, I've got too many projects going on and don't find time to work on them.

Highlighted
Community Member

This is the error message I am getting:

[15-11-04 07:37:25:968 EST] Exception: Request failed for https://CANVAS.instructure.com/api/v1/courses/1344408/discussion_topics?per_page=100 returned code 401. Truncated server response: {"errors":[{"message":"Invalid access token."}],"error_report_id":54998680} (use muteHttpExceptions option to examine full response)

[15-11-04 07:37:25:969 EST] Unable to obtain list of discussions.

I'm not sure if having the log is helpful in explaining what is going on but it seems to suggest that my token is invalid. But I used the same token that worked previously and then tried a new one but I keep getting the same error message.