Quiz Class
In here, you'll find all of the things you have to know from the quiz class.
constructor (name: string, questions: Array<Question>)
// Adds a new question to the quiz
.addQuestion(questions: Array<Question>|Question)
// Adds a new question to the quiz, only if it's not set yet
.addQuestionIfNotSet(questions: Array<Question> or Question)
// Gets a question by its index (starting from 0)
.getQuestion(index: number)
// Gets a random question
.getRandomQuestion()
// Deletes a question by its index
.removeQuestion(index: number)
// Checks if the question is already added
.hasQuestion(question: Question)
// Adds a new users (if not set) to the quiz
.addUser(name: Array<string>|string)
.addUserIfNotSet(name: string)
// Deletes a user by his name
.removeUser(name: string)
// Gets a user by his name
.getUser(name: string)
// Following proprties can only be used after the getUser method!
// Gets the ID of the user (basically the index of the user in the users array property)
.id
// Gets the user's score
// Every right answer gives +1 score
.score
// Gets the question the user has to anwer
// After each time the player answers, this will increase by 1
.currentQuestion
// Checks if the user has finished the quiz
.isFinished
// Lets the user answer a question with a certain choice
// The callbacks can act like events for a correct/an incorrect answer
// Callback parameters:
// Correct: name (name of user)
// Wrong: correctAnswer, name (name of user)
.letAnswer(name: string, choice: string, callbackRight: Function, callbackWrong: Function)
// All the question are stored here
// These are from the class Question and is an array
.questions
// All the users are stored here
.users
// The name of the quiz
.name
Last updated
Was this helpful?