Socket
Book a DemoInstallSign in
Socket

single-question-quiz-element

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

single-question-quiz-element

A web component for a simple quiz

0.1.6
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

single-question-quiz-element

A web component that creates an interactive quiz with a single question, multiple choice answers, and feedback.

Usage

Include the component script in your HTML. Change latest to a specific version:

<script src="https://cdn.jsdelivr.net/npm/single-question-quiz-element@latest/dist/single-question-quiz-element.umd.min.js"></script>

Then use the component in your HTML:

<single-question-quiz-element name="my-quiz">
  <form class="bg-light rounded p-4">
    <div class="quiz-question">
      <p class="mb-4 fw-bold">Your question goes here?</p>

      <div class="form-check">
        <input class="form-check-input" type="radio" name="quizOptions" id="option1" value="0" data-correct="false" />
        <label class="form-check-label" for="option1">First answer option</label>
        <aside class="alert alert-danger mt-2" style="display: none">
          Feedback shown when this incorrect answer is selected.
        </aside>
      </div>

      <div class="form-check">
        <input class="form-check-input" type="radio" name="quizOptions" id="option2" value="1" data-correct="true" />
        <label class="form-check-label" for="option2">Second answer option (correct)</label>
        <aside class="alert alert-success mt-2" style="display: none">
          Feedback shown when this correct answer is selected.
        </aside>
      </div>

      <div class="mt-3">
        <button type="submit" class="btn btn-primary" data-action="submit">Submit Answer</button>
        <button type="button" class="btn btn-secondary" style="display: none" data-action="reset">Start over</button>
      </div>
      <aside class="alert alert-secondary mt-3" style="display: none">
        Optional general explanation shown after answer is submitted.
      </aside>
    </div>
  </form>
</single-question-quiz-element>

Required HTML Structure

  • The component must contain a <form> element
  • Question options should be in <div class="form-check"> elements
  • Each option should have:
    • A radio input with name="quizOptions" and data-correct="true/false"
    • A label
    • An optional feedback <aside> that's shown when that option is selected
  • Include submit/reset buttons with data-action="submit" and data-action="reset"
  • Optional general explanation in an <aside> at the end

For many more examples, see index.html in the repository.

Styling

The component uses Bootstrap classes by default. Include Bootstrap CSS in your page for the best appearance:

<link
  href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/css/bootstrap.min.css"
  rel="stylesheet"
  crossorigin="anonymous" />

Contributing

Install packages:

npm install

Run the development server (with hot reloading):

npm run dev

Lint the code:

npm run lint

Format the code:

npm run format

Build the production version:

npm run build

Publish to npm:

npm publish

FAQs

Package last updated on 23 Jun 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.