Download the PHP package harishdurga/laravel-quiz without Composer

On this page you can find all versions of the php package harishdurga/laravel-quiz. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-quiz

Laravel Quiz

Laravel Quiz

Latest Version on Packagist Total Downloads GitHub Actions

With this package, you can easily get quiz functionality into your Laravel project.

Features

Installation

You can install the package via Composer:

Usage

Class Diagram

LaravelQuiz

Publish Vendor Files (config, migrations, seeder)

If you are updating the package, you may need to run the above command to publish the vendor files. But please take a backup of the config file. Also, run the migration command to add new columns to the existing tables.

Create Topic

Create Sub Topics

Question Types

A seeder class QuestionTypeSeeder will be published into the database/seeders folder. Run the following command to seed question types.

Currently, this package is configured to only handle the following types of questions

Create a QuestionType:

User-Defined Methods To Evaluate The Answer For Each Question Type

Though this package provides three question types you can easily change the method that is used to evaluate the answer. You can do this by updating the get_score_for_question_type property in config file.

But your method needs to have the following signature

If you need to pass any data to your method then you can pass it as the last $data parameter. When you call the calculate_score() method of QuizAttempt then you can pass the data as the parameter.

Create Question

Fetch Questions Of A Question Type

Fetch only questions with an option (valid question)

Attach Topics To Question

Question Option

Fetch Options Of A Question

Create Quiz

Attach Topics To A Quiz

Topicable

Topics can be attached to a quiz or a question. Questions can exist outside of the quiz context. For example, you can create a question bank which you can filter based on the topics if attached.

Negative Marking Settings

By default negative marking is enabled for backward compatibility. You can disable it by setting the enable_negative_marks to false. Two types of negative marking are supported(negative_marking_type). fixed and percentage. Negative marking value defined at question level will be given precedence over the value defined at quiz level. If you want to set the negative marking value at quiz level, set the negative_mark_value to the value you want to set. If you want to set the negative marking value at question level, set the negative_marks of QuizQuestion to your desired value. No need to give a negative number instead the negative marks or percentage should be given in positive.

Adding An Author(s) To A Quiz

Add CanAuthorQuiz trait to your model and you can get all the quizzes associated by calling the quizzes relation. You can give any author role you want and implement ACL as per your use case.

Add Question To Quiz

Fetch Quiz Questions

Attempt The Quiz

Get the Quiz Attempt Participant

MorphTo relation.

Answer Quiz Attempt

A QuizAttemptAnswer belongs to QuizAttempt,QuizQuestion and QuestionOption

Get Quiz Attempt Score

In case of no answer found for a quiz question which is not optional, a negative score will be applied if any.

Get Correct Option Of A Question

Return a collection of QuestionOption.

Please refer to unit and features tests for more understanding.

Validate A Quiz Question

Instead of getting total score for the quiz attempt, you can use QuizAttempt model's validate() method. This method will return an array with a QuizQuestion model's id as the key for the assoc array that will be returned. Example:

To be able to render the user answer and correct answer for different types of question types other than the 3 types supported by the package, a new config option has been added.

By keeping the question type id as the key, you can put the path to your custom function to handle the question type. This custom method will be called from inside the validate() method by passing the QuizQuestion object as the argument for your custom method as defined in the config. Example:

As shown in the example your customer method should return an array with two elements the first one being the correct answer and the second element being the user's answer for the question. And whatever the $data you send to the validate() will be sent to these custom methods so that you can send additional data for rendering the answers.

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of laravel-quiz with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
illuminate/support Version ^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package harishdurga/laravel-quiz contains the following files

Loading the files please wait ....