Git Product home page Git Product logo

iamjohndynamic's Introduction

IJDynamic

Introduction

IJDynamic is a class library for generating dynamic questions and calculating total scores based on user input. It provides a convenient way to generate HTML markup for a set of questions with options and retrieve the total score based on the selected answers.

Installation

You can install the IJDynamic library via Composer. Run the following command in your project directory:

composer require iamjohndev/ijd-dynamic-question

Usage

To use the IJDynamic class, follow these steps:

Include the Composer autoloader in your PHP file: require 'vendor/autoload.php';

Instantiate the IJDynamic class by passing an array of questions to the constructor:

use iamjohndev\IJDynamic;

$questions = [
    // Define your questions and options here
];

$ijDynamic = new IJDynamic($questions);

Generate the HTML markup for the questions using the **generateQuestions() ** method:

$html = $ijDynamic->generateQuestions();

The **generateQuestions() ** method returns an HTML string representing the questions and options.

Display the generated HTML markup in your web page.

To calculate the total score based on user input, use the calculateTotalScore() method:

$totalScore = $ijDynamic->calculateTotalScore();

The calculateTotalScore() method returns the total score calculated from the selected answers.

Example

Here's an example of how to use the IJDynamic library:

require 'vendor/autoload.php';

use iamjohndev\IJDynamic;

$questions = [
    [
        'question' => 'Question 1',
        'name' => 'q1',
        'options' => [
            ['label' => 'Option 1', 'value' => 1],
            ['label' => 'Option 2', 'value' => 2],
            ['label' => 'Option 3', 'value' => 3],
        ],
    ],
    // Add more questions here
];

$ijDynamic = new IJDynamic($questions);

$html = $ijDynamic->generateQuestions();
$totalScore = $ijDynamic->calculateTotalScore();

// Display the HTML markup and total score
echo $html;
echo 'Total Score: ' . $totalScore;

Contributing

Contributions are welcome! If you have any bug reports, feature requests, or suggestions, please open an issue on the GitHub repository.

iamjohndynamic's People

Contributors

pseudodevs avatar

Stargazers

 avatar  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.