react-quiz-component is a ReactJS component allowing users to attempt a quiz.
npm i react-quiz-component
import Quiz from 'react-quiz-component';
The quiz source is a JSON object. You can use react-quiz-form to generate it.
export const quiz = {
"quizTitle": "React Quiz Component Demo",
"questions": [
{
"question": "How can you access the state of a component from inside of a member function?",
"questionType": "text",
"answers": [
"this.getState()",
"this.prototype.stateValue",
"this.state",
"this.values"
],
"correctAnswer": "3"
},
{
"question": "ReactJS is developed by _____?",
"questionType": "text",
"answers": [
"Google Engineers",
"Facebook Engineers"
],
"correctAnswer": "2"
},
{
"question": "ReactJS is an MVC based framework?",
"questionType": "text",
"answers": [
"True",
"False"
],
"correctAnswer": "2"
},
{
"question": "Which of the following concepts is/are key to ReactJS?",
"questionType": "text",
"answers": [
"Component-oriented design",
"Event delegation model",
"Both of the above",
],
"correctAnswer": "3"
},
{
"question": "Lorem ipsum dolor sit amet, consectetur adipiscing elit,",
"questionType": "photo",
"answers": [
"https://dummyimage.com/600x400/000/fff&text=A",
"https://dummyimage.com/600x400/000/fff&text=B",
"https://dummyimage.com/600x400/000/fff&text=C",
"https://dummyimage.com/600x400/000/fff&text=D"
],
"correctAnswer": "1"
}
]
} import { quiz } from './quiz';
...
<Quiz quiz={quiz}/>- Clone the project
- run
npm install - run
npm run dev
The demo is available at https://wingkwong.github.io/react-quiz-component/
This project is licensed under the MIT License - see the LICENSE.md file for details