Closed lkeegan closed 1 month ago
The questions that the user should answer about themselves are modelled in the database by UserQuestion:
UserQuestion
https://github.com/ssciwr/mondey/blob/2daf2483221204a7d0c82fb0bd905846b5d5868e/mondey_backend/src/mondey_backend/models/questions.py#L30-L40
There is an endpoint to retrieve the list of questions here:
https://github.com/ssciwr/mondey/blob/2daf2483221204a7d0c82fb0bd905846b5d5868e/mondey_backend/src/mondey_backend/routers/questions.py#L15-L22
We need to add a UserAnswer model to store the answer by a particular user for a particular question, e.g. something like
UserAnswer
id
user_question_id
user_id
answer
And we need endpoints to retrieve the current set of answers, and to upload the new set of answers. I'd suggest adding these to the user router: https://github.com/ssciwr/mondey/blob/main/mondey_backend/src/mondey_backend/routers/users.py
We don't need full CRUD endpoints for these, just a get that returns the list of current answers for the user (if any), e.g.
get
@router.get("/user-answers/", response_model=list[UserAnswerPublic]) def get_current_user_answers(session: SessionDep, current_active_user: CurrentActiveUserDep): ....
and a put that replaces the existing answers with new ones, e.g.
put
@router.put("/user-answers/") def update_current_user_answers(session: SessionDep, current_active_user: CurrentActiveUserDep, answers: list[UserAnswerPublic]): ....
The questions that the user should answer about themselves are modelled in the database by
UserQuestion
:https://github.com/ssciwr/mondey/blob/2daf2483221204a7d0c82fb0bd905846b5d5868e/mondey_backend/src/mondey_backend/models/questions.py#L30-L40
There is an endpoint to retrieve the list of questions here:
https://github.com/ssciwr/mondey/blob/2daf2483221204a7d0c82fb0bd905846b5d5868e/mondey_backend/src/mondey_backend/routers/questions.py#L15-L22
We need to add a
UserAnswer
model to store the answer by a particular user for a particular question, e.g. something likeUserAnswer
id
: intuser_question_id
: intuser_id
: intanswer
: strAnd we need endpoints to retrieve the current set of answers, and to upload the new set of answers. I'd suggest adding these to the user router: https://github.com/ssciwr/mondey/blob/main/mondey_backend/src/mondey_backend/routers/users.py
We don't need full CRUD endpoints for these, just a
get
that returns the list of current answers for the user (if any), e.g.and a
put
that replaces the existing answers with new ones, e.g.