Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.0.1.1: update readme usage #2

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading