Currently, I am in the process of creating a survey using Vue 2. My goal is to construct and emit the answers array to a parent component named Evaluation. You can view the structure of this array here: https://pastebin.com/rLEUh56a
Within my project, there exists a component known as QuestionItem.vue, which serves as the child component of Evaluation. Details regarding this component can be found here: https://pastebin.com/RFPgKs5Q
The format of the answers array needs to adhere to specific criteria for successful transmission to the API:
answers: [
{
questionId: "6a9ad778-aacf-4e60-9610-37a767700b9f",
questionOptionIds:[
"1bc35f6c-900a-4764-84ee-23531e46e638",
],
answer: null
},
{
questionId: "d1c3f4f0-9525-4e6e-bb81-599d84b5cb02f",
questionOptionIds:[],
answer: "answered value"
},
]
In situations where the question.type
is categorized as text
, range
, stars
, or faces
, it is required that the questionOptionIds
remain empty while the answer
property contains the user's response. Conversely, if the question.type
corresponds to radio
or check
, the answer should be null, and the questionOptionIds
must reflect the selected option.
I am currently facing challenges in constructing this array based on the information inputted in the QuestionItem.vue component. Any guidance on how to accomplish this task would be greatly appreciated. Thank you for your time and have a wonderful day!