A simple jQuery quiz plugin.

Overview

jQuery Quiz Plugin

A simple jQuery quiz plugin.

Disclaimer

This is a very simple quiz plugin I created to port quizzes from an existing platform. It creates simple multiple choice quizzes. You can customize most of the screens that are displayed, as well as the text displayed.

Usage

HTML

<div id="quiz">
  <div id="quiz-header">
    <h1>Basic Quiz Demo</h1>
    <!-- Optionally add a home button -->
    <p><a id="quiz-home-btn">Home</a></p>
  </div>
  <div id="quiz-start-screen">
    <p><a href="#" id="quiz-start-btn" class="quiz-button">Start</a></p>
  </div>
</div>

You may optionally add other HTML, this is just the markup required by the plugin (although home button is optional).

Javascript

$('#quiz').quiz({
  questions: [
    {
      'q': 'A smaple question?',
      'options': [
        'Answer 1',
        'Answer 2',
        'Answer 3',
        'Answer 4'
      ],
      'correctIndex': 1,
      'correctResponse': 'Custom correct response.',
      'incorrectResponse': 'Custom incorrect response.'
    }
  ]
});

Add as many questions as you like. You may also specify a different number of options (answers) for each question.

Don't forget to include jQuery.

Options

allowIncorrect: boolean [default: true]

If false, the quiz will show the gameOver screen if a question is answered incorrectly. This will force the user to get a perfect score to complete the quiz.

counter: boolean [default: true]

If true, a counter will be shown displaying the current question and how many questions there are. The output of the counter can be customized using counterFormat.

counterFormat: string [default: '%current/%total']

Specify the counter format. The placehoder %current displays which question you are currently on. The placeholder %total displays the total number of questions.

startScreen: string [default: '#quiz-start-screen']

The id selector of the start screen. The start screen should contain the start button.

startButton: string [default: '#quiz-start-btn']

The id selector of the start button.

homeButton: string [default: '#quiz-home-btn']

The id selector of the home button.

resultsScreen: string [default: '#quiz-results-screen']

The id selector of the results screen. This screen will display the number of questions correct.

resultsFormat: string [default: 'You got %score out of %total correct!']

Specify the results format. The placehoder %score displays how many questions you got correct. The placeholder %total displays the total number of questions.

gameOverScreen: string [default: '#quiz-gameover-screen']

The id selector of the game over screen. This screen is used when allowIncorrect is set to false.

nextButtonText: string [default: 'Next']

The text to display on the next button.

finishButtonText: string [default: 'Finish']

The text to display on the finish button.

restartButtonText: string [default: 'Restart']

The text to display on the restart button.

Callbacks

setupCallback: function [default: undefined]

Callback fired after quiz is setup.

answerCallback: function [default: undefined]

Callback fired after an answer is selected.

nextCallback: function [default: undefined]

Callback fired after the next button is clicked.

finishCallback: function [default: undefined]

Callback fired after the finish button is clicked.

homeCallback: function [default: undefined]

Callback fired after the home button is clicked.

resetCallback: function [default: undefined]

Callback fired after the the quiz is reset. This happens when the home and finish button are clicked.

Comments
  • Great Script! Easy to implement!

    Great Script! Easy to implement!

    Hi, I was looking for a simple jquery solution... and I landed on your github page.

    Great script. Simple to use and implement. KUDOS!!!

    How can I implement adding a predefined number of points per question?

    In my specific case. I have 40 questions and I want to assign a value of 2 points to the first 20, and a value of 3 points per correct answer to the remainder 20 questions (21 - 40).

    Any quick way to accomplish this, without messing up your work?

    Hope you can give me a hint.

    Regards

    opened by inglesuniversal 3
  • How to add multiple correctIndex answers?

    How to add multiple correctIndex answers?

    Hi, I'm trying to give a question multiple right answers but it doesn't work. How can I achieve this?

    $('#quiz').quiz({
      questions: [
        {
          'q': 'A smaple question?',
          'options': [
            'Answer 1',
            'Answer 2',
            'Answer 3',
            'Answer 4'
          ],
          'correctIndex': ['1','2'],
          'correctResponse': 'Custom correct response.',
          'incorrectResponse': 'Custom incorrect response.'
        }
      ]
    });
    
    opened by webb24h 2
  • Images to questions

    Images to questions

    Hi Love the script but I'm still struggling to add images to some questions from a http link but still it doesn't display or it displays at all questions, if anyone know how I can make help will be appreciated thanks

    opened by gevrip 2
  • Custom Result Message with Score

    Custom Result Message with Score

    Hi thanks for making this! I have a request for the custom result screen to also include the score. When I used the custom result screen, the score "You got %score out of %total correct!'" disappeared. Thanks!

    opened by elsieleerobbins 1
  • Problem with text options

    Problem with text options

    When I try to use the variables to change the text like "resultsFormat" or "finishButtonText", this does'nt work, it will display the default text but if I try with the var "counterFormat" it work. (other variable like "counter" works well). I use strings everywhere, the plugin is correctly installed and jQuery also.

    opened by jeremy174433 1
  • How to use multiple query sets for different selectors in the quiz.js plugin?

    How to use multiple query sets for different selectors in the quiz.js plugin?

    I am using a Bootstrap Modal for queries. I want to load different query sets based upon the selected options in dropdown. But the problem is, $('#quiz').quiz({}) loads on page load and pass the first query set and don't replace with the other query set when we change option in dropdown. I don't know how to fix this ...

    opened by seAfnan 1
  • Adding correct answer on event

    Adding correct answer on event

    Unless i'm missing something there does not seem to be a way to highlight the correct answer when they pick an incorrect one. We would like to be able to highlight the red chosen option but also indicate the correct option in green. Perhaps this can be done in callbacks but we're not finding a way to index it.

    opened by erikickes 1
  • How can i get errors and mistakes

    How can i get errors and mistakes

    How can I get the number of errors and success with JAVA? is there a way? What is the name of the variable that holds these datas? My back-end need to get this data and send it to the database using JAVA, I need to save the results for later analysis. Very good, easy and functional your framework, congratulations and thank you!

    opened by vitorregisrr 1
  • Bump grunt from 1.4.0 to 1.5.2

    Bump grunt from 1.4.0 to 1.5.2

    Bumps grunt from 1.4.0 to 1.5.2.

    Release notes

    Sourced from grunt's releases.

    v1.5.2

    • Update Changelog 7f15fd5
    • Merge pull request #1743 from gruntjs/cleanup-link b0ec6e1
    • Clean up link handling 433f91b

    https://github.com/gruntjs/grunt/compare/v1.5.1...v1.5.2

    v1.5.1

    • Merge pull request #1742 from gruntjs/update-symlink-test ad22608
    • Fix symlink test 0652305

    https://github.com/gruntjs/grunt/compare/v1.5.0...v1.5.1

    v1.5.0

    • Updated changelog b2b2c2b
    • Merge pull request #1740 from gruntjs/update-deps-22-10 3eda6ae
    • Update testing matrix 47d32de
    • More updates 2e9161c
    • Remove console log 04b960e
    • Update dependencies, tests... aad3d45
    • Merge pull request #1736 from justlep/main fdc7056
    • support .cjs extension e35fe54

    https://github.com/gruntjs/grunt/compare/v1.4.1...v1.5.0

    v1.4.1

    • Update Changelog e7625e5
    • Merge pull request #1731 from gruntjs/update-options 5d67e34
    • Fix ci install d13bf88
    • Switch to Actions 08896ae
    • Update grunt-known-options eee0673
    • Add note about a breaking change 1b6e288

    https://github.com/gruntjs/grunt/compare/v1.4.0...v1.4.1

    Changelog

    Sourced from grunt's changelog.

    v1.5.2 date: 2022-04-12 changes: - Unlink symlinks when copy destination is a symlink. v1.5.1 date: 2022-04-11 changes: - Fixed symlink destination handling. v1.5.0 date: 2022-04-10 changes: - Updated dependencies. - Add symlink handling for copying files. v1.4.1 date: 2021-05-24 changes: - Fix --preload option to be a known option - Switch to GitHub Actions

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump path-parse from 1.0.6 to 1.0.7

    Bump path-parse from 1.0.6 to 1.0.7

    Bumps path-parse from 1.0.6 to 1.0.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Auto-scroll to the top of the quiz on nextQuestion

    Auto-scroll to the top of the quiz on nextQuestion

    When the nextQuestion call function is triggered we will automatically scroll to the top of the quiz so that the question is in view.

    Edit: Apologies for putting commit:d2a39a6 in this pull request. I was attempting to submit my first ever pull requests and wasn't sure what happened here and I am not sure how to remove the second one and put it in it's own Pull Request.

    opened by nftchance 0
  • Possibility to retry after incorrect answer?

    Possibility to retry after incorrect answer?

    Great plugin, simple yet powerful, nice job!

    I found the callback solution to highlight the correct answer when you answer incorrectly:

    // Highlight correct answer.
    $('.active-question ul.answers a[data-index=' + question.correctIndex + ']').addClass('hint');
    

    When you answer incorrectly you can't change your answer. Is there a simple solution to enable this?

    opened by bielze 0
  • Bump grunt from 1.5.2 to 1.5.3

    Bump grunt from 1.5.2 to 1.5.3

    Bumps grunt from 1.5.2 to 1.5.3.

    Release notes

    Sourced from grunt's releases.

    v1.5.3

    • Merge pull request #1745 from gruntjs/fix-copy-op 572d79b
    • Patch up race condition in symlink copying. 58016ff
    • Merge pull request #1746 from JamieSlome/patch-1 0749e1d
    • Create SECURITY.md 69b7c50

    https://github.com/gruntjs/grunt/compare/v1.5.2...v1.5.3

    Changelog

    Sourced from grunt's changelog.

    v1.5.3 date: 2022-04-23 changes: - Patch up race condition in symlink copying.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Multiple issues in the quiz re-attempt functionality

    Multiple issues in the quiz re-attempt functionality

    1. The Next Start Finish buttons appears when user clicks on the Start button to reattempt the quiz. If user reattempts the quiz for 3rd time, then in the dialog 2 rows of Next-Start-Finish buttons appears.

    2. The user is not able to select the earlier selected options (option selected in previous attempt).

    3. Only first 2 questions appears correctly, the questions no. appears but the question and options are not appearing.

    opened by techtrail-git 1
Owner
JC
JC
QuizApp - A simple Quiz App app using MVC

Quiz App Hey folks! I'm still learning Swift and I made a simple app again. This

Damla Çim 1 Jun 29, 2022
Group project where, we have built a simple quiz to test your Pokemon knowledge

Pokemon-Project For our first team project we have built a Pokemon Quiz. The Team Damon Spriggle Chris Burton Fuji Sin Oscar Hurtado Christopher Lee A

Chris Burton 2 Apr 25, 2022
This project is about a quiz website backend with google sheet.

This project is about a quiz website backend with google sheet. In this project we will fetch quiz data from google sheet to our quiz website, which is responsive & dynamic. Basically we use google sheet as our quiz database.This project is only possible for @Lsvekis .

Subhranshu Choudhury 2 Mar 28, 2022
The easiest quiz night you'll ever run.

Quizzler The easiest quiz night you'll ever run. About The Project Quizzler is a fun new way to practice, improve, and test your Javascript skills. Du

Wasim Reja 11 Dec 4, 2022
💡 A FullStack Quiz web app using TypeScript and Next.js!

A FullStack Quiz app using TypeScript and Next.js! This projects is in portuguese! Self Hosting npm i && npm run build && npm run start # or yarn && y

Jon4s_ 6 Aug 13, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
JQuery charCounter - jQuery Character Counter Plugin

jQuery Character Counter A jQuery based character counter for <input> and <textarea> HTML tags. What is this? This simple plugin allows you to add a c

mmmm_lemon 1 Aug 10, 2022
jQuery quick notification plugin. jQuery плагин быстрых уведомлений

Note: English translation by Google Translate Notific About Description: this is a jQuery plugin that helps you display notifications on your site. Li

Webarion 2 Nov 7, 2021
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
A variety of jQuery plugin patterns for jump starting your plugin development

jQuery Plugin Patterns So, you've tried out jQuery Boilerplate or written a few of your own plugins before. They work to a degree and are readable, bu

jQuery Boilerplate 1.6k Dec 31, 2022
A Simple jQuery Plugin for Animating Scroll

AnimateScroll A Simple jQuery Plugin for Animating the Scroll Demo can be seen at http://plugins.compzets.com/animatescroll What is it exactly? Animat

Ram 714 Jul 21, 2022
simple jquery Plugin that utilizes Google API to get data from a Place on Google Maps

jQuery Plugin to display Google Reviews of a Place on Google Maps this will get the 5 reviews, google offers you. But I need more than 5 reviews! if y

Simon Neutert 32 Dec 14, 2022
Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries.

Image Zoom (jQuery) Plugin Simple jQuery plugin that will allow users to zoom in your images, perfect for product images and galleries that is less th

Mario Duarte 8 Aug 3, 2022
Simple, responsive and lightweight Masonry Grid jQuery Plugin.

jquery-masonry-grid Simple, responsive and lightweight Masonry Grid jQuery Plugin. Installation Add the script before closing the <body> tag (make sur

Peter Breitzler 8 Jun 9, 2022
Simple calendar jquery plugin

Simple Calendar A simple and easy plugin to create a calendar and add events to it. Usage Including files You need to include : A recent version of JQ

Benoit Rospars 42 Dec 29, 2022
Picky is a jQuery plugin that provides simple client-side date validation when entering dates using select tags.

jquery.picky.js Picky is a jQuery plugin that provides simple client-side date validation when entering dates using select tags. Features Instead of g

Patrick Crowley 5 Apr 25, 2021
Simple Cropper is a jQuery plugin which gives you ability to add cropping functionality to your web application

Simple Cropper is a jQuery plugin which gives you ability to add cropping functionality to your web application. It uses html5 canvas to create cropped images and css3, so it only works on latest browsers.

null 1 Feb 15, 2022
A simple and useful jquery plugin that allows you to create a Text Area Character Count Effect with limited warning.

jquery-character-counter A simple and useful jquery plugin that allows you to create a Text Area Character Count Effect with limited warning. #Demo Us

Abdoulie Kassama 0 Dec 28, 2020
ezoom.js is a jQuery plugin for simple Image with zoom effect.

ezoom.js ezoom.js is a jQuery plugin for simple Image with zoom effect. This plugin in under development to support Next/Prev a gallery Images/SVG lat

Nam Le 3 Sep 3, 2022