Skip to content

Commit

Permalink
feat: add tag db column, conditionally render tags section
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzocorallo committed Feb 5, 2024
1 parent fb72b07 commit b3fee17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion scripts/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
12 changes: 6 additions & 6 deletions src/components/Util/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ interface Props {
dbRef?: DATABASE_REF
}

const TEST_TAGS = ['combinazioni e coefficienti binomiali', 'permutazioni']

export default function Question({
q,
isDebug = false,
Expand Down Expand Up @@ -95,10 +93,12 @@ export default function Question({
)
})}

<div style={styles.tagsContainer}>
<FaAnchor />
<p style={styles.tags}>{concatTags(TEST_TAGS)}</p>
</div>
{q.tags.length > 0 && (
<div style={styles.tagsContainer}>
<FaAnchor />
<p style={styles.tags}>{concatTags(q.tags)}</p>
</div>
)}
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Question {
correct: AnswerLetter
attachments: string[]
validated: boolean
tags: string[]

// These are only present for COM questions
sub?: string
Expand Down

0 comments on commit b3fee17

Please sign in to comment.