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:
@@ -75,7 +75,7 @@ export class QuizSchema extends PothosSchema {
|
|||||||
quizAttempt() {
|
quizAttempt() {
|
||||||
return this.builder.prismaObject('QuizAttempt', {
|
return this.builder.prismaObject('QuizAttempt', {
|
||||||
fields: (t) => ({
|
fields: (t) => ({
|
||||||
id: t.exposeID('id'),
|
id: t.exposeID('id'),
|
||||||
quizId: t.exposeID('quizId'),
|
quizId: t.exposeID('quizId'),
|
||||||
quiz: t.relation('quiz'),
|
quiz: t.relation('quiz'),
|
||||||
userId: t.exposeID('userId'),
|
userId: t.exposeID('userId'),
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user