quiz.js

0.6.5 • Public • Published

Quiz.js (Demo)

Create quizzes easily

Doc

  • Installation

Simply import Quiz into your HTML.

<script src="https://unpkg.com/quiz.js/Quiz.min.js"></script>
  • How to use

Create a new Quiz object :

let quiz = new Quiz(questions);

quiz
  .setTimeLimit(1000*20) // (Optional) Set a time limit to answer
  .attachTo('#test')     // Display the quiz in the targeted element
  .start(3);             // Start the quiz with 3 random questions

// OR

let quiz = new Quiz();

quiz
  .setTimeLimit(1000*20) // (Optional) Set a time limit to answer
  .attachTo('#test')     // Display the quiz in the targeted element
  .start(questions);     // Start the quiz with every specified question
  • Questions
[
  {
    id: '1+1',          // Unique question ID
    title: '1 + 1 = ?', // Actual question displayed
    answer: '2',        // Correct answer (must correspond to one of the answers' value)
    answers: [          // Answer list
      {
        title: '11',         // Answer displayed
        value: '11',         // Answer actual value
        chosenPercentage: 11 // Percentage of people who chose this answer
	  },
	  ...
    ]
  },
  ...
]
  • Methods

See the documentation for the method definitions.

  • Example

See this JSFiddle for a working example

Authors

Readme

Keywords

Package Sidebar

Install

npm i quiz.js

Weekly Downloads

3

Version

0.6.5

License

MIT

Unpacked Size

1.1 MB

Total Files

42

Last publish

Collaborators

  • zenoo