1.0.2 • Published 5 years ago
quizer v1.0.2
Quizer
Introduction
Welcome to Quizer, an easy and smooth way to make your own quiz.
The reason I started this project was because I had to code a quiz for a project. This project was a website where you could find some quizzes. I had to hard code every quiz, so that's why I made this simple, but effective NPM package for Javascript users.
You basically make a new quiz, and then you have some methods to change the quiz to your belongings. In the futur, I will make some more methods for sure!
Here you have an example:
// Get the package
const Quiz = require('quizer');
// Create a new quiz
const myQuiz = new Quiz("My Quiz Name");
// Add a question to the quiz
myQuiz.add("How much is 2 + 3?", "5");
// Checks if the question is already in the quiz using an ID
if (!myQuiz.has("How much is 5 -1?")) {
myQuiz.set(2 /* Question 2 */, "How much is 5 - 1?", "4");
}
// Adds the question only if it doesn't exist
myQuiz.addIfNotSet("How much is 2 + 3?", "5");
// Returns the answer and the question of a specific question ID
// Logs {question: "How much is 2 + 3?", answer: "5"}
// (from above example)
console.log(myQuiz.get(2))
// Logs "How much is 2 + 3?" and "5" seperatly
console.log(myQuiz.get(2).question)
console.log(myQuiz.get(2).answer)
// Logs a random question
console.log(myQuiz.getRandom())
Coming
I have some features planned to complete the API:
- More than 1 answer in a question
- Delete questions
- Delete a whole quiz