Merged in feature/matrix-solutions (pull request #59)
Parse answers from survey matrix
This commit is contained in:
commit
700b899a23
|
|
@ -43,5 +43,4 @@
|
|||
@import "@/styles/_variables.scss";
|
||||
@import "@/styles/_mixins.scss";
|
||||
@import "@/styles/_default-layout.scss";
|
||||
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -59,10 +59,22 @@
|
|||
if (!answer.answer) {
|
||||
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 prop of Object.keys(answerObject)) {
|
||||
keysAndValues.push(`${prop}: ${answerObject[prop]}`);
|
||||
}
|
||||
answerText = keysAndValues.join(', ');
|
||||
} else {
|
||||
answerText = answer.answer;
|
||||
}
|
||||
return `
|
||||
${previous}
|
||||
<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