Skip to content

Communication with the API

Taikelenn edited this page Oct 22, 2021 · 9 revisions

Overview

This page lists all A+ API endpoints that are accessed by the plugin. Unless otherwise specified, all calls to A+ API are HTTP GET requests and are authenticated using the token provided by the user. The plugin expects all requests to succeed (200 OK) - error codes are always some kind of failure (perhaps an invalid token, perhaps the user is not enrolled in the course or the server might be experiencing issues)

Pagination

Some requests are marked as paginated. This means that they don't return all the results at once - instead, they just return a limited number of results and provide a URL which may be accessed to fetch the next batch of results.

Endpoints

Endpoint: Get user instance

Endpoint URI: https://plus.cs.aalto.fi/api/v2/users/me/

This is used in two ways:

  1. When the user provides an authentication token, this API is called as a simple check for the token's validity.
  2. This API returns the user's name, which we display in the top right corner of the A+ Courses tool window.

Endpoint: Get course instance

Endpoint URI: https://plus.cs.aalto.fi/api/v2/courses/{courseId}/ where courseId is an integer representing the course ID (e.g. 197 = Ohjelmointi 1, 2021 edition)

This endpoint returns a list of URLs which we can access to get detailed information about the course and the user's progress. The contents of this API are reflected in the plugin's class APlusExerciseDataSource.

Endpoint: Get course exercises list

Endpoint URI: https://plus.cs.aalto.fi/api/v2/courses/{courseId}/exercises/ where courseId is an integer representing the course ID.

This endpoint is used to get the list of exercises in the course. Note that it doesn't contain the actual exercise details - it only has the chapter names, exercise names, submission count and some other metadata. This data is used to fill the Assignments view in the A+ Courses tool window. When a user expands some chapter, detailed data is fetched using other endpoints.

Endpoint: Get course points

Endpoint URI: https://plus.cs.aalto.fi/api/v2/courses/{courseId}/points/{userId}/ where courseId is an integer representing the course ID, and userId is EITHER the A+ user ID OR the string "me" which indicates the current user.
Note: to view other users' points, the calling user must have appropriate permissions.

This endpoint returns a list of exercises with all user's submission metadata included. This data is used to further populate the Assignments view - it provides information such as user's current points for each exercise, or the submission list.

Endpoint: Get exercise data

Endpoint URI: https://plus.cs.aalto.fi/api/v2/exercises/{exerciseId}/ where exerciseId is an integer representing the exercise ID.

This endpoint is used to get detailed information about a single exercise. The plugin utilizes lazy loading of assignments, which means that the exercises (and submissions) are loaded only when the corresponding chapter is opened. The endpoints returns various information, but for the plugin the most important piece of data is the list of submittable files.

Endpoint: Get submission data

Endpoint URI: https://plus.cs.aalto.fi/api/v2/submissions/{submissionId}/ where submissionId is an integer representing the submission ID.
Note: to view other users' submissions, the calling user must have appropriate permissions.

This endpoint is used to get information about a submission. This is invoked so that when the user expands the tree item representing some exercise, they can view their own submissions.

Endpoint: Get student list

Endpoint URI: https://plus.cs.aalto.fi/api/v2/courses/{courseId}/students/ where courseId is an integer representing the course ID.
Note: requires appropriate permissions set on the A+ side.
This endpoint is paginated.

This endpoint is used to get the list of students that are enrolled on a particular course. It is used exclusively in the plugin's Assistant Mode - the assistant can view the list and select any enrolled student. This allows the assistant to easily access the selected student's submissions.

Endpoint: Get user's groups

Endpoint URI: https://plus.cs.aalto.fi/api/v2/courses/{courseId}/mygroups/ where courseId is an integer representing the course ID.

This endpoint is used when a user invokes the assignment submission dialog. Because some courses allow submitting exercises in groups (in addition to submitting alone), the plugin reaches out to this endpoint in order to fetch the list of the groups that the user is in. They can later choose the group in the submission dialog.

Endpoint: Send submission

Endpoint URI: https://plus.cs.aalto.fi/api/v2/exercises/{exerciseId}/submissions/submit/ where exerciseId is an integer representing the exercise ID.
This is a POST request.

This endpoint is responsible for submitting exercises. It is sent after the user has confirmed the submission in the dialog. The endpoint returns the URL of this new submission, so that the plugin can periodically query this submission to provide real-time updates on its grading process.