refactor: streamline quiz schema formatting and improve readability

- Reformatted the quiz schema for consistent indentation and spacing, enhancing overall code clarity.
- Consolidated the random index calculation into a single line for improved readability.
- Maintained existing functionality while ensuring the code adheres to style guidelines for better maintainability.
This commit is contained in:
2024-12-10 16:37:53 +07:00
parent d18258f81a
commit 431e478f21

View File

@@ -195,9 +195,7 @@ export class QuizSchema extends PothosSchema {
}, },
}) })
// get amount of questions using nrOfQuestions and random index based on random // get amount of questions using nrOfQuestions and random index based on random
const randomIndex = quizzes.length > 0 const randomIndex = quizzes.length > 0 ? Math.floor(random * quizzes.length) : 0
? Math.floor(random * quizzes.length)
: 0
const nrOfQuestions = quizzes[0]?.nrOfQuestions ?? 1 const nrOfQuestions = quizzes[0]?.nrOfQuestions ?? 1
const result = quizzes.slice(randomIndex, randomIndex + nrOfQuestions) const result = quizzes.slice(randomIndex, randomIndex + nrOfQuestions)
return result return result