Advertisement Advertisement
Click here
Advertisement Contact for advertisement: proainexsupport@gmail.com
HomeSource CodesQuiz App Source Code in HTML, CSS & JavaScript – Interactive Quiz Application

Quiz App Source Code in HTML, CSS & JavaScript – Interactive Quiz Application

JavaScript Projects 5 Views 0 Downloads
Share this code: Pinterest
Click to View Live Preview
// Loading...

Implementation Guide & Details

 How to run the app

  1. Copy the entire code into a new file called, for example, quizmaster.html.

  2. Open that file with any modern browser (Chrome, Edge, Firefox, etc.).

  3. The quiz app loads immediately – all features are available offline after the first load.

Note about uploads/quiz.json
This is a pure front‑end application, so custom quizzes are stored in your browser’s localStorage, not in a server folder. You can still upload a .json file or paste JSON directly – the app will remember them automatically.


2. Navigating the app

The app has four main views accessible from the top navigation bar:

 
 
View What it does
Home Hero section + list of all available quizzes (default + your custom ones).
Add Quiz Interface to create a new quiz by pasting or uploading JSON.
Quiz Player Appears when you click Start Quiz. Shows questions, timer, options, and feedback.
Results Displays after finishing a quiz: score, statistics, answer review.
  • Use the mobile menu button (three horizontal lines) on small screens.

  • At the end of any quiz, you can RetryReview Answers, or go back to Home.


3. Adding custom quizzes (the “uploads” feature)

Even though there’s no physical uploads/ folder, you can add as many quizzes as you like. Here’s how:

Method A – Paste JSON directly

  1. Click “Add Quiz” in the nav bar.

  2. Write (or copy‑paste) a quiz in JSON format into the text area.

  3. Click “Save Quiz”.

  4. The quiz instantly appears on the Home screen under Available Quizzes.

Method B – Upload a .json file

  1. On the Add Quiz page, click the upload area (or drag & drop a .json file onto it).

  2. The content of the file fills the text area.

  3. Review the JSON, then click “Save Quiz”.

Method C – Start with the sample template

  • Click the “Load Sample” button to see the required JSON structure, then modify and save.

Important: All saved custom quizzes persist in your browser’s localStorage. They stay even after closing the tab, but they are lost if you manually clear your browser data.


4. JSON format for a quiz

Your custom quiz must follow this structure (same as the sample):

json
{
  "title": "My Awesome Quiz",
  "category": "General",
  "difficulty": "medium",
  "timePerQuestion": 25,
  "iconType": "custom",
  "questions": [
    {
      "question": "What is the capital of France?",
      "options": ["London", "Berlin", "Paris", "Madrid"],
      "correct": 2,
      "explanation": "Paris is the capital of France."
    },
    {
      "question": "How many continents are there?",
      "options": ["5", "6", "7", "8"],
      "correct": 2,
      "explanation": "There are 7 continents."
    }
  ]
}

Rules:

  • title – string, required.

  • questions – array of objects, at least one question.

  • Each question must have:

    • question (string)

    • options (array of strings, minimum 2 options, maximum 4 recommended)

    • correct (integer 0‑based index of the correct option)

    • explanation (string, optional but recommended)

  • Optional fields: difficulty (easy/medium/hard), timePerQuestion (seconds, default 30), iconType (science/general/tech/custom).


5. Playing a quiz – key features

  • Timer per question – default 30 seconds (customisable via JSON). Bar turns yellow then red as time runs out.

  • Keyboard shortcuts – while a question is active, press 1‑4 or A‑D to select an answer. Press Enter or Space to move to the next question after answering.

  • Instant feedback – after selecting an answer, the correct option is highlighted in green, wrong ones in red, and an explanation appears.

  • Scoring – points for each correct answer: 100 + (time left * bonus). Perfect scores trigger confetti.

  • Results screen – shows percentage, total points, time taken, and a question‑by‑question review.


6. Customisation tips (for developers)

If you want to change the default quizzes or the behaviour:

  • Edit the pre‑loaded quizzes – Find the defaultQuizzes array in the JavaScript (around line 1500). Add, remove, or modify quiz objects.

  • Change default timer – Inside each quiz object, set timePerQuestion to your preferred number.

  • Adjust styling – All colours are CSS custom properties under :root. For example, change --accent-1 to a different colour to rebrand the app.


7. What if you really need a server‑side uploads/quiz.json folder?

The current implementation is fully client‑side. If you later need to store quizzes on a server (e.g., with Node.js or Python), you would:

  • Send the JSON from the Add Quiz page to an endpoint that saves it in uploads/quiz.json (or multiple files).

  • Load those files on startup instead of using localStorage.

However, for most personal or demo use, the localStorage approach is simpler, faster, and already implemented. The app shows exactly the same “upload” experience without any backend.

About this code

Download a professional Quiz App Source Code developed using HTML, CSS, and JavaScript. This interactive quiz application allows users to answer multiple-choice questions, track scores, view results instantly, and enjoy a smooth user experience across all devices. The project features a clean interface, responsive layout, question navigation, timer support, score calculation, and dynamic quiz functionality. Perfect for students, developers, and anyone learning frontend web development.

Features

Technologies Used

HTML5, CSS3, JavaScript

Frequently Asked Questions

What technologies are used in this Quiz App project?

This Quiz App is built using HTML5, CSS3, and JavaScript without any external frameworks.

Is the Quiz App fully responsive?

Yes, the application is fully responsive and works smoothly on mobile phones, tablets, and desktop devices.

Does the Quiz App support multiple-choice questions?

Yes, users can answer multiple-choice questions and receive instant feedback and scoring.

Can I customize the quiz questions and answers?

Yes, developers can easily modify questions, answers, categories, and quiz settings according to their requirements.

Does the project include score calculation?

Yes, the Quiz App automatically calculates scores and displays the final result after quiz completion.

Can I use this project for educational websites?

Yes, this project is suitable for educational platforms, online tests, practice exams, and learning applications.

How can I add my own quiz to the app?

Navigate to the 'Add Quiz' section. You can either paste your quiz as a JSON object directly into the text area, or upload a .json file using the drag-and-drop area. Click 'Save Quiz' and it will instantly appear on the home screen.

How does the quiz timer work?

Each question has a configurable time limit (default 30 seconds). A progress bar shows remaining time; it turns yellow when 10 seconds are left and red in the last 5 seconds. If time runs out, the question is marked incorrect automatically.

What scoring system does the Quiz App use?

Points are awarded only for correct answers. The base score is 100 points, plus a bonus proportional to the remaining time. Total points and a percentage score are shown at the end, along with a detailed answer review.

Can I use keyboard shortcuts while playing a quiz?

Yes. During a question, press 1, 2, 3, or 4 (or A, B, C, D) to select an option. After answering, press Enter or Space to move to the next question.

Where are my custom quizzes stored?

Custom quizzes are saved in your browser's localStorage. They remain even after closing the tab, but are lost if you clear your browser data. No server upload is required.

Does the app come with any demo quizzes?

Yes, two built-in quizzes are included: 'Science & Technology' (5 questions, medium difficulty) and 'General Knowledge' (5 questions, easy difficulty). You can start playing immediately without adding anything.

Home Source Codes Best Deals AI Prompts Profile