Currently I'm building an PHP application with the ideas of CQRS, ES and DDD. Let's consider this an survey application with 5 questions. A participant can respond to the survey by answering the 5 questions.
The 5 questions can be queried from the read side in the right order. But, a question can have conditions. For example, don't show question 2 when B is answered to question 1. With the answer 1B, the next question(s) to ask will be: 3, 4 and 5.
The client can fire the command AnswerQuestion, a handler will process that command and a event QuestionAnswered is fired. Based on that event an event handler will update the read side and the client can query for the next question to ask. When there are no further questions the ask, the participation will be completed for the participant (and can take participate with a new participation).
The logic in the survey will decide which questions to ask, and which not, based on the given answer, this is pure domain logic. I'm struggling where to place / apply this logic. Also where to decided when a participation is completed. I think the most likely answer will be: let the survey AR determine the next question based on the given answers from the participation. Or, share the logic in a service, let the read side query the questions and given answers and apply the shared logic to that.
Can you help me further? Thanks in advance!