feat(ask): add question and option notes

This commit is contained in:
Erik Kotsiuba
2026-04-17 16:50:53 +02:00
parent 52dfc4f9a6
commit 16ff8c42e2
7 changed files with 718 additions and 57 deletions
+15 -4
View File
@@ -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";
}