Chat GPT Quiz Generator using Laravel Livewire
Tech Stack: tailwindcss, livewire
Demo
Please login to check demo of ChatGPT Quiz Generator
Code
Documentation
Overview
This component, GptQuiz, creates an interactive quiz with questions and answers. It uses the OpenAI API to generate a multiple-choice quiz based on a provided topic and difficulty level. It then allows the user to answer the quiz and provides a score upon completion.
Implementation Instructions
1. Copy the component file (GptQuiz.php) to yourapp/Livewire
directory.
2. Copy the blade view file (gpt-quiz.blade.php) to your resources/views/livewire
directory.
Integration
To integrate this component into your Laravel project, you can call it in your blade file using the following Livewire directive:
@livewire('gpt-quiz')
Usage Instructions
When the component is loaded, the user will be prompted to enter a topic and select a difficulty level for the quiz. After clicking the "Start Quiz" button, the quiz will be generated and presented to the user. The user can then select an answer for each question and navigate through the quiz using the "Next Question" button. Upon completion, the user's score will be displayed.
Configuration Options
The number of total questions in the quiz can be configured by changing the $totalQuestions
property in the GptQuiz class.
Customization Possibilities
You can customize the quiz by modifying the prompt sent to the OpenAI API in the generateQuiz()
function. For example, you can change the format of the quiz or the type of questions generated.