Parse answers from survey matrix
This commit is contained in:
parent
5da7665f79
commit
10078cde5f
|
|
@ -43,5 +43,4 @@
|
||||||
@import "@/styles/_variables.scss";
|
@import "@/styles/_variables.scss";
|
||||||
@import "@/styles/_mixins.scss";
|
@import "@/styles/_mixins.scss";
|
||||||
@import "@/styles/_default-layout.scss";
|
@import "@/styles/_default-layout.scss";
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,24 @@
|
||||||
if (!answer.answer) {
|
if (!answer.answer) {
|
||||||
return previous
|
return previous
|
||||||
}
|
}
|
||||||
|
let answerText;
|
||||||
|
if (typeof answer.answer === 'object') {
|
||||||
|
// this means the answer comes from a matrix, where the keys are the labels and the values are the respective answers
|
||||||
|
let answerObject = answer.answer;
|
||||||
|
let keysAndValues = [];
|
||||||
|
for (let i in answerObject) {
|
||||||
|
if (answerObject.hasOwnProperty(i)) {
|
||||||
|
keysAndValues.push(`${i}: ${answerObject[i]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
answerText = keysAndValues.join(', ');
|
||||||
|
} else {
|
||||||
|
answerText = answer.answer;
|
||||||
|
}
|
||||||
return `
|
return `
|
||||||
${previous}
|
${previous}
|
||||||
<h2 class="solution-text__heading">${answer.title}</h2>
|
<h2 class="solution-text__heading">${answer.title}</h2>
|
||||||
<p class="solution-text__answer">${answer.answer}</p>
|
<p class="solution-text__answer">${answerText}</p>
|
||||||
`
|
`
|
||||||
}, '')
|
}, '')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue