Resolve "CSV export script fails for different answer types"
Closes #1008 (closed)
Jakob found the bug with this file as input: report-jakob.json The scale questions and the daily notes don't have options
.
Jakob/Andreas suggested this change to the script (see Jakob's MR linked in the issue):
if (question.type === 'boolean') answerWording = answerRaw.toString()
else {
const option = (question.options ||[]).find(opt => opt.value === answerRaw)
// ...
= Leaving answerWording
as ''
if no the question has no options, except for boolean questions. (answerRaw
is also part of the output, so that works)
I propose the following improvement:
if (!question.options) answerWording = answerRaw.toString()
else { // ...
= Setting answerWording
to the raw answer value for all questions without options.
This seems safer to me than checking the question type, since we have been adding new question types.
Edited by Noel Simmel