https://github.com/milospaunovic/questionnaire
Serving random questions in multiple languages has never been this easy.
https://github.com/milospaunovic/questionnaire
questionnaire questions
Last synced: about 1 year ago
JSON representation
Serving random questions in multiple languages has never been this easy.
- Host: GitHub
- URL: https://github.com/milospaunovic/questionnaire
- Owner: MilosPaunovic
- License: mit
- Created: 2022-09-27T20:47:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-31T07:39:26.000Z (almost 3 years ago)
- Last Synced: 2025-03-01T16:40:57.041Z (over 1 year ago)
- Topics: questionnaire, questions
- Language: JavaScript
- Homepage: https://bit.ly/3UDnETD
- Size: 3.79 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Questionnaire
Package for generating random question(s) in multiple languages.
[](https://github.com/MilosPaunovic/questionnaire/actions/workflows/testing.yml)
## Try it Online
[Link to Codepen playground](https://codepen.io/milospaunovic/pen/MWGrdEZ?editors=1011)
## Motivation
Main idea and motivation behind this was work from [Nenad Ilić](https://github.com/ilic5000) and his post I saw on [Reddit](https://www.reddit.com/r/programiranje/comments/xofp1t/anansi_computer_vision_mini_projekat_izvukao_sam/). You could (and should) read more about it [here](https://github.com/ilic5000/pabkvizgenerator/blob/main/README.md).
## Installation
```bash
npm i @paunovic/questionnaire
```
## Configuring
```js
import { initialize } from '@paunovic/questionnaire';
// Initialization with default language pack
const QUESTIONNAIRE = initialize();
// Initialization with different language pack, including variation
const QUESTIONNAIRE = initialize({ countryCode: 'rs', variation: 'cyrillic' });
```
Currently available country codes and variations:
| Country | Country code | Variation | Questions |
| :------------ | :----------: | :--------: | :---------: |
| Serbia `*` | `rs` | `cyrillic` | 10253 |
`*` Default language; if no `countryCode` parameter is passed to `initialize` method, Serbian Latin will be loaded as a default language.
## Methods
#### Question
Returns random question from the list in the object form, containing question and answer properties.
```js
QUESTIONNAIRE.question(); // => { question: 'QUESTION', answer: 'ANSWER' }
```
Returns random question from the list in the object form, containing question, answer and wrong (containg number of wrong answers you've specified, in range from 1 to 30) properties.
```js
QUESTIONNAIRE.question({ wrong: 3}); // => { question: 'QUESTION', answer: 'ANSWER', wrong: ['WRONG', 'WRONG', 'WRONG'] }
```
#### Questions
Returns an array of 10 question objects from the list.
```js
QUESTIONNAIRE.questions() // => [{ question: 'QUESTION', answer: 'ANSWER' }, { question: 'QUESTION', answer: 'ANSWER' }...]
```
Returns an array of question objects with wrong answers (containg number of wrong answers you've specified, in range from 1 to 30) from the list (number of items defaults to 10, accepted range from 1 to 10000).
```js
QUESTIONNAIRE.questions({ howMany: 7, wrong: 1 }) // => [{ question: 'QUESTION', answer: 'ANSWER', wrong: ['WRONG'] }, { question: 'QUESTION', answer: 'ANSWER', wrong: ['WRONG'] }...]
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please try to follow [semantic commit messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) principle to simplify navigation through git history.
## License
[MIT](https://raw.githubusercontent.com/MilosPaunovic/questionnaire/develop/LICENSE) © [Milos Paunovic](https://github.com/MilosPaunovic)