/markbot-server

A small PHP proxy application for adding grades into Canvas after Markbot checks pass.

Primary LanguagePHPMIT LicenseMIT

This application is no longer maintained. Markbot favours submitting directly to Learn the Web’s progress tracking app.

Markbot Server

A small PHP proxy application for adding grades into Canvas after Markbot checks pass.

Students will fork assignment repositories from GitHub, make their changes, and drop their folder into Markbot.

After those tests pass, this application is called with specific information to mark their assignment complete inside Canvas.


Why not build this into Markbot?

Well, I suppose I have a few reasons:

  1. To keep my teacher Canvas API key secure, I’d rather it not be embedded in every Markbot build.
  2. To control who can submit to Canvas by controlling the accepted list.
  3. To avoid students having to figure out their Canvas user ID.

In the first day of class I create a Canvas assignment where they hand in their GitHub profile URL. I can then use the Canvas API to grab all those submissions and parse out the GitHub username and Canvas ID to generate the user map.


Quick setup

It’s a small single page application that expects a query string of parameters. It’s capable of running on Google App Engine, but is not necessary.

config.example.php — Rename to just config.php and enter your API authentication keys & your passcode hash generated by Markbot.

'canvas_base_url' => 'CANVAS_SUB_DOMAIN', // example: algonquin.instructure.com
'canvas_api_key' => 'CANVAS_API_KEY',
'passcode_hash' => 'YOUR_MARKBOT_LOCK_PASSCODE_HASH',

Fill in a mapping of what string you want to use in your .markbot.yml files to what the Canvas ID is. This is an automation step so that you don’t have to change all the assignments every year when there’s a new Canvas course ID.

'courses' => [
  'web-dev-1' => 'CANVAS_COURSE_ID',
],

user-map.example.php — Rename to just user-map.php. Fill with mappings of GitHub usernames to Canvas user IDs.

$user_map = [
  'github-username' => 'canvas-id-number'
];

Use

Make a GET request to the grade.php file (or the /grade route if using Google App Engine) with the following query string parameters:

  • gh_repo — The GitHub repo name
  • gh_username — The students GitHub username for matching against their Canvas ID
  • canvas_course — The string mapped to the Canvas ID in config.php
  • markbot_version — The version of the Markbot app that sent this request—to help prevent students from using outdated versions
  • cheater — 0 or 1: whether the student cheated on the assignment
  • sig — A sha512 hash of all the previous parameters & the hashed passcode

Example request

/grade?gh_repo=using-markbot&gh_username=thomasjbradley&canvas_course=web-dev-1&markbot_version=3.6.2&cheater=1&sig=ec17e2bf78a4ee76d7467adfdf6d9567bbbf2f2c0e6e70744b8925136e1642b3156da453795cdebe6311df3857e6a45343abb686c99bdd15d25cee86c55abe60

Setting up assignments in Canvas

In an attempt to prevent a super maintenance overhead of Canvas assignments and constantly having to change IDs, I’ve decided to hack some information into the Canvas assignments.

Each assignment that you create on Canvas, should be set to “No submission” because Markbot will be doing the assignment submissions. But the ID for the assignment isn’t stored anywhere—only the repo slug.

So, in each assignment, I store the repo slug in the allowed_extensions field—Markbot server will search through all the assignments in the course and pick out the one with a matching entry in allowed_extensions and will submit the grade to that assignment.


License & copyright

© 2016 Thomas J Bradley — MIT License.