$ ./grades
English: 12.34%
Maths: 56.78%
Science: 90.12%
History: --
See also the Elvish version.
Tested on xh v0.10.0–v0.14.1 and fx v20.0.2.
- Get an API token
https://example.instructure.com/profile/settings
→ ‘Approved Integrations’ → ‘New Access Token’
export HOST=example.instructure.com # replace with actual host
export CANVAS_TOKEN='<your API access token>'
Replace <courseId1>
, <courseId2>
, etc. with the ids of the courses that you want to get
the grades of. The id of the course can be found by looking at the course’s URL:
https://example.instructure.com/courses/courseId
.
xhs $HOST/api/graphql Authorization:"Bearer $CANVAS_TOKEN" query="{
legacyNode(_id: \"$(xhs $HOST/api/v1/users/self Authorization:"Bearer $CANVAS_TOKEN" | fx .id)\", type: User) {
...on User {
Subject1: enrollments(courseId: \"<courseId1>\") { id }
Subject2: enrollments(courseId: \"<courseId2>\") { id }
}
}
}" | fx .data.legacyNode
The result will be something like this:
{
"Subject1": [
{
"id": "<enrollmentId1>"
}
],
"Subject2": [
{
"id": "<enrollmentId2>"
}
]
}
Use these ids (<enrollmentId1>
, <enrollmentId2>
, etc.) in query.graphql
.
- Align 100%/<10% grades correctly
- Automate getting enrollment IDs