🌎 Leia em Português
Ready-to-use application to generate, export, and print math exercise sheets.
MathX is a math exercise generator built with Laravel. The user selects the operations (addition, subtraction, multiplication, and division), defines a number interval, sets how many exercises will be generated, and the system displays a printable and exportable list.
This project follows a simple structure based on Controller → Services → Models → Views (Blade).
- Generation of basic arithmetic exercises: addition, subtraction, multiplication, and division.
- Control of operand range (min and max values).
- Define the amount of exercises (5 to 50).
- Exercises stored temporarily in Laravel Session.
- Print view for classroom use.
- Export results as a
.txtfile.
- PHP (recommended 8.x)
- Laravel (Blade templates)
- Bootstrap (static assets included)
- Composer for dependency management
Main structure of the code:
app/Http/Controllers/MainController.php— route logic and service integration.app/Services/ExerciseGeneratorService.php— exercise creation.app/Services/ExerciseExporterService.php—.txtformatting.app/Services/ExerciseSessionService.php— validation and session handling.app/Models/Exercise.php— simple model for exercises.routes/web.php— routes (home, generateExercises, exportExercises, printExercises).resources/views/— Blade views (layouts, home, operations, etc.)
- Clone the repository:
git clone https://github.com/jprogram-php-projects/MathX.git
cd MathX- Install dependencies:
composer install- Copy and configure the environment file:
cp .env.example .envAdjust .env if needed (e.g., APP_NAME, APP_URL).
- Generate Laravel app key:
php artisan key:generate-
Database is not required for current features. If you add DB-related features, update
.envand runphp artisan migrate. -
Start the local server:
php artisan serveAccess the app at http://127.0.0.1:8000.
- Rename
.env.exampleto.envbefore generating the app key. - Exercise data is stored in session, default session driver
fileworks great. - Static assets are located in
public/assets/...and Blade references useasset('assets/...').
-
User submits form on
/route. -
MainController::generateExercisesvalidates and callsExerciseGeneratorService. -
Exercises are stored in session:
session(['exercises' => $exercises]). -
User can:
- View exercise list in
operationsview. - Export to
.txtusingexportExercises. - Print exercises with answers using
printExercises.
- View exercise list in
- Add decimal configuration for division.
- Filter exercises by operation type on export/visualization.
- Add PHPUnit tests for
ExerciseGeneratorServiceandMainController. - View internationalization (i18n).
- Fork the repo.
- Create a new branch:
git checkout -b feat/feature-name. - Commit small and meaningful changes.
- Open a Pull Request with a description of your changes.
