From b3fee1769a64daf70d8e6d6e20b26da5da407a86 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Mon, 5 Feb 2024 22:22:30 +0100 Subject: [PATCH] feat: add `tag` db column, conditionally render tags section --- scripts/database.ts | 3 ++- src/components/Util/Question.tsx | 12 ++++++------ src/utils/database.ts | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/database.ts b/scripts/database.ts index 6c0085a..201c808 100644 --- a/scripts/database.ts +++ b/scripts/database.ts @@ -137,7 +137,8 @@ async function getParsedSheets() { correct: r.rispostaCorretta?.toLowerCase(), attachments: DriveClient.matchFileIds(r.immaginiQuesito || '') || undefined, - validated: (r.validato as string | undefined)?.toLowerCase() == 'sì' + validated: (r.validato as string | undefined)?.toLowerCase() == 'sì', + tags: r.tag ? r.tag.split(';') : [] })) res['com'] = res['com']?.map((q, _, arr) => { diff --git a/src/components/Util/Question.tsx b/src/components/Util/Question.tsx index b798f26..744357d 100644 --- a/src/components/Util/Question.tsx +++ b/src/components/Util/Question.tsx @@ -51,8 +51,6 @@ interface Props { dbRef?: DATABASE_REF } -const TEST_TAGS = ['combinazioni e coefficienti binomiali', 'permutazioni'] - export default function Question({ q, isDebug = false, @@ -95,10 +93,12 @@ export default function Question({ ) })} -
- -

{concatTags(TEST_TAGS)}

-
+ {q.tags.length > 0 && ( +
+ +

{concatTags(q.tags)}

+
+ )} ) } diff --git a/src/utils/database.ts b/src/utils/database.ts index 0a5254a..97b354f 100644 --- a/src/utils/database.ts +++ b/src/utils/database.ts @@ -21,6 +21,7 @@ export interface Question { correct: AnswerLetter attachments: string[] validated: boolean + tags: string[] // These are only present for COM questions sub?: string