Skip to content

feat: allow 2 users to complete a questionary concurrently - #1723

Draft
TCMeldrum wants to merge 4 commits into
developfrom
allow-2-users-to-edit-questionairy
Draft

feat: allow 2 users to complete a questionary concurrently#1723
TCMeldrum wants to merge 4 commits into
developfrom
allow-2-users-to-edit-questionairy

Conversation

@TCMeldrum

@TCMeldrum TCMeldrum commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces functionality to allow 2 users to complete a questionary concurrently.

Motivation and Context

The change is required to prevent conflicts and data loss when two users edit a proposal at the same time. The system will prompt the second user to merge their answers, thus ensuring data integrity and a smoother user experience.

Changes

  1. A new column 'last_edited' has been added to the 'answers' table to track the last edit timestamp.
  2. The 'QuestionaryDataSource' has been updated to include 'last_edited' in the answer records.
  3. The 'AnswerTopic' mutation has been extended to check for conflicts based on the 'last_edited' timestamp before updating an answer. If a conflict is detected, it returns an error message prompting the user to merge their answers.

How Has This Been Tested?

Fixes Jira Issue

https://jira.ess.eu//browse/

Depends On

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@TCMeldrum TCMeldrum changed the title feat: Allow 2 users to complete a questionary concurrently feat: allow 2 users to complete a questionary concurrently Aug 14, 2026
@TCMeldrum
TCMeldrum marked this pull request as ready for review August 21, 2026 10:07
@TCMeldrum
TCMeldrum requested a review from a team as a code owner August 21, 2026 10:07
@TCMeldrum
TCMeldrum requested review from EdwardHaynes and removed request for a team August 21, 2026 10:07
@zacharyjhankin

Copy link
Copy Markdown
Collaborator

I think there is an edge case that was missed. Where if person 1 edits and saves the proposal while person 2 is in the review phase. Then person 2 presses the back button, they load the inital answers into the form (before person 1 edited it). Then they do their update and it effectively deletes person 1s edits from existence.

Screencast.From.2026-08-24.09-17-13.mp4

I would not say that this bug necessarily is a reason to reject this PR though.

@zacharyjhankin

Copy link
Copy Markdown
Collaborator

I might vote to use radio-buttons instead of checkboxes when selecting which answer to use. Because checkboxes imply you could select both. (which makes sense for text to append)

radio buttons you usually can only select 1

@zacharyjhankin

Copy link
Copy Markdown
Collaborator

I think there might be another bug when you use the instrumentPicker question as the place for conflicts because the wrong callId is passed to the answer renderer?

[0] {"error":"{"userMessage":"Can not answer topic because the answers have been edited by another user",{"questionId":"instrument_picker_question","value":"{\"value\":{\"instrumentId\":\"1\",\"timeRequested\":\"0\"}}"}],"topicId":10,"isPartialSave":false,"editStartTime":"2026-08-24T08:45:25.454Z"}}}}"}
[0] [2026-08-24T08:45:31.190Z] INFO - GraphQL request received
[0] {"client":"UOP frontend","client_type":"frontend","operation":"getInstrumentsByIdsMinimal","operation_Type":"query"}
[0] [2026-08-24T08:45:31.191Z] INFO - GraphQL request received
[0] {"client":"UOP frontend","client_type":"frontend","operation":"getCallByAnswerId","operation_Type":"query"}
[0] [2026-08-24T08:45:31.192Z] INFO - GraphQL request received
[0] {"client":"UOP frontend","client_type":"frontend","operation":"getInstrumentsByIdsMinimal","operation_Type":"query"}
[0] [2026-08-24T08:45:31.195Z] INFO - GraphQL request received
[0] {"client":"UOP frontend","client_type":"frontend","operation":"getCallByAnswerId","operation_Type":"query"}
[0] [2026-08-24T08:45:31.198Z] ERROR - GraphQL response contained error(s)
[0] {"errors":[{"message":"Call not found for answerId: 101","locations":[{"line":2,"column":3}],"path":["getCallByAnswerId"]}],"context":{"requestUserId":6,"request":{"query":"query getCallByAnswerId($answerId: Int!) {\n getCallByAnswerId(answerId: $answerId) {\n allocationTimeUnit\n }\n}","operationName":"getCallByAnswerId","variables":{"answerId":101},"http":{"method":"POST","headers":{},"search":"","body":{"query":"query getCallByAnswerId($answerId: Int!) {\n getCallByAnswerId(answerId: $answerId) {\n allocationTimeUnit\n }\n}","variables":{"answerId":101},"operationName":"getCallByAnswerId"}}}}}

image

I can't get this error to show unless it comes at the same time as the new popup of the answer conflicts. I think callId became a field that you need to pass to the question now.

</Box>
<Box sx={{ width: '50%' }}>
<Typography variant="body2" color="textSecondary">
Your current Answer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Your current answer:"
"Your current answer"
maybe

>
<Box sx={{ width: '50%' }}>
<Typography variant="body2" color="textSecondary">
Currently saved Answer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently saved answer

>
<Typography variant="h6">
{
'A User has updated some answers while you have been completing this form. Please review the answers below and select which ones you would like to keep.'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A user has updated"

@zacharyjhankin

Copy link
Copy Markdown
Collaborator

I think the abstract can still be deleted when two users edit it simultaniously. Maybe it it is worth getting that to be included in the same validation if possible? I imagine that might even be the most edited/conflicted field ?

@TCMeldrum

TCMeldrum commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@zacharyjhankin Thanks very much for the review!

I think its not just if one user is in the review phase, its part of a larger bug as when you navigate to a topic it doesn’t re-fetch the answers as I thought it did so a user 2 users editing different topic might cause conflicts. Thanks for finding it!

For the instrument picker question I could not replicate it my set up will look into further.

For the proposal abstract I was going to try and fix it in another PR as it is on a different mutation to the rest of the answers but I'll try and deal with here as well.

@TCMeldrum
TCMeldrum marked this pull request as draft August 24, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants