-
Notifications
You must be signed in to change notification settings - Fork 0
API
In the following article, the API is documented.
The attribute role definies, which User-Role can access the individual interface.
To authenticate a user, they must send a JWT with each request.
To send the JWT, the header Authorization must be set with the following format: Bearer <token>.
The JWT is signed with a random 64-Byte Token, which will be regenerated at every restart of the server.
It expires after 12 Hours.
{
"id":user_id,
"username":"username",
"fullname":"fullname",
"role":"student"|"teacher"|"administrator",
"exp":time_to_expire
}
The middleware verifies and decodes the delievered JWT, if the request is not to /user/login.
If the JWT could not be verified, a response with the HTTP-Status 401 and the message Invalid JWT is send.
Register a new user
administrator
{
"username":"username",
"password":"password",
"role":"student"|"teacher"|"administrator",
"fullname":"fullname",
"address":"address",
"matriculationNumber":"matriculationNumber",
"mail":"[email protected]"
}
It may be noticed, that the role will default to student, if none of the role listed above is used.
On success returns the HTTP-Status 200.
On failure returns the HTTP-Status 403.
Try to login a user
Unauthenticated users
{
"username":"username",
"password":"password
}
On success returns the HTTP-Status 200 and a JWT for authentication.
On failure returns the HTTP-Status 403 and the message Wrong username or password.
Deletes a user from the repository
administrator
{
"username":"username"
}
On success returns the HTTP-Status 200 and the message The user has been deleted.
On failure returns the HTTP-Status 500 and the message The user could not be deleted.
Change the password of the given user
student & teacher may only change their own password.
administrator may change their own password as the password of other users.
{
"username":"username",
"password":"password
}
On success returns the HTTP-Status 200 and the message The password has been changed.
On failure returns the HTTP-Status 500 and the message Password could not be changed.
Get all users
administrator
No request data
An array of the following JSON-Objects
{
"id": 5,
"fullname": "fullname",
"address": "address",
"matriculationNumber": "matriculationNumber",
"mail": "[email protected]",
"userId": {
"id": 14,
"username": "username",
"isTeacher": false|true,
"isAdministrator": false|true
}
}
Returns the grades of the student specified in :studentId
student may only see his own grades
administrator may see the grades of all students
No request data
An array with the following JSON-Objects
{
"grade": 3,
"weight": 100,
"moduleId": {
"id": 1,
"name": "Test",
"description": "Test"
}
}
Insert or update a new grade
teacher may insert or update new grades for his module
administrator may insert or update new grades for every module
{
"id":1, // Only needed if updating a existing grade
"moduleId":1,
"studentId":1,
"grade":1,
"weight":100
}
On success returns the HTTP-Status 200 and the message The grade has been saved.
On failure returns the HTTP-Status 500 and the message The grade has not been saved.
Delete the grade
teacher for their own modules
administrator for every module
{
"id":1, // Only needed if updating a existing grade
"moduleId":1,
"studentId":1,
"grade":1,
"weight":100
}
On success returns the HTTP-Status 200 and the message The grade has been deleted.
On failure returns the HTTP-Status 500 and the message The grade could not be deleted.
Insert or update a new entry into the timetable
teacher can insert entries for their module
administrator can insert entries for every module
{
"id":1, // Only needed if updating a existing entry
"startTime":Date,
"endTime":Date,
"assignedModule":1,
"description":"description", // can be null
"room":"A38"
}
On success returns the HTTP-Status 200 and the message The entry has been saved.
On failure returns the HTTP-Status 500 and the message The entry could not be saved.
Retrieve entries for a person
teacher may get the entries for their modules
student may get the entries for their assigned course
No request data
A array with the following JSON-Objects
{
"id": 2,
"startTime": "2022-02-02T11:30:19.490Z",
"endTime": "2022-02-02T12:30:19.490Z",
"description": null,
"room": "A13",
"assignedModule": {
"id": 1,
"name": "tset",
"description": "Test",
"assignedCourse": {
"id": 1,
"name": "test"
}
}
}
Retrieve entries for a module, specified by :moduleId
tbd
No request data
A array with the following JSON-Objects
{
"id": 2,
"startTime": "2022-02-02T11:30:19.490Z",
"endTime": "2022-02-02T12:30:19.490Z",
"description": null,
"room": "A13",
"assignedModule": {
"id": 1,
"name": "tset",
"description": "Test"
}
}
Retrieve entries for a module, specified by :courseId
tbd
No request data
A array with the following JSON-Objects
{
"id": 2,
"startTime": "2022-02-02T11:30:19.490Z",
"endTime": "2022-02-02T12:30:19.490Z",
"description": null,
"room": "A13",
"assignedModule": {
"id": 1,
"name": "tset",
"description": "Test",
"assignedCourse": {
"id": 1,
"name": "test"
}
}
}
Delete a entry
teacher may delete the entries of their own module
administrator may delete all entries
{
"id":1,
"startTime":Date,
"endTime":Date,
"assignedModule":1,
"description":"description", // can be null
"room":"A38"
}
On success returns the HTTP-Status 200 and the message The entry has been deleted.
On failure returns the HTTP-Status 500 and the message The entry could not be deleted.
Change the name of a course
administrator
{
"name":"coursename",
"newName":"newCoursename"
}
On success returns the HTTP-Status 200 and the message The course has been updated.
On failure returns the HTTP-Status 500 and the message Course could not be updated.
Register a new course
administrator
{
"name":"coursename",
"students":"list of student_id"
}
On success returns the HTTP-Status 200.
On failure returns the HTTP-Status 403.
Delete a course
administrator
{
"name":"coursename"
}
On success returns the HTTP-Status 200 and the message The course has been deleted.
On failure returns the HTTP-Status 500 and the message Course could not deleted updated.
Add students to a course
administrator
{
"name":"coursename",
"students":"list of student_id"
}
On success returns the HTTP-Status 200 and the message The students have been added.
On failure returns the HTTP-Status 500 and the message Students could not be added.
Remove students from a course
administrator
{
"name":"coursename",
"students":"list of student_id"
}
On success returns the HTTP-Status 200 and the message The students have been removed.
On failure returns the HTTP-Status 500 and the message Students could not be removed.