Last active
December 16, 2015 05:39
-
-
Save brent20/5386038 to your computer and use it in GitHub Desktop.
This Ruby script pulls the Canvas Analytics for the Account requested and generates a CSV file compatible with the Panic Status Board App.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # CREIGHTON UNIVERSITY | DOIT | |
| # BRENT SALTZMAN | EMERGING TECHNOLOGIES | |
| # LAST MOD. 4/15/13 | |
| # This Ruby script pulls the Canvas Analytics for the Account requested and | |
| # generates a CSV file compatible with the Panic Status Board App. | |
| require "rubygems" | |
| require 'rest_client' | |
| require 'json' | |
| require 'net/http' | |
| require 'fastercsv' | |
| require 'pp' | |
| output = "c:/inetpub/wwwroot/sign" | |
| the_title = "BlueLine2 Stats" | |
| file_name = "bl2api" | |
| secret_token = "Generate_Token_and_Insert_here" | |
| request = 'https://your_canvas.instructure.com/api/v1/accounts/<ACOUNT_ID>/analytics/terms/<TERM_ID>/statistics' | |
| response = RestClient.get request, {:params => {:access_token => secret_token}} | |
| data = JSON.parse(response) | |
| #Used PP to troubleshoot JSON Parse | |
| #pp data | |
| FasterCSV.open("#{output}/#{file_name}.csv", "w") do |csv| | |
| csv << [" ","BlueLine2 Global Stats" ] | |
| csv << ["Courses", data["courses"]] | |
| csv << ["Students", data["students"]] | |
| csv << ["Teachers", data["teachers"]] | |
| csv << ["Assignments", data["assignments"]] | |
| csv << ["Discussions", data["discussion_topics"]] | |
| csv << ["Media Uploads", data["media_objects"]] | |
| csv << ["Colors","Purple"] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment