- Route
/: page containing the menu with the options available according to the type of authenticated user. In case the user is not authenticated the user is redirected to the login page - Route
/new-homework: page containing the form for creating a new homework, the content shown is a text-area for the question and the list of all students to choose from to form the group. (This route can only be used by users with teacher role) - Route
/students: page containing the list of the entire class, with information about homeworks and the average score. A sorting option is also available to organize the list by different criteria. (This route can only be used by users with teacher role) - Route
/homeworks: page containing a list of homeworks as cards, each showing key information. The content updates dynamically based on the user type or request. In particular, there is a filter parameter that can have 2 different values:/homeworks?filter=ready: shows homeworks that already have an answer and are ready to be evaluated. (Used by teacher)/homeworks?filter=close: shows homeworks that are closed and displays a dashboard with the average score of the authenticated student. (Used by student)
- Route
/homeworks/:id: page containing the detail of a single homework. The content changes dynamically so that a student can provide an answer and a teacher can grade it. The id is used to uniquely identify the homework displayed
URL: /api/homeworks
HTTP Method: GET.
Description: Retrieve all homeworks of the current teacher.
Query Parameters:
filter(optional):readyto get only homeworks ready to be graded (with all answers submitted)
Response: 200 OK (success) or 500 Internal Server Error (generic error).
Response body:
[
{
"id": 1,
"question": "Quanto fa 4 + 4?",
"answer": "Fa 8!",
"state": "close",
"score": 20.0,
},
...
]
Authorization (user role): teacher
URL: /api/homeworks
HTTP Method: POST.
Description: Create a new homework for a group of students.
Request body:
{
"question": "Quanto fa 4 + 4?",
"studentsIds": [5,7,20]
}
Response: 201 Created (succes, with the created id), or 500 Internal Server Error (generic error). If the request body is not valid, 422 Unprocessable Entity (validation error).
Response body: None
Authorization (user role): teacher
URL: /api/homeworks/<id>
HTTP Method: GET.
Description: Retrieve the homework represented by <id>.
Response: 200 OK (success), 403 Forbidden (unauthorized access), 404 Not Found (wrong id), or 500 Internal Server Error (generic error).
Response body:
{
"id": 1,
"question": "Quanto fa 4 + 4?",
"answer": "Fa 8!",
"state": "close",
"score": 20.0,
"teacherName": "Mario",
"teacherSurname": "Rossi",
"group": [
{
"id": 2,
"name": "Mario",
"surname": "Rossi"
},
{
"id": 3,
"name": "Edoardo",
"surname": "Cecchini"
}
...
]
}
Authorization: authenticated
URL: /api/homeworks/<id>/score
HTTP Method: PATCH.
Description: Insert a score for the homework represented by <id>.
Request body:
{
"score": 0
}
Response: 204 No content (succes), 400 Bad Request (no answer), 404 Not Found (wrong id) or 500 Internal Server Error (generic error). If the request body is not valid, 422 Unprocessable Entity (validation error).
Response body: None
Authorization (user role): teacher
URL: /api/students
HTTP Method: GET.
Description: Retrieve all students.
Response: 200 OK (success) or 500 Internal Server Error (generic error).
Response body:
[
{
"id": 1,
"name": "Edoardo",
"surname": "Cecchini",
"email": "s339169@studenti.polito.it",
},
...
]
Authorization (user role): teacher
URL: /api/students/stats
HTTP Method: GET.
Description: Retrieve for all the students, how many open homework, how many closed homework, and the average score they got in the homework assigned by the current teacher.
Response: 200 OK (success) or 500 Internal Server Error (generic error).
Response body:
[
{
"id": 1,
"name": "Edoardo",
"surname": "Cecchini",
"email": "s339169@studenti.polito.it"
"openHomeworks": 5,
"closeHomeworks": 20,
"averageScore": 27.5
},
...
]
Authorization (user role): teacher
URL: /api/students/<id>/homeworks
HTTP Method: GET.
Description: Retrieve all the open homeworks assigned to the student represented by <id>.
Response: 200 OK (success), 404 Not Found (wrong id), or 500 Internal Server Error (generic error).
Response body:
[
{
"id": 1,
"question": "Quanto fa 4 + 4?",
"answer": "Fa 8!"
},
...
]
Authorization (user role): student
URL: /api/homeworks/<id>/answer
HTTP Method: PATCH.
Description: Send an answer for the homework identified by <id>.
Request body: A JSON object representing the action.
{
"answer": "Fa 8!"
}
Response: 204 No content (success), 400 Bad Request (homework close), 404 Not Found (wrong id) or 500 Internal Server Error (generic error). If the request body is not valid, 422 Unprocessable Entity (validation error).
Response body: None
Authorization (user role): student
URL: /api/students/<id>/homeworks/stats
HTTP Method: GET.
Description: Retrieve the scores and the total average score for all the closed homeworks assigned to the student represented by <id>.
Response: 200 OK (success), 404 Not Found (wrong id) or 500 Internal Server Error (generic error). In case of success, returns an array of questions in JSON format (see below). Else, returns an error message.
Response body:
{
"homeworks": [
{
"id": 1,
"question": "Quanto fa 4 + 4?",
"answer": "Fa 8!",
"state": "close",
"score": 28
},
...
],
"averageScore": 27.5
}
Authorization (user role): student
URL: /api/sessions
HTTP Method: POST.
Description: Authenticate a user with email and password using Passport.
Request body:
{
"username": "user@example.com",
"password": "password123"
}
Response: 201 Created (success), 401 Unauthorized (wrong credentials), or 500 Internal Server Error (generic error).
Response body:
{
"id": 1,
"name": "Marco",
"surname": "Rossi",
"email": "marco.rossi@student.it",
"role": "student"
}
URL: /api/sessions/current
HTTP Method: GET.
Description: Get information about the currently authenticated user.
Response: 200 OK (authenticated) or 401 Unauthorized (not authenticated).
Response body:
{
"id": 1,
"name": "Marco",
"surname": "Rossi",
"email": "marco.rossi@student.it",
"role": "student"
}
Authorization (user role): authenticated
URL: /api/sessions/current
HTTP Method: DELETE.
Description: Logout the current user and destroy the session.
Response: 200 OK (success) or 500 Internal Server Error (generic error).
Response body: None
Authorization (user role): authenticated
-
Table
users
Contains all registered users. Fields:id(PK) – unique identifiername– first namesurname– last nameemail– email address (username used for login)password– hashed passwordsalt– per‑user salt for hashingrole– user type (teacherorstudent)
-
Table
homeworks
Stores each homework assignment. Fields:id(PK) – unique identifierquestion– the homework questionanswer– group's submitted answer (nullable until answered)state– status (openorclose)score– numeric grade from 0 to 30 (nullable until graded)teacherId(FK →users.id) – the teacher who created it
-
Table
student_homework
Join table linking students to homeworks, also used to manage groups. Fields:id(PK) – unique identifierstudentId(FK →users.id) – the student assignedhomeworkId(FK →homeworks.id) – the homework assigned
HomeworkList(inHomeworkList.jsx): Displays a filtered list of homeworks as cards with different views based on user role (teacher/student) and filter parameters (close/ready)HomeworkCard(inHomeworkCard.jsx): Individual homework card component showing question preview, answer status, state badge, and score with click navigation to detail viewHomeworkDetail(inHomeworkDetail.jsx): Detailed homework view allowing students to submit/edit answers and teachers to grade submissions, with role-based authorization checksNewHomeworkForm(inNewHomeworkForm.jsx): Form component for teachers to create new homework assignments with question input and student group selectionStudentList(inStudentList.jsx): Displays class statistics with sortable student cards showing the number of open homework, close homework and the average scores, includes filtering options (alphabetical, total homeworks, average score)Home(inHome.jsx): Dashboard component with role-based navigation buttons providing access to different homework management actionsNavHeader(inNavHeader.jsx): Navigation bar with role-based menu items (Class tab only for teachers)DefaultLayout(inDefaultLayout.jsx): Layout wrapper component providing consistent user interfaceAuthComponents(inAuthComponents.jsx): ContainsLoginFormfor user authentication andLogoutButtonAuthContext(inAuthContext.jsx): React Context provider managing global authentication state and providing user access and login/logout functionality throughout the applicationRequireRole(inRequireRole.jsx): Wrapper component for role-based route protection, restricting access based on user role (used to prevent students from accessing teacher routes)Utils(inUtils.jsx): Utility components includingConfirmModalfor confirmation dialogs,NotFoundfor 404 pages, andNotAuthorizedfor access denied messages
(password = student123)
- luca.ferrari@student.it
- marco.rossi@student.it
- giulia.bianchi@student.it
- alessandro.verdi@student.it
- francesca.neri@student.it
- martina.romano@student.it
- davide.gallo@student.it
- chiara.conti@student.it
- matteo.ricci@student.it
- sara.marino@student.it
- federico.greco@student.it
- elena.bruno@student.it
- simone.gatti@student.it
- valentina.rizzo@student.it
- andrea.lombardi@student.it
- beatrice.moretti@student.it
- gabriele.barbieri@student.it
- alessia.fontana@student.it
- nicola.santoro@student.it
- giorgia.caputo@student.it
- maria.ricci@teacher.it, teacher123
- giuseppe.bianchi@teacher.it, teacher321

