1.0.5 • Published 1 year ago

quiz-component-react v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

quiz-component-react

:orange_book: React Quiz Component

NPM version License

quiz-component-react is a React component allowing users to attempt a quiz.

Features

  • Progress bar ✓
  • Allow retry ✓
  • Custom result page
  • New question types
  • Allow markdown in question

Installing

npm i quiz-component-react

Importing quiz-component-react

import { Quiz } from 'quiz-component-react';

Defining Your Quiz Source

The quiz source is a JSON object.

export const quiz =  {
  "title": "Title quiz",
  "questions": [
    {
      "question": "Paul can't touch the ceiling because he is too ______.",
      "image": "src image",
      "answers": [
        "shortening",
        "shortly",
        "short",
        "shortness"
      ],
      "correctAnswer": "3",
      "messageForCorrectAnswer": "Correct answer. Good job.",
      "messageForIncorrectAnswer": "Incorrect answer. Please try again.",
      "point": "20"
    },
  ]
} 

Locale Customization

If you want to use your customized text, you can send props locale

 "locale": {
    "questionText": "Question",
    "nextButton": "Next",
    "resultText": "Your result",
    "endText": "Сongratulations you passed the quiz",
    "correctText": "Correct answers",
    "incorrectText": "Incorrect answers",
    "retryText": "Retry",
  } 

Props

NameTypeDefaultRequiredDescription
quizobjectnullYQuiz Json Object
shufflebooleanfalseNShuffle the questions
onCompletefunctionnullNFunction after end quiz
onQuestionSubmitfunctionnullNFunction after question
localefunctionlocaleNText in quiz
isPorgressBarbooleanfalseNShow progress bar
isAllowRetrybooleanfalseNAllow retry quiz
isAllowRetrybooleanfalseNDon't show answer after select

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago