rage / mooc.fi

https://mooc.fi
5 stars 6 forks source link

/api/progress returns unexpected data #521

Closed Technopathic closed 4 years ago

Technopathic commented 4 years ago

The new /api/progress endpoint returns the same data from a course no matter what the user token is. Endpoint:

https://www.mooc.fi/api/progress/e1eaff32-8b2c-4423-998d-d3477535a1f9

Tokens used:

fee41f0fac48f2766fb6f2c6150df0fa3dbba8c61038c4e7ad2f981b04976c05
7815336336d70f29157a3b49eddbd808f7173c7530d05a99eb0c687eb31f9926

data returned for both:

{
    "data": {
        "184989df-1b40-4cfc-bf49-ffdd3b70400c": {
            "exercise_id": "184989df-1b40-4cfc-bf49-ffdd3b70400c",
            "n_points": "1.000000000000000000000000000000",
            "part": 1,
            "section": 3,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "202618dc-52fd-5977-a942-b814f6d7e35b"
        },
        "79323a2a-f830-4cfa-9c36-5c4e53b061c0": {
            "exercise_id": "79323a2a-f830-4cfa-9c36-5c4e53b061c0",
            "n_points": "0.000000000000000000000000000000",
            "part": 1,
            "section": 3,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "e97eaf29-d6d8-5837-9db1-2a1dec51a1a1"
        },
        "5b0c617f-1850-4cab-8c32-42b60f4c8527": {
            "exercise_id": "5b0c617f-1850-4cab-8c32-42b60f4c8527",
            "n_points": null,
            "part": 1,
            "section": 2,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "1e4af21e-7734-5282-a070-cc464a376e81"
        },
        "d86bd3d3-0e2e-4247-a2f0-dc5d4323139c": {
            "exercise_id": "d86bd3d3-0e2e-4247-a2f0-dc5d4323139c",
            "n_points": "1.000000000000000000000000000000",
            "part": 1,
            "section": 3,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "3ae47ac2-d2d7-5d3c-8823-dc6e32728340"
        },
        "49e353dd-03de-42e7-b072-aa2c75534c9c": {
            "exercise_id": "49e353dd-03de-42e7-b072-aa2c75534c9c",
            "n_points": "1.000000000000000000000000000000",
            "part": 1,
            "section": 3,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "97339e0e-6dfc-59ea-8338-b516dee0b893"
        },
        "cdbbb07c-6114-4364-8c46-fe5063e1dd64": {
            "exercise_id": "cdbbb07c-6114-4364-8c46-fe5063e1dd64",
            "n_points": "1.000000000000000000000000000000",
            "part": 1,
            "section": 2,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "7252cbff-92b4-5766-9f9c-64558a577de2"
        },
        "c86f731d-f326-41b6-b773-19fdfd558681": {
            "exercise_id": "c86f731d-f326-41b6-b773-19fdfd558681",
            "n_points": "1.000000000000000000000000000000",
            "part": 3,
            "section": 1,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "db4b9a3f-6a6d-57a6-bcd1-d247685d55e7"
        },
        "d2d83fb3-8f38-4824-8469-04548a43aa88": {
            "exercise_id": "d2d83fb3-8f38-4824-8469-04548a43aa88",
            "n_points": "1.000000000000000000000000000000",
            "part": 2,
            "section": 1,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "cd59d296-8f49-5ff5-97b3-d9d274a555e0"
        },
        "9cee1bfa-90ff-49a9-b534-f7a0b99d2918": {
            "exercise_id": "9cee1bfa-90ff-49a9-b534-f7a0b99d2918",
            "n_points": "1.000000000000000000000000000000",
            "part": 2,
            "section": 1,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "43123f05-dec1-5c84-909a-e20e8ce30c63"
        },
        "4afa227f-fab9-48a6-bb42-fb872be5137e": {
            "exercise_id": "4afa227f-fab9-48a6-bb42-fb872be5137e",
            "n_points": "1.000000000000000000000000000000",
            "part": 2,
            "section": 2,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "2537e870-4b2e-57c9-9b90-83f63e58d8c6"
        },
        "d18e8f30-9f00-4b2e-9655-ffede70fe329": {
            "exercise_id": "d18e8f30-9f00-4b2e-9655-ffede70fe329",
            "n_points": "0.000000000000000000000000000000",
            "part": 5,
            "section": 0,
            "max_points": 0,
            "completed": true,
            "quizzes_id": "836dae15-6755-416e-82e8-508afa5b6854"
        },
        "65d6fc6c-0546-4373-a3e3-ae7bf291add1": {
            "exercise_id": "65d6fc6c-0546-4373-a3e3-ae7bf291add1",
            "n_points": "0.166666666666666660000000000000",
            "part": 4,
            "section": 2,
            "max_points": 1,
            "completed": true,
            "quizzes_id": "48f05b72-10fd-5c83-b5a8-c104c7636376"
        }
    }
}
nygrenh commented 4 years ago

I think at the moment it's returning the exercise completions for all users whereas it's supposed to only return those who belong to the current user.

mipyykko commented 4 years ago

Yup, that's what happened. I'm not sure if the users are supposed to exist in the database at the moment they're queried, so I might need to add user creation for that as well.