refactor: remove 'amount' argument from Quiz schema and update quiz retrieval logic
- Removed the 'amount' argument from the quiz retrieval query to streamline the schema. - Updated the quiz retrieval logic to use 'nrOfQuestions' from the quiz object instead of the removed 'amount' argument, ensuring consistent behavior in quiz selection. - Improved code clarity by refining comments related to quiz selection logic.
This commit is contained in:
@@ -155,10 +155,6 @@ export class QuizSchema extends PothosSchema {
|
||||
type: 'String',
|
||||
required: false,
|
||||
}),
|
||||
amount: t.arg({
|
||||
type: 'Int',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, _root, args, ctx, _info) => {
|
||||
if (ctx.isSubscription) {
|
||||
@@ -186,9 +182,9 @@ export class QuizSchema extends PothosSchema {
|
||||
centerMentorId: centerMentor.mentorId,
|
||||
},
|
||||
})
|
||||
// get amount of quizzes using args.amount and random index based on random
|
||||
// get amount of quizzes using nrOfQuestions and random index based on random
|
||||
const randomIndex = Math.floor(random * quizzes.length)
|
||||
return quizzes.slice(randomIndex, randomIndex + (args.amount ?? 1))
|
||||
return quizzes.slice(randomIndex, randomIndex + (quizzes[0].nrOfQuestions ?? 1))
|
||||
}
|
||||
|
||||
// use case 2: Customer
|
||||
|
||||
Reference in New Issue
Block a user