From 5ecd4a319a998eb84de802223a48a7ae8fb133bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lais=20Frig=C3=A9rio?= Date: Sun, 12 Jan 2025 15:34:42 -0300 Subject: [PATCH] v.0.1.1: update readme usage --- README.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f34b4a..07abcca 100644 --- a/README.md +++ b/README.md @@ -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 | [Lais Frigério
@laisfrigerio](https://github.com/laisfrigerio)
| diff --git a/package.json b/package.json index d030020..4c00b6d 100644 --- a/package.json +++ b/package.json @@ -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": {