Course Setup Using Google Docs and the Canvas API

Justin Ball: My name is Justin Ball. Welcome
to Instructure con. Hopefully everybody is having a great time in beautiful Park City.
This is one of my favorite places in the state of Utah because it has some incredible mountain
bike trails. So if you haven’t had a chance, take the gondola up, rent a mountain bike,
go hiking, enjoy this experience because it’s beautiful and the weather is great. I am with a company called Atomic Jolt. We
do all kinds of custom Canvas development and I am going to talk about one of the projects
that we’ve built here for Instructure, actually. So first of all I’m going to talk about
some things that really really boring. Yeah. The people in the back are already like okay
I’m done. I’m out. Things like lukewarm water. That’s kind of boring, right? We
like cold water. Cold water is exciting. Hot water, make lots of beverages with hot water.
Lukewarm water is kind of boring. Have your iPhone stolen and having to sit
at the bus stop waiting for the bus. That’s kind of boring. Sitting here listening to
somebody drone on about boring. That’s kind of boring. Some more people in the back are
probably like I’m done, walking out here. Watching golf on television. That’s kind
of boring. If you’re my age you used to get up, watch Saturday morning cartoons and
after the cartoons what was always on? It was always golf. But you had your bowl of
cereal and if you got up and got dressed then you had to do chores so you watched golf on
television. I still think that’s kind of boring. But the most boring thing of all to me is
building courses or at least building the same course over and over. I know I just offended
every instructional designer in the room because they’re like I love to build courses. This
is the most exciting thing of my day. But I’m not talking about working with somebody
to discover some piece of new knowledge and put courses together. I’m talking about
actually building courses. So you’ve probably had this experience.
You get an email and here’s this great sale. You get 20 percent off that brand new pair
of jeans that’s going to make you look skinner. You go to the site, you add it to your cart,
you go to check out. During the checkout process they say okay, enter your email, choose a
password, put in your address, type in your credit card, choose six security questions,
give us the name of your first born, on and on and you’re like I’m cool with the pants
I already have. I’m done. I’m out of here. If you’ve ever had to build the same course
in Canvas over and over again, then you know that that’s a boring experience. We’ve
had this because we develop a lot of different systems that integrate with Canvas. And we
have to test those systems and so frequently what I would find is after I got all my code
done and I had to build everything. At the very end it’s like okay let’s go test
it. So go build a course, add some users and add some discussions and add some assignments
and I was like I am – just can’t take this anymore. I did this all this work, building
the course, or building the code, and now I have to do this boring part that I have
to do every single time I want to test a course. And that’s kind of boring. But, oh no. That’s not boring. That’s
the wrong screen. Computers are great at boring stuff and at switching your screen at the
very moment when you don’t want them to switch the screen. Computers do boring stuff
really well. They don’t go home at night and complain to their wife and say you know
today I had to build the same thing over and over again and I am going to quit my job. Instead computers religiously follow exactly
what you tell them to do and they will do that over and over again and so I want to
introduce you to Demo Arigato, which is the name of a project that we can be thankful,
you know Demo Arigato, thank you Mr. Computer, right? Is that how the song, no that’s not
– robot. Okay. So this is a project that we built,
Jared Stine who’s been a friend of mine for a long time, said will you take some code
that we have and build this piece of technology for the sales team because every time they
want to demonstrate Canvas they have do the same thing over and over again. They want
fresh courses. So they have to go out and get the common cartridge and generate a course.
And then they would have to bring in some users and they would have to add discussions
and then they would literally have to log in as each of these users and surf through
the course so it would generate some analytics so they could the show the analytics piece. You want to talk about boring. Go create a
user, log in as that user, log out, create another user, log in as that user, surf around
a couple of times, add some discussion and then do that over and over again every time
you show off Canvas. That’s really boring. So the payoff for this is that you get to
build your courses one time. We’re done with boring. Demo Arigato will automatically
build your courses and abstracts away all the boring stuff and it will actually surf
the site for you to generate some of those statistics, which is kind of fun because then
you don’t have to do that by hand. All right, so everyone is unicorns and rainbows.
That’s what we like when we’re a programmer except that sometimes it’s not. There are
a few problems and I’m going to admit those upfront before I do the demonstration. Some
of those problems include that it’s not entirely user friendly. This is an admin tool.
And you can use it and I will show you how to go use it but I will warn you that if you
put in bad data it will do bad things. Computers don’t like bad data. We had this happen a couple of times. People
would put in a bad URL for one of the common cartridges. And you’d be like why is this
course not loading? And I am like well because the computer can’t get to the thing that
you told it get to. Or why is this user’s profile not loading and it’s because the
image was not on a publicly accessible URL. So with that we’re going to try a demonstration.
Now I am on the hotspot on my phone, not on the conference Wi-Fi so hopefully this will
work. Female 1: Are you better off as a hotspot. Justin Ball: Yeah. We’ll see how this works.
First off I wanted to show this. This is how you build the courses. This is the Google
Docs part of the presentation. Okay? So basically Instructure’s – I can’t remember who
exactly does this, somebody at Instructure does this. They build this spreadsheet. And
they add all of the users so you can see here the user CSV. So you do this one time. So
this is a boring part but you only have to do the boring one time. Type in my users,
I give them a SIS ID, give them a name. They have an avatar over here. That’s kind of
nice so that their pictures actually show up in the demonstration. That’s kind of
cool. We’ve got this Courses tab. So here are
the courses that you will see that we can build using Demo Arigato. And you can see
it’s pretty easy to add a new course. So I have, if somebody comes along and they’re
like oh really want to do an underwater basket weaving course because that’s really really
popular in colleges these days I hear. You just add another line. Underwater Basket Weaver.
You give is a SIS ID and you give it the common cartridge URL right here. So one thing to note is all of these are public
URLs. If you go to that URL this – you will be able to see this. You can’t edit it.
Hopefully you can’t edit it. So anyways, let somebody mess that up. But you can see
it and that’s important and I’ll show you why in here a minute. And the common cartridges
are also public. So then we have enrollments. So after you
create the users you have to enroll them in the courses. So this describes given users
enrolled in a given course. And it gives the types so you can see there’s a whole bunch
of students. And then we have discussions. So it will set
up and populate discussions. We have assignments. It builds up the assignments, conversations,
and so on and so forth. Okay. So here’s what Demo Arigato looks
like. That’s public. You can go there and you can actually do this if you own Canvas
Instance. Now I will warn you it does create all this stuff in your Canvas Instance so
if you go and you do this and it creates a bunch of stuff, don’t come tell me it created
a bunch of stuff in your Canvas Instance because that’s what supposed to do. You can put in a SIS ID if you want to make
these courses unique. I’m going to put in my last name here. And I want to create an
eighth grade math course. And with any luck when I hit submit it’s going to go off and
start creating this. Now you can see that it’s starting to set up and it says go get
yourself a tasty beverage because one of the drawbacks is this takes a couple of minutes.
So you can see it’s found all of these existing users. So you don’t end up with duplicate
users. The end result looks like this. It has this
output log file. It tells you it added some courses, enrolled users in the courses. As
Canvas is importing the common cartridge it checks for the status until we get down here
to 98 percent complete then all the sudden it says, all right. It’s ready to go. I realize this is kind of small but this is
just log file stuff, so it’s kind of boring anyway. Don’t worry about. It’s just saying
it’s finishing. It’s done. It lets you know kind of what’s going on. All right. So let’s switch back over creating
you can see it’s about 5% complete, and so campus is currently importing the common cartridge
to generate the course. All right. So while it’s doing that, let’s
go and I’m going to show you a couple URLs. And I have provided these URLs at the end
of the presentation so don’t worry about writing them down as fast as you can. I’ve also put
them up on my blog and it’s also associated with the Jive Room that’s associated. I don’t
know, they are in there too. I had an easier time just putting it on my blog. Female 2: It’s right there. Justin Ball: What’s that? Female 3: It’s right here on the page. Justin Ball: It’s right here, okay, so you’ve
got it. Perfect. Awesome. So here is the source code. This is open source.
You can grab it, use it, modify it, tweak it, do anything you want with it. You can
host it yourself, if you find this tool useful. It’s really easy to put a up on HoDoKu, which
is a site that hosts Ruby, well, it hosts a lot of different technologies, but it is
free so that’s kind of cool. All right let’s see if this is getting closer.
So about 30%, okay. So while it’s thinking about that, we’re going to switch back over.
Okay, actually I’m going to ask, are there any questions related to that piece of it
so far? Female 4: I just have one quick question.
When you populate discussions can you populate who are users, put it up there so their avatar
is with it? Justin Ball: Okay. So the question is can
– when you populate the discussion can you use which user it was so that their avatar
shows up? And the answer is yes. So you I think in that spreadsheet when it has the
discussion you put in the user’s email. And then it says that was the user who posted
that discussion. Another question? Female 5: Can you also submit assignments
on behalf of people? Justin Ball: Okay. So the question is will
it submit an assignment on behalf of people? And the answer is yes. Female 5: Okay. Justin Ball: So in the assignments it sets
up the assignments and then it submits a bunch of assignments. So another question. Female 5: The log file that flew by does it
send it to a text file that you can peruse later if there’s a problem? Justin Ball: Okay. So the question – sorry
I’m repeating these. It’s not just because I have mental issues it’s because they are
recording it. The question was does the log file output to a text? It doesn’t. It just
saves it on the screen so you just copy and paste it. It wouldn’t be that hard actually
if you wanted to dump it log file, but yeah, you can just always copy and paste it. Another
question? Male 2: Sorry if this is getting ahead, but… Justin Ball: Oh you are good. Male 2: So what kinds of activity are there
discussions, assignments? Justin Ball: Okay. So the question is what
kinds of activity, discussion, assignments and the answer is both of those. It does discussions.
It does assignments. We started down the path of quizzes but it turns out quizzes are actually
pretty complicated because we have to generate the quizzes and then we’d have to go through
and fill out all the quizzes so we sort of punted because this was a small project and
we decided it just wasn’t – we just didn’t have enough time. The other thing that it does do is it logs
a student in and it will surf the site. So it browses pages. So then that’s important
probably mostly for the sales team because they want to show the analytics packages associated
with Canvas and so it’s important that you can show activity across the site. All right.
Anything else? Oh, back here. Male 3: Is this modular so that you could
not do something and do other things? Justin Ball: Okay. Is this is modular so you
can do some things and not others? And sort of. If you want go ahead and comment out some
code, yes. But there is not a checkbox – let’s see. Let me go back to what you can do here.
There are a couple of things that it lets you pick. Like do you want to generate the
welcome the Canvas course and then do you want to generate these courses? We originally
have a few other options on here. One was to install LTI tools. It does not show up
here because I don’t have one of the magic Instructure accounts. If you are an employee
at Instructure there’s a couple more options you get. Mainly because those are only relevant
to the guys inside of Instructure. But if you wanted to say modify this a little
bit. I don’t want to add this assignments. You would just go and in comment out a small
piece of code. So that’s why it’s open source and it’s most likely if you’re
going to reuse this you’re probably going to grab it, push it up on HoDoKu and run your
instance unless you want to install the courses that Instructure has already put together. So we’ll be at Hack Night. If you want to
come it. I’m happy to show you. And I am going to show a little bit of code here in
a minute to kind of talk just a little bit about this. So let’s see. There we go. I think it’s
all done. So before – here’s our Atomic Jolt Instance of Canvas. I didn’t have any
courses. If I refresh this and the Wi-Fi holds just a little bit longer. There it is, eighth
grade math. And you can see it’s added my last name, it says Ball on there. And there’s
the course. So that’s pretty cool. Now I didn’t have to do all that boring
stuff. And the next time I need to go test one of the tools that I just built, I can
just go here, say build all this stuff for me, and now I install whatever LTI tool I
am testing at the moment. And I have users that I can test with and everything’s unicorns
and roses and rainbows. Okay. So this is the coded heavy part. So
if you are a developer this should be exciting. At Atomic Jolt we use Ruby on Rails. We do
a lot of Java Script. That’s the same thing that the Instructure team uses to write all
of Canvas and we mirror that. All right, so let’s switch over to this.
Okay. First thing I wanted to show was just how we talk to Google Docs. Okay. Working
with Google can actually be a somewhat painful experience a lot of times. Yeah. I hear a
lot of people laughing. Yeah, hey I was just a Google I/O last week, two weeks ago whenever
it was, and there’s a lot of really really smart people, like, I actually worked in the
Google offices for a couple days and you walk – you sit next to somebody and they’re
like yeah, I just graduated from MIT. I just got done with Stanford. And I’m like okay
this explains to me. Really really smart people work there and
so they expect you to be really smart to work with their APIs I’ve decided and so sometimes
working with the Google APIs can be a little bit of a painful process. We’ve simplified
some of that and we have some libraries that can talk to Google APIs. So there’s this
wonderful protocol called OAuth. How many people are familiar with OAuth? Raise your
hands. Okay, so quite a few people. For anybody who’s not, you’ve probably
used it before. Any time you’ve ever logged into a website using Facebook login, you’ve
used OAuth. So same thing if you’ve logged into some website using Twitter and Canvas
implements OAuth. So if you want to work with the Canvas API then you need to talk to Canvas
via OAuth. And it turns out we’ve made that into a
relatively simple process. Where is my mouse? There we – ut oh. This is not good. Okay.
So the computer has locked up. So computers like, maybe it really doesn’t like to do
boring things. This never happens to Macs, ever. Male 4: Unplug your computer. Justin Ball: No I don’t really want to shut
down, but okay. Male 4: Try unplugging the digital. Justin Ball: Okay. We’re going to do this
really quick. And I’m going to keep talking about OAuth while I do this. So OAuth, when
you do OAuth with Canvas it’s different than when you do OAuth with somebody like
Facebook or Twitter. And the big difference is is that when you do an OAuth dance with
Facebook – sorry it’s going to restart here in just a second – you always authenticate
with the same Facebook. You always authenticate with the same Twitter and you always authenticate
with the same – whatever that system is that you’re using. With Canvas you have to authenticate with
your specific Canvas Instance. Right? So everybody, probably everybody in this room, you’re
running Canvas I’m assuming or maybe you’re piloting Canvas, you’re playing around with
Canvas. And so you have to say I want to do – I want to log into
or or whoever it is that’s using it you need to be able to talk that. So in order to facilitate that process we
actually wrote a Gem. Now a Gem is just a piece of code that is a library. It’s – how
many people use Ruby? Anybody? Okay. So there is some people familiar with Gems and if you’re
not it’s okay. It’s just a piece of code that you can reuse. So we created a piece of code that you could
reuse. This is not the right screen. All right. There we go. We create a Gem that makes it
really trivial to use the – to do the OAuth dance with Canvas. So if you want, that’s
also open source. It’s free and super simple to use. And I’ll show you just a couple
lines how to use that. So we use another thing called Devise. Don’t
worry too much about what Devise is other than it handles logins, okay? And with just
this small amount of code right here, okay, we can talk to Canvas. So it says we want
to use this OmniAuth which is another Gem that does OAuth for you. And when you do that
we will pass in this specific Canvas URL whether that comes from parameters meaning coming
from the URL. It comes from the session meaning a piece of memory that the computer can get
a hold of or if it’s just a static value that we set. So that way we’re able to pass
the specific or whatever your URL is and
that’s what Demo Arigato is using. So, go to another screen, go to Demo Arigato.
I’m going to sign out really quick and I’ll just demonstrate that. So on this screen right
here, Demo is the one that Instructure uses. If I type in Atomic Jolt, this is the beginning
of the OAuth dance. So Facebook login it would just be the Facebook connect button. You’ve
probably seen that. You just push the button, you go to Facebook, and it says, hey this
website wants to have access to everything that you’ve ever said, known, all your friends,
family, yeah anyway. And you say, no, whatever. In this case we have to type in the URL. I
hit login. And this will go out and say, hey, Demo Arigato wants to access your Canvas account.
And I say, sure. And by doing that now I have an API key. And with that API key that’s
what I can use to run all this magic, create all these courses and do all these interesting
things. All the code that does that is inside the
Demo Arigato application. And like I said, we’ll be at Hack Night, so if you want to
see the details on how all that works, come and talk to us. Happy to show you all that. All right, so getting back to the Google Docs,
now that my computer is more or less back alive. This is the magic right here is these
few lines down here at the bottom. Can you see this in the back? Do I need to make it
bigger? Good? Okay. Everything above this line, there’s all
this magic and all these things you’ve got do to be able to talk to Google Drive and
you have to get a token from Google and then you have to take that token, exchange it with
Google to get another token that you use to actually talk to the APIs and it only lasts
for 20 minutes and on and on and on. And I was like, no, this is too much work. So we
just wrote just method and we made the spreadsheets public and it turns out you can generate a
nice little URL right here that looks like this. And then you just have to give it a
Google – or you have to give it the ID of the actual spreadsheet and then you have to
give it the ID of the tab, that’s the carrots here and then you go out and you get it as
a CSV file and you parse it and you are done. Because this is so much simpler for people
who don’t want to have to like log into Canvas first and then log into Google Docs
as well. Okay? So by doing this there is another file where
we did some naughty things that I typically tell my developers not to do. But we just
hard coded some values. So that’s that really ugly value right there is the name of the
spreadsheet and the little, well they’re not little, the really long numbers below
that describe each of one those tabs and for this Instance that was fine because we’re
always going to talk to the same spreadsheet. So if you decide to use this tool, you’ll
want to go in and point and change these values to point to your spreadsheet on Google Docs.
Okay? So this makes it a little bit simpler you
just have to make your spreadsheets publicly readable, which hopefully doesn’t give you
too much heartburn. I can from the open content world. We shared everything, so. Everybody
just share everything and then we can all just be happy together. And then like I say, this just small piece
of code loads the stuff from the spreadsheets. If you do need to authentic with the Google
APIs and you want to do that whole thing, you can look at this piece of code up here.
And come talk to me and I can walk you through it. Okay, so I think I have 10 minutes, nine minutes
maybe. Male 5: Ten. Justin Ball: Ten. Okay. Any questions about
the code that I’ve shown so far. I realize I went through really fast and there’s probably
– might be a little confusing. Sorry about the computer issue. Yes? Male 6: You said make the spreadsheets public,
what did you really mean by that? Justin Ball: What did I mean by make the spreadsheets
public? So when you create a Google Document, you can go in and set the permissions to the
world can read it but not write to it. That’s what I mean. Set it world read. Male 6: The spreadsheet [inaudible] [22:23] Justin Ball: Yes, but it’s – they’re
not real email addresses and names. They’re all fake. Male 6: [Inaudible] [22:29] Justin Ball: Yeah. Male 6: For real…. Justin Ball: For a real one then you probably
need to go through some more pain. Yeah. So if you have real student data in here please
don’t make that public because somebody’s not like that very much. Right? You’re going
to get some phone calls. If you have real data and you’re populating
real students then you should do this stuff up here. And by that stuff up there what you
would do is go to this screen and add one more button. And it would say Authenticate
with Google. And I would put it like right here at the top. And you would push that button and that same
process that I showed you when I authenticated with Instructure. I pushed the button, right?
That’s all that would happen. You would push the button. It will drop you out on a
Google page. It will say Demo Arigato would like access to all of your Google Drive data.
And you would say yes. And then it would bounce you back here and then Demo Arigato would
be able to use the API token provided by Google to chat with the Google API to download that
spreadsheet. Now I said that pretty fast but that is probably
about three days’ worth of work. I’ll just warn you because you going to have to
go out and do some confusing things. Like you’ll have to go out your Google Developer
Console and you‘ll have to say I’m want to authorize this specific URL and I want
to allow it to talk to these APIs and it can be a little bit of a painful process. I’ve
done it a bunch of times so again I can walk through that because it’s nice to have a
little bit of handholding when deal with the Google APIs. Yes? Male 7: When you are designing these did you
go see if they were the same on local spreadsheet instead of Google spreadsheet? Justin Ball: Oh good question. So can you
use a local spreadsheet instead of a Google spreadsheet? Yes, but you would need to modify
the code. So at the end of the day, when all of the magic begins to happen, I have this
Canvas loads controller down here. Let’s see, you see I’ve just got these methods.
Sample courses, sample users, this is where the actual spreadsheets get loaded and you
can see that I’m doing Googledrive.loadspreadsheet. So that says please go talk to Google Drive
and pull down some CSV. So instead of using Google Drive you would just swap out that
code and say load a local CSV file. And you would do it that way. So you could either
upload as part of the project or if you want to get fancy you could add a file uploader
and then allow the user to upload the CSV files. That would take a little bit more work
and it takes away some of the magic of the one button click, but yes you can. Okay. Any other questions? Male 8: What are some of the common issues
you’ve seen using this? Justin Ball: Some of the common issues. So
the big common issue is that users put bad data into the spreadsheet. That’s the number
one thing that I’ve had happen. I’ve gotten a lot of emails. They’re like, such and
such was using the tool and bad things happened. Like the course wasn’t created or it will
create all the other users but it won’t create this one. And inevitably it was because
of some entry on the spreadsheet, whether that’s they did not use a URL that was public,
like for the common cartridge to create the course or a – the profile picture sometimes
they would make those private. And so then Canvas actually is the one who actually goes
out and retrieves the image and puts it in for the user and it couldn’t retrieve it,
so. Yes? Female 6: This is kind of an Instructure question.
But do you have documentation on how to set up the spreadsheets properly? No, I like to write code documentation stuff’s. I… Male 9: It’s open source. Justin Ball: It’s open source. It’s like
it contributes in documentation. I think that probably internally Jared has some instructions
that he’s talked about with the team maybe? I don’t know that for sure, but unfortunately
no. Copy, paste exactly. Yes? Male 10: I can come tonight and ask this,
but I’m really curious how you push surfing through a course through the API. Justin Ball: Oh that’s a good question.
So how do we surf through the API? And let’s see if I can remember. Maybe come tonight,
because I don’t remember right off hand. Sorry. There is a lot of code in here. But
yeah, I can – basically it’s you use the API to load a page. And I’ve got – I can
go and find the specific code but that’s basically how it works. Yes? Male 11: Are there are any set features in
the data? Justin Ball: No. That’s the problem. There
should be. There’s a couple. There’s some that make sure you don’t do really evil
things that can destroy stuff. But as far as verifying like that a URL is public I didn’t
add that. Maybe because verifying each URL is publicly accessible. It would take even
more time and so it already takes quite a while to run the tool and I didn’t want
to make it take twice as long to do all those sanity checks. But if we wanted to add that,
like if that was a really critical thing, it’s – that’s a super trivial thing
to add. Okay. So I’m going to post this really quickly.
This has all the different resources. If you go to my blog I have listed the resources
there too, it’s just Hopefully that’s fairly easy to remember. I have about 40 seconds so I will plug the
Canvas starter app. That’s a tool that we built at Atomic Jolt. So we’ve been doing
this for a very long time. Since Canvas became a thing when Instructure was just 10 people.
We’ve built one of the very first integrations with Canvas and so we took all of that knowledge
from all the years of building all these tools and we’ve put into one single open source
application. So if you want to build an LTI tool, if you want to do an integration with
the API, all of the details are in that application and that will get you probably 80 percent
of the way there. And then you can focus on the specific requirements to build your application
and not have to focus on how do I talk to the API? How do I implement LTI? How do I
do the OAuth dance? Like it’s just done. That’s open source. It’s MTI licensed.
You are welcome to take and use it, do anything you want with it, or you can come to Hack
Night, hang out with us, happy to introduce you to it, help you get set up and running.
It uses Ruby on Rails and it actually has React set up so if you have not heard of React,
it’s the new hot thing for building for single page applications. It’s the technology
that Canvas uses for its Java Script frontend framework, so you can kind of stay along with
the Instructure team. And with that I think my time is up. Yes.
Okay, if you have questions come find me. Thank you.

Add a Comment

Your email address will not be published. Required fields are marked *