New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

quiz-gamification-engine

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quiz-gamification-engine

A customizable quiz gamification engine built with TypeScript.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Quiz Gamification Engine

NPM Version License Tests Code Coverage TypeScript

A lightweight, pluggable quiz engine for gamification campaigns — TypeScript powered, browser-ready, and customizable.

🚀 Features

  • ✅ Multiple-choice scoring with custom weights
  • ⏱ Per-question and total quiz timers
  • 🔁 Question & choice shuffling
  • 🧠 Scoring buckets (e.g. low / medium / high)
  • 💾 Persistent state (localStorage + optional encryption)
  • 🔍 Review mode with answer breakdown
  • 🏷️ Tag-based question pool selection
  • 📊 Final score normalized to 0–100

📦 Installation

npm install quiz-gamification-engine

🧱 Usage

import QuizGame from "quiz-gamification-engine";

const game = new QuizGame({
  questions: [
    {
      question: "What's your favorite color?",
      choices: [
        { text: "Red", score: 10 },
        { text: "Blue", score: 20 },
      ],
      tags: ["personality"],
    },
  ],
  timeLimitPerQuestion: 15,
  totalTimeLimit: 60,
  scoringBuckets: [
    { min: 0, max: 30, label: "Low" },
    { min: 31, max: 70, label: "Medium" },
    { min: 71, max: 100, label: "High" },
  ],
  onStart: () => console.log("Started"),
  onAnswer: (choice, score) =>
    console.log("Answered:", choice, "Score:", score),
  onComplete: (score, bucket) =>
    console.log(`Final Score: ${score} (${bucket})`),
});

game.start();

🧪 Example: Browser Demo

Clone the repo and run:

npm install
npm run build
npx serve

Then open examples/demo.html in your browser.

📖 API Highlights

✅ Methods

  • start(), reset(), submitAnswer(index)
  • saveState(), loadState()
  • enterReviewMode(), getReviewData()
  • getFinalScore(), getScoreBucket(), getStatus()

✅ State

  • status: "idle" | "in-progress" | "completed"
  • reviewMode: boolean
  • answerHistory: { questionIndex, choiceIndex, score }[]

🔐 Optional Configs

OptionDescription
encryptStorageBase64 encode saved data in localStorage
storageKeyLocalStorage key for persistence
questionTagsFilter from a pool of tagged questions
shuffleQuestionsRandomize question order

🛠 Development

npm run build
npm test

📜 License

MIT © 2025 armin shaikhy

Keywords

quiz

FAQs

Package last updated on 17 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts