Skip to content

Commit

Permalink
v.0.1.1: update readme usage
Browse files Browse the repository at this point in the history
  • Loading branch information
laisfrigerio committed Jan 12, 2025
1 parent 30b87b5 commit 5ecd4a3
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,99 @@ QuizLand is a tiny library with common functions to manage a quiz
- Jest
- NPM library deploy via Github Actions automation

## Usage

```ts
import { QuizLand } from "quizland-core";

const quizLand = QuizLand({
{
"title": "General Knowledge Quiz",
"category": {
"name": "General"
},
"mode": "exam",
"questions": [
{
"content": "What is the capital of France?",
"options": [
{ "id": 1, "content": "Paris" },
{ "id": 2, "content": "London" },
{ "id": 3, "content": "Rome" },
{ "id": 4, "content": "Berlin" }
],
"correctAnswerIds": [1]
},
{
"content": "What is the capital of Brazil?",
"options": [
{ "id": 1, "content": "Salvador" },
{ "id": 2, "content": "Rio de Janeiro" },
{ "id": 3, "content": "São Paulo" },
{ "id": 4, "content": "Brasília"}
],
"correctAnswerIds": [4]
},
{
"content": "Which of these are tourist attractions in Rio de Janeiro?",
"options": [
{ "id": 1, "content": "Pelourinho" },
{ "id": 2, "content": "Cristo Redentor" },
{ "id": 3, "content": "Museu do Futebol" },
{ "id": 4, "content": "Escadaria Selarón" }
],
"correctAnswerIds": [2, 4]
},
{
"content": "Which of these teams have four World Cup titles?",
"options": [
{ "id": 1, "content": "Argentina" },
{ "id": 2, "content": "Inglaterra" },
{ "id": 3, "content": "Alemanha" },
{ "id": 4, "content": "Itália" }
],
"correctAnswerIds": [3, 4],
"answerDetails": "Only the Italian and German teams have 4 World Cup Titles."
}
],
"tryAgain": false,
"showTimer": false,
"showScore": false,
"level": "easy"
}
});
```

- Get Current Question

```ts
const currentQuestion = quizLand.getCurrentQuestion();
```

- Check Answer

```ts
const isCorrectAnswer = quizLand.checkAnswer([1,2]);
```

- Get Current Score

```ts
const score = quizLand.getScore();
```

- Go To Next Question

```ts
quizLand.goToNextQuestion();
```

- Back To Previous Question

```ts
quizLand.goToPreviousQuestion();
```

## 👩 Author

| [<img src="https://avatars.githubusercontent.com/u/20709086?v=4" width="100px;" alt="Lais Frigério"/><br /><sub><b>@laisfrigerio</b></sub>](https://github.com/laisfrigerio)<br /> |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quizland-core",
"description": "QuizLand is a tiny library with common functions to manage a quiz",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/index.js",
"types": "dist/types.d.ts",
"scripts": {
Expand Down

0 comments on commit 5ecd4a3

Please sign in to comment.