Giter Site home page Giter Site logo

signtest's Introduction

Here is the JSON API structure, including the correct answer in the questions list so that the app can determine if the chosen answer is correct without making additional API calls.

1. API Structure

1.1 Fetch Test Categories

Endpoint: GET /api/categories

Response:

{
  "categories": [
    {
      "id": 1,
      "name": "Motorcar/Jeep Test"
    },
    {
      "id": 2,
      "name": "Motorcycle Test"
    },
    {
      "id": 3,
      "name": "LTV Test"
    },
    {
      "id": 4,
      "name": "HTV Test"
    }
  ]
}

1.2 Fetch Questions for a Category

Endpoint: GET /api/categories/{categoryId}/questions

Response:

{
  "categoryId": 1,
  "questions": [
    {
      "id": 101,
      "text": "What does this traffic sign mean?",
      "image": "https://example.com/signs/sign1.png",
      "choices": [
        { "id": 1, "text": "Stop" },
        { "id": 2, "text": "Yield" },
        { "id": 3, "text": "No Entry" },
        { "id": 4, "text": "Speed Limit" }
      ],
      "correctChoiceId": 1
    },
    {
      "id": 102,
      "text": "What should you do at a yellow light?",
      "image": null,
      "choices": [
        { "id": 1, "text": "Speed up" },
        { "id": 2, "text": "Slow down and prepare to stop" },
        { "id": 3, "text": "Continue driving" }
      ],
      "correctChoiceId": 2
    },
    // ... 28 more questions
  ]
}

2. Detailed API Endpoints

2.1 Fetch Test Categories

  • Description: Get the list of test categories.
  • Method: GET
  • Endpoint: /api/categories
  • Response:
    {
      "categories": [
        {
          "id": 1,
          "name": "Motorcar/Jeep Test"
        },
        {
          "id": 2,
          "name": "Motorcycle Test"
        },
        {
          "id": 3,
          "name": "LTV Test"
        },
        {
          "id": 4,
          "name": "HTV Test"
        }
      ]
    }

2.2 Fetch Questions for a Category

  • Description: Get a list of 30 questions for the selected category.
  • Method: GET
  • Endpoint: /api/categories/{categoryId}/questions
  • Response:
    {
      "categoryId": 1,
      "questions": [
        {
          "id": 101,
          "text": "What does this traffic sign mean?",
          "image": "https://example.com/signs/sign1.png",
          "choices": [
            { "id": 1, "text": "Stop" },
            { "id": 2, "text": "Yield" },
            { "id": 3, "text": "No Entry" },
            { "id": 4, "text": "Speed Limit" }
          ],
          "correctChoiceId": 1
        },
        {
          "id": 102,
          "text": "What should you do at a yellow light?",
          "image": null,
          "choices": [
            { "id": 1, "text": "Speed up" },
            { "id": 2, "text": "Slow down and prepare to stop" },
            { "id": 3, "text": "Continue driving" }
          ],
          "correctChoiceId": 2
        },
        // ... 28 more questions
      ]
    }

In this revised structure, the correctChoiceId field is included in each question object. This allows the app to immediately determine if the selected answer is correct and provide instant feedback by showing red or green based on the user's choice.

This approach ensures that the app can handle the logic for verifying answers and transitioning to the next question without needing to make additional API calls for each answer submitted.

signtest's People

Contributors

tahiryasin avatar jahanzaibtahir2006 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.