feat(ask): add question and option notes
This commit is contained in:
+15
-4
@@ -9,10 +9,21 @@ export function renderResultText(result: AskResult): string {
|
||||
for (const question of result.questions) {
|
||||
const answer = result.answers[question.id];
|
||||
if (!answer) continue;
|
||||
const value = answer.customText
|
||||
? `(wrote) ${answer.customText}`
|
||||
: answer.labels.join(", ");
|
||||
lines.push(`✓ ${question.label}: ${value}`);
|
||||
if (answer.customText) {
|
||||
lines.push(`✓ ${question.label}: (wrote) ${answer.customText}`);
|
||||
} else if (answer.labels.length > 0) {
|
||||
lines.push(`✓ ${question.label}: ${answer.labels.join(", ")}`);
|
||||
}
|
||||
if (answer.note) {
|
||||
lines.push(` note: ${answer.note}`);
|
||||
}
|
||||
for (let index = 0; index < answer.values.length; index++) {
|
||||
const value = answer.values[index];
|
||||
const label = answer.labels[index] ?? value;
|
||||
const note = answer.optionNotes?.[value];
|
||||
if (!note) continue;
|
||||
lines.push(` ${label} note: ${note}`);
|
||||
}
|
||||
}
|
||||
return lines.join("\n") || "Submitted";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user