Mapping the number of tasks to a course?

Viewed 22

I am developing a Springboot API for the school management systems. I have a student class that has a list of courses. The student in each course has to complete a certain amount of tasks to meet the requirements of that course. Let's say, course CS101 has 15 tasks to be completed, likewise, CS102 has 20 tasks to be completed. The student has to finish those tasks. I need to show the student, so far how many of them are done and how many of them remained. I am confused about how to show the number of tasks that are completed so far. The following JSON is my course list response for a specific student.

"course": [
            {
                "id": 1,
                "name": "CS101",
                "totalToComplete": 15
            },
            {
                "id": 2,
                "name": "CS102",
                "totalToComplete": 20
            },
         ]

The following response is my StudentProfileDto. Here, I will show all the information about the student including the list of courses that are taken and tasks that are completed in that course. As I mentioned above I just need to send a JSON response that shows the number of completed tasks in that course. For instance, in UI, students will see the text "You have finished 10 tasks out of 15 in CS101". I couldn't figure out how to send the response. I can send java codes upon request, otherwise, the question will be too long.

{
    "id": 1,
    "studentId": 20170602012, // I could've use this as a primary key :)
    "noProcedures": 0, // not relevant with the question
    "noPatientLogs": 0, // not relevant with the quesiton.
    "courses": [ // list of courses that are taken by students with id 1
        {
            "id": 1,
            "name": "CS101",
            "totalToComplete": 15
        },
        {
            "id": 1,
            "name": "CS102",
            "totalToComplete": 20
        }
    ],
  
}
0 Answers
Related