Skip to content

Lightweight javascript ulitily for parsing json to html quiz

License

Notifications You must be signed in to change notification settings

pvavercak/quiz-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quiz-js

Lightweight javascript ulitily for parsing json to html quiz.

All you have to do is to call a set of the following functions:

    quiz = new Quiz({
        divId: "yourOwnClass",
        jsonPath: "qs.json",
        answerClass: "yourOwnClass",
        questionClass: "yourOwnClass",
        labelClass: "yourOwnClass",
        correctAnswerClass: "yourOwnClass",
        wrongAnswerClass: "yourOwnClass",
        explanationClass: "yourOwnClass",
        submitButtonId: "buttonId"});

    // this is a promise function since it loads a json file using fetch()
    quiz.parseQuizFromJson().then(() => {
        quiz.displayHTMLQuiz();
    });

JSON file with answers MUST HAVE the following structure

{
    "quizData": [
        {
            "question": "Your own question?",
            "answers": {
                "a": "Your option a",
                "b": "Your option b"
            },
            "correctAnswer": "a",
            "explanation": "Explanation why 'a' is a correct answer"
        },
        {
            ...
        }
    ]
}

Screenshots

  • initial_quiz_state.png
  • initial_quiz_state.png

See example folder for more info.

About

Lightweight javascript ulitily for parsing json to html quiz

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published