Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
I'm at InstructureCon right now and have met people from a couple other institutions who are doing Canvas things in Java. I thought I would start a discussion here to see how many others there are out there.
Some background on where I'm coming from: I'm at Kansas State University and we are in the middle (hopefully towards the end) of our move from a home-grown LMS to Canvas. We have been writing some LTI applications to replicate functionality that was in our old LMS but is lacking in Canvas. Some things we are working on:
1) A replacement for the "People" page that has more information about students from our internal identity management database. I've seen at least two other institutions here at the conference who are doing something similar.
2) Scantron integration. We are still working out the details on how this will work because Canvas doesn't quite support some things we would like to do. But we did get a good alternative idea at the hack day on Tuesday here at the conference so we'll see how that plays out.
3) A replacement for the "Publish Grades to SIS" link in the grade book. It will check for common errors that prevent grade postings from going through and hold instructors' hands through the process better than the native Canvas functionality. (we use PeopleSoft)
We are a Java shop and are using Spring MVC and Spring security to handle authenticating the LTI launch request. I wrote some common code that handles that stuff so making a new LTI application isn't overly difficult.
One thing I would love to see happen is an open source Java library for talking to the Canvas API. The API interactions we are doing right now only involve a couple of endpoints and is integrated into our LTI code base but I might be able to get some time to work on pulling it out into an external library and fleshing it out. We'll see.
Any other thoughts on Java+Canvas out there?
Solved! Go to Solution.
Another update. Today I wrote a blog post on here announcing our API library code being released under the LGPL v3 license. Please chime in: https://community.canvaslms.com/groups/canvas-developers/blog/2017/01/25/java-library-for-accessing-...
Huh. this posted as a question. I clicked on the "Start a discussion" link which didn't seem to imply a question. Should I have done it as a blog post instead? Live and learn I guess.
I think posting this as a question is right. You may find https://github.com/kajigga/canvas-contrib/tree/master/SIS%20Integration/java interesting. It is an open-source java class (I think) for interacting with Canvas' SIS import API. I'm not intimately familiar with it myself, but you may find it useful.
Just as an update to this post: I did find Northwestern is also using Java to interact with the Canvas API. I found this by reading a response in another thread. However after looking at their code a little bit it seems like they wrote it much the way we wrote our first bit of LTI/Canvas API code. It is heavily coupled with and in the same repository as other things.
In the last couple of days we here at K-State have been working on separating out our API code into a separate project. The goal is to develop a library that can be used similarly to libraries for the Twitter/Facebook/etc API that are out there. A completely stand-alone .jar file that can be included in any Java project and will return plain domain objects in response to methods that invoke Canvas API calls. It will handle things like API pagination and the low level HTTP communications for you but won't make any assumptions about what kind of application you are writing or what kind of container you are running in.
I hope to have something to show within a week or two.
We're interested in something similar here at Indiana University. We have had some conversations internally about packaging up our code into a standalone library, but it hasn't gotten any priority. I think there are also some conversations that need to happen regarding licensing of code and so forth. But, if you get to something first, we might be willing to take it for a test drive (and potentially contribute if there are gaps), but that may also depend on licensing and things that are determined by folks higher up the org chart!
Chris
We have made some progress but it hasn't been prioritized for the last couple of sprints. The way we initially structured our whole LTI project was... "unfortunate" so we've been having to work on pulling the API code out into a separate module just for our own sanity. Turns out, after you make a couple of successful LTI applications, people are like "oh hey that's neat. Let's make some more!"
We actually had some thoughts about trying to go a little insane on this thing and try to parse the Canvas ruby code and automatically generate a java interface based on the code that actually runs the API on the Canvas side. This would be about the only way to actually get feature complete on all possible API calls since there are so many... But I'm not sure how feasible it really is. One of our guys is kind of interested in that kind of language theory thing so we'll see if he comes up with something
Another update. Today I wrote a blog post on here announcing our API library code being released under the LGPL v3 license. Please chime in: https://community.canvaslms.com/groups/canvas-developers/blog/2017/01/25/java-library-for-accessing-...
Hi Tobias and others,
Having written the code you mention above (from Northwestern), I agree with your desire to separate out the 'Canvas API functionality' in a separate jar file. This should be extremely useful for other Java-Canvas projects. I am not sure how soon I will be able to spend time on it, but I think it shouldn't be very difficult to do (I have one main class for making the Canvas API calls in the open source package above - what I called the CanvasAPISubmissionDispatcher, so it's just a question of making sure all the dependencies for that class are also included in the resulting jar). Will let you know if I get to accomplish this in the near future. Thanks for your post. And of course, let the group know if you also come up with something to share. Great Post/question.
Update on this topic:
We have started actually putting some effort into this. We have the bare basics of an API library working. It handles pagination (with the option of getting a callback every time a chunk of results comes back), can masquerade (using either Canvas user ID or SIS user ID) and can take various optional parameters to some of the API endpoints.
As of right now we only have a couple of endpoints working but it isn't too hard to add more. Unfortunately there are hundreds of them so I don't know if we will ever really be complete since the Canvas API is always evolving.
We are heavily using Java 8 features (lambdas, stream API, Optionals) - sorry if you're still running java 6/7... time to upgrade!
So for example, to get a list of users in a course while masquerading as a user using their SIS ID, it takes 3 lines of code:
CanvasApiFactory apiFactory = new CanvasApiFactory("https://institution.test.instructure.com");
UserReader userReader = apiFactory.getReader(UserReader.class, "myOauthToken");
List<User> courseUsers = userReader.readAsSisUser("12345678").getUsersInCourse("123", Collections.emptyList(), Optional.empty(), Collections.emptyList());
System.out.println("users in course: " + courseUsers.size());
The empty lists/optional are optional parameters that the "list users in course" API endpoint can take like enrollment type, optional fields to include. Although looking at the API documentation, I think we are missing several new options that have been added and if we just keep adding lists and optional parameters it will likely get confusing so we might have to rethink something here.
Anyway, I suppose I should probably initiate a conversation with the lawyers about licensing if we want to open source this. I'm guessing that won't be a short process.
To participate in the Instructure Community, you need to sign up or log in:
Sign In