# generate-quiz

> Generates a quiz from an array of questions. Supports multiple correct answers, multiple quizes on one page, randomizing the order of questions and answers, highlighting correct and incorrect answers. Made for a school project.

Latest version **1.0.0** (published 2018-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install generate-quiz
pnpm add generate-quiz
yarn add generate-quiz
bun add generate-quiz
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-06-14 |
| First published | 2018-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ol-web |
| Maintainers | ol-web |
| Keywords | quiz, quiz generator, generate quiz, generate-quiz, quiz-generator |

## Links

- npm: https://www.npmjs.com/package/generate-quiz
- Repository: https://github.com/oL-web/generate-quiz
- Homepage: https://github.com/oL-web/generate-quiz#readme
- Issues: https://github.com/oL-web/generate-quiz/issues
- npm.io page: https://npm.io/package/generate-quiz

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) latest
- [superagent](https://npm.io/package/superagent.md) latest
- [html-entities](https://npm.io/package/html-entities.md) ^1.2.1

## Recent versions

- 1.0.0 (latest) — 2018-06-14

## README

# generate-quiz

Generates a quiz from an array of questions. Supports multiple correct answers, multiple quizes on one page, randomizing the order of questions and answers, highlighting correct and incorrect answers. Made for a school project.

* * *

### Installation:

`npm install --save generate-quiz`
You can play around with the demo example too! It picks questions from https://opentdb.com/
`npm run example`  

* * *
### Lazy documentation and usage:
```javascript
    const questions = [
		 {
	      question: "What's 2 + 2?",
	      answers: [`4`,`2`,`1`],
	      correctAnswer: 0 // index of the correct answer in the answers array
	     },
	     {
	      question: "Is JavaScript cool?",
	      answers: [`yes`,`no`,`of course`,`yes, it is`,`yep`,`definitely`],
	      correctAnswers: [0,2,3,4] // multiple correct answers, make sure to differentiate between correctAnswer and correctAnswers
	     },
    ];

    const  quiz  =  new  Quiz(document.querySelector(".generate-quiz"), questions);
    
    quiz.render(); // resets the quiz container and renders it in randomized order
    
    const resultsObj = quiz.calculateResults(); // returns an object with point score, percentage score and total points

	quiz.disableInputs(); // user won't be able to click inputs anymore

    quiz.highlightAnswers(); // applies .generate-quiz__answer_wrong class to wrong answers and .generate-quiz__answer_correct to correct answers
```
* * *
### Is there something wrong?

Please tell me!

---
_Source: https://npm.io/package/generate-quiz · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
