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.
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.
Go to File and choose Make a Copy. Name it whatever you like.
In cell A1 enter the Canvas Course ID for the course you want to count the discussions for.
In cell A2 tell it whether or not to also include completed students (this does not included deleted students, just concluded ones)
Go to Tools > Script editor
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.
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.
Go back to your spreadsheet and look for a new sheet called "Data" that has your counts in a pivot-table style format.
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 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.
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 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.
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.
@peeksas , 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.
@peeksas , 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!
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!
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.
[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.
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.
James, I was wondering if maybe the problem I am having is b/c I have several different discussion forums. Would this be a problem for the script you wrote?
The code fetches a list of all discussions before it starts processing them. There's nothing in the program that would limit it because of that.
However, there is is a Google Sheets timeout of 5 minutes that might come into play. No script will execute for more than 5 minutes. So, if you have enough discussions with a lot of students and it can't process them all in 5 minutes, it would stop. I'm not sure where it would stop, though. Probably before displaying anything.
Also, if your discussions were long -- like lots of embedded graphics and the like, it might also cause a timeout.
That wouldn't be my first guess, but you could edit the code and skip everything after the first discussion to see if it was working. I think you could accomplish that by adding a line that says break; between lines 110 and 111 in the discussionCounts.gs file. Those probably aren't the same lines if you removed the code for your token.
Look for this (the numbers may be off a little) and put break; before the between the two } lines
110
}
111
}
112
header = [ '' ];
113
footer = [ 'Total' ];
Then if it runs, it might be a timeout issue. If it doesn't run, it's probably something else.
Unfortunately, nothing gets timed out (the script is completed within 10-30 seconds). I end up with a "data" sheet that is completely blank. There are lots of embedded videos and such that the students include in their posts so that could be the issue but since the error message (noted in a previous post) mentions the access token, it may be an issue with my home institution and something changing in the last month. Unfortunately, it looks like I will be stuck manually tallying up all the discussion board posts for each student at the end of the semester. I do appreciate you taking the time to create this script James. Hopefully in the future it won't be needed because Canvas will provide this statistic for teachers.
Have you tried creating a new token and trying it. You may need to make another copy of the original if you've removed the lines that contain the token from your existing one.
Another (I'm stretching) idea might be that you put an end-date when you created the original token and it has just expired.
If you want to confirm that it really is a token issue and not something else that has changed, you could try this:
Go into Tools > Script Editor and choose the canvasAPI.gs script.
Find the line that mentions UrlFetchApp. There's only one and it's around line 195. You could do a Ctrl-F for it.
Insert a line after that and add Logger.log(response);
Then, after every call to the Canvas API it will try to log something. You can then view the log once you've run the script and see if data is being returned or if there is an error message. There might be too much (my first call said "Logging output too large. Truncating output." but then there was data shown after that so I know it's working).
Be sure to remove that line after testing or your log will fill up with useless crap and you'll miss the good stuff.
I figured out the problem. The problem was that even if I brought up a new spreadsheet and put in a new token, the script would resort back to my original token that had expired (this is even if I saved the new script with the new token). So that was a relief.
With that said, I need to warn anyone who is using the script that there are errors with the results (at least for me). I have had three students thus far question their discussion board grade and based on manually going through and checking their posts, I have found that the number of posts the script indicates they have is less than what they actually posted. While it has not been off by more than two posts, it does make me worry that if it is miscounting for some students, it is miscounting for others and since I have over 150 students, it is going to be a painstaking process to go through them all. I do appreciate the time that you invested in this James and I am not sure why it is not counting accurately. I will add that the posts it is missing involves only text with no attachments or anything else "fancy."
I did read somewhere that Canvas is going to talk about improvements for the discussion board in 2016 so maybe by 2017 or 2018 it will have the features that I need for my courses without having to resort to outside solutions.
There are two or three things I can think of for the miscount. That's without digging into it. These are purely conjecture on my part and no guarantee that they are correct.
I didn't test it on non-threaded discussions, so if it is not threaded, it might be an issue.
I tested it with much smaller classes, so there might be an issue with the 5 minute timeout if you have 150 students with a lot of discussions and a lot of posts.
There might be a pagination issue involved with that many items. In my testing, Canvas sent the entire discussion in one document, but some people have commented about how they don't like having to page through to get to new information.
Students may have dropped or been concluded. I'm not sure how or if this would affect it, but there might be something wonky going on if one of the responses was in reply to a dropped student.
The token thing makes sense. Someone else ran into a similar issue. This is documented, by the way, and was designed to be a security feature. Once you put your token in once, it saves it so that you can remove the line. That way, if someone else does get access to your file, they don't get access to your token. But that meant that unless you told it to override the saved value, it would continue to use it.
Making a new copy of the script would fix it or there's some code you can override. There's a statement around line 36 that says:
var override = false;
Set that to true to overwrite the saved host and token. There's also a comment (which is mostly unheard of for my code) for the function that explains things.
I am off until January, so I won't be as present in the Community as normal for the next 3 weeks. I'll be without Internet for the next week, so I won't be able to provide any help figuring things out for this semester.
If you figure out why it's miscounting, send me a note with the solution and I'll update the code. I need to update the interface anyway as I've got a new version that asks for the token with a web form so you never have to edit the script directly. Just finding time to get everything done is the hard part.
After manually going through, it looks like the script did not count 298 posts that were made for a class of 155 students. It might be a good idea to place a warning next to the script or alert those you know are using it that there are potential issues with the script. Since I already have issued grades based off of the script counts, I am now faced with having to redo my curve and reevaluate grades. Hopefully, with the warning, this can be avoided for other faculty.
I am wondering if it might be an issue with some of my forums having so many posts in them that they go on to a "page 2" and when this script is counting the posts, it doesn't have a command to continue on to any additional pages that might exist? Just a thought.
I spent most of Christmas Day investigating and I think I found the issue. Can you check and see the following matches what you're seeing?
The system was only checking one level of threading. That is, it was counting initial posts and replies to initial posts, but not replies to replies to initial posts (or further down the list). In my class this summer, there was no deeper nesting and so I didn't notice that I needed to use recursion.
I've done a major rewrite of the code and changed it to use pivot tables instead of manually do the counting. Unfortunately, generating a pivot table through programming seems problematic, but as long as people don't delete the existing one, it seems to work. It's also cool to see it run. With the pivot table, you can choose whether or not to include teachers and concluded enrollments through a filter, so one spreadsheet allows for configuration to meet people's needs.
I also incorporated the new interface so you don't have to go in and edit the source code anymore. I want to make another modification so that you enter the course ID rather than putting it in a spreadsheet cell. There's also some more testing I want to do before I release it.
I have done a major overhaul to this spreadsheet. I kept the same URL because several people have linked to it, but the old version is no longer available.
Changes
There is a Canvas menu that will appear after the Google Sheets menu. All configuration is done there, there is no more need to edit the source code.
All discussions are included. It turns out the first version only counted top level (initial posts) and responses to the initial posts, but not nested replies beyond that. Thanks to Aaron PeeksMease for directing me towards this bug.
It now creates a Data page that has one entry for each student/discussion combination.
It uses Pivot Tables to do the counting. This allows you to filter the data by role (student/teacher/ta) and by status (active/concluded) without modifying the source code.
Students who didn't post in a particular discussion show up as missing rather than a 0. That's an artifact of using Pivot Tables.
It now uses the IFRAME sandbox mode. That doesn't sound glamorous, but Google has said they will stop supporting the NATIVE mode that I was using on June 16, 2016, so the update was necessary to keep the program working.
In theory, you can add multiple courses to the spreadsheet.
Getting Started
I will try to get an updated video made. The quick start is
Make a copy of the spreadsheet that you can edit
Choose the Canvas > Configure API Settings menu item and put in your Canvas Instance and Access Token.
Choose the Canvas > Specify Course menu item and enter your Canvas Course ID
Choose the Canvas > Refresh All Discussions menu item. This will wipe out any existing data and count all the discussions in your course.
There is also a Canvas > Append New Data menu item. This will skip any discussions previously analyzed and only fetch new discussions (it will not fetch new posts to old discussions). This is useful if you run the report several times a term or you want to fetch data for multiple courses. It is not useful for on-going discussions that have previously been analyzed.
Sorry James for never responding but I never received an e-mail notification saying you referenced me in your post. The nested within nested posts makes sense. I am back on here to see if Canvas has finally provided this simple statistic like other platforms do but apparently they do not. I tried to test your new API but I can't figure out the "Canvas Instance"/username. I had a problem with this before and my exchange server deleted the e-mails that provided me with the solution. Thanks for all your work on this and wished that Canvas would start providing users with useful and typical content to users without users having to request and vote up specific suggestions. I guess I will be using the free CourseSites once again this Fall and Spring semesters.
I'm not sure about this one since I haven't updated it in a while, but I think you can copy/paste a URL from your class into the box asking for the Canvas Instance/Hostname. "Username" doesn't make sense to me as it is determined from the Access Token you provide.
A quick search on the web makes it look like the Canvas instance/hostname for JMU would be canvas.jmu.edu
Yes, when I put that in along with the token then I tried to put in the course ID but it took me back to the API screen saying that I needed to put in the token, etc. Like last time, it is likely an issue with JMU and permission. If there was not another platform that provided me with the information that I need then I would take the time to figure this all out. But in the end, all the other paid and free platforms provide what I need so I will go with the free one available. Thanks again James for all your hard work on this and I wish Canvas had someone like you working for them making their platform better.
There was another big school that removed the access to the tokens and finally granted it after over a year, but you had to run everything through a proxy and so it became difficult for people to use. All that to say that yes, some schools are putting up roadblocks for effective use of classroom data.
Are you allowed to install your own LTI applications? If so, then Threadz my @mlewis23 might be able to help. I think it was one discussion at a time, but that there were some features for exporting the data.
Can you install a user script manager extension like Greasemonkey for Firefox or Tampermonkey for Chrome or Safari. It doesn't have to be on a school computer, but if you can, then someone could write code that would run the report within the browser, totally bypassing the need for an access token. I don't have time to do that right now, but someone could take my script and modify it. Then they could possibly combine it with some other stuff I've written to export a CSV file of all the information.
Any scripts I write are provided as-is and without any warranty as to suitability or correctness. They are a "it works for me and you might benefit from it" production. I throw them out there hoping that people will be inspired by them to take them and improve on them. I personally don't use most of the scripts that I make available here in the Community.
If people report problems, I will try to fix them if I can (which is not always possible), but I have no idea who is using it unless they write something. Beyond that, if you read the original reply, you will see that there are tons of warnings about it may not work for you. I will clarify that my issues with pagination are not the same as yours, I was talking about the API returning results in paginated form, not the pagination you might see when there are a LOT of responses.
My offer still holds -- if you track down the problem and fix the code so it works, I will modify the version available for people to download.
As I mentioned, though, it is not always possible to fix them. I've had a couple of cases I've been involved in where Canvas fails to return all of the information when requested through the API. There's nothing my program can do if the information is missing in the first place. I'm not saying that's the problem and I really don't think it is based on the way this particular API call is supposed to work, but you might look at your discussions where posts weren't counted and see if the non-counted posts appear spread throughout the discussion or if they appear on the second page. If they appear spread throughout the discussion, then the probability that Canvas isn't returning all of the discussion just went way up. If they all appear on the second page of the discussion then that gives me a different area to pursue.
As far as not being able to change your grades, I make it clear at the beginning of the semester (and place it into the syllabus) that grades are subject to audit and change and that students should not shoot for the minimum grade needed because I may find a mistake and they may not end up with enough points.