Add a space between multiple solutions for the same matrix row
This commit is contained in:
parent
11ad61c355
commit
315d84316e
|
|
@ -16,36 +16,21 @@ const extractAnswerFromQuestion = (previous: any[], question: Question) => {
|
|||
return [...previous];
|
||||
}
|
||||
let answer = question.correctAnswer;
|
||||
console.log(question.getType());
|
||||
const type = question.getType();
|
||||
if (type === 'matrix' || type === 'matrixdropdown') {
|
||||
const correctAnswer = question.correctAnswer;
|
||||
const { rows, columns } = question;
|
||||
console.log('columns', columns);
|
||||
const col1 = columns[0];
|
||||
const col2 = columns[1];
|
||||
console.log('col1', col1);
|
||||
console.log(col1.value);
|
||||
console.log(col1.name);
|
||||
console.log(col1.locTextValue);
|
||||
console.log(col2);
|
||||
console.log(col2.choices);
|
||||
|
||||
answer = rows.map(({ text, value }: RowKey) => {
|
||||
const labelWitoutPunctuation = /[,.!?]/.test(text.slice(-1)) ? text.slice(0, -1) : text; // the last character might be a period, comma, question or exclamation mark. If not, we just return the key as-is
|
||||
console.log('correctAnswer', correctAnswer);
|
||||
let answer;
|
||||
if (type === 'matrix') {
|
||||
answer = correctAnswer[value] || correctAnswer[labelWitoutPunctuation]; // the key might be with or without the punctuation, can be inconsistent depending on the survey
|
||||
} else {
|
||||
const answers = correctAnswer[value] || correctAnswer[labelWitoutPunctuation]; // the key might be with or without the punctuation, can be inconsistent depending on the survey
|
||||
// console.log(answers);
|
||||
// console.log(answers.getOwnPropertyNames());
|
||||
// const forcedObject = { ...answers };
|
||||
// console.log(forcedObject.getOwnPropertyNames());
|
||||
// console.log(forcedObject.keys());
|
||||
// answer = answers.keys();
|
||||
answer = Object.keys(answers);
|
||||
answer = Object.keys(answers).join(', ');
|
||||
console.log(answer);
|
||||
}
|
||||
return `${labelWitoutPunctuation}: ${answer}`; // return the key without punctuation, as we add the colon
|
||||
|
|
|
|||
Loading…
Reference in New Issue