A comprehensive training platform built with MongoDB, Express.js, React, and Node.js.
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Tailwind CSS |
| Backend | Node.js, Express.js |
| Database | MongoDB |
| Authentication | JWT |
- ✅ Create, edit, delete training modules
- ✅ Rich text slide editor with drag-and-drop ordering
- ✅ PDF/Image upload support
- ✅ Quiz question management
- ✅ Worker management
- ✅ Company & department management
- ✅ Results reporting with export
- ✅ News/announcements system
- ✅ Polls & surveys
- ✅ Clean slide-based training viewer
- ✅ Progress tracking
- ✅ Quiz with randomized questions and answers
- ✅ Certificate generation
- ✅ Mobile-friendly responsive design
- ✅ Questions randomly ordered for each worker
- ✅ Answer options shuffled for each question
- ✅ Configurable passing scores
- ✅ Instant results feedback
training/
├── mern/
│ ├── client/ # React frontend
│ │ ├── src/
│ │ │ ├── api/ # API service functions
│ │ │ ├── components/ # Reusable components
│ │ │ ├── contexts/ # React contexts
│ │ │ ├── pages/ # Page components
│ │ │ └── App.jsx # Main app component
│ │ ├── package.json
│ │ └── vite.config.js
│ │
│ └── server/ # Express backend
│ ├── models/ # Mongoose models
│ ├── routes/ # API routes
│ ├── middleware/ # Auth middleware
│ ├── uploads/ # Uploaded files
│ ├── server.js # Entry point
│ └── package.json
│
└── README.md
- Node.js 18+
- MongoDB (local or Atlas)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd training
-
Install server dependencies
cd mern/server npm install -
Configure environment variables Create
mern/server/.env:PORT=5000 MONGODB_URI=mongodb://localhost:27017/training_system JWT_SECRET=your_jwt_secret_key
-
Install client dependencies
cd ../client npm install -
Seed the database (optional)
cd ../server npm run seed
Start the backend server:
cd mern/server
npm run devServer runs on http://localhost:5000
Start the frontend (new terminal):
cd mern/client
npm run devClient runs on http://localhost:5173
Build the client:
cd mern/client
npm run buildStart production server:
cd mern/server
npm start| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/login |
Worker login |
| POST | /api/admin/login |
Admin login |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/trainings |
List all trainings |
| POST | /api/trainings |
Create training |
| PUT | /api/trainings/:id |
Update training |
| DELETE | /api/trainings/:id |
Delete training |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/workers |
List all workers |
| POST | /api/workers |
Create worker |
| PUT | /api/workers/:id |
Update worker |
| DELETE | /api/workers/:id |
Delete worker |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/enrollments |
List enrollments |
| POST | /api/enrollments |
Create enrollment |
| PUT | /api/enrollments/:id |
Update enrollment |
Create backup:
cd mern/server
node backup.jsRestore from backup:
cd mern/server
node restore.js| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 5000 |
MONGODB_URI |
MongoDB connection string | - |
JWT_SECRET |
Secret for JWT tokens | - |
MIT License
- Filter by training, status, date
- Export to CSV
- Select training from home page
- View all slides (minimum time enforced)
- Enter SAP number and name
- Take quiz (randomized questions/answers)
- View instant results
trainings- Training modulestraining_slides- Slide contentquiz_questions- Quiz questionsquiz_answers- Answer options (4 per question)workers- Worker recordsquiz_attempts- Quiz attempt recordsquiz_responses- Individual answer responses
The system validates answers by answer ID, not letter position:
// Correct way (what this system does)
$isCorrect = ($selectedAnswerId == $correctAnswerId);
// Wrong way (don't do this)
$isCorrect = ($selectedLetter == 'A'); // Breaks with shuffle!Edit config/app.php:
define('DEFAULT_PASSING_SCORE', 80); // Default pass percentage
define('MAX_QUESTIONS_PER_QUIZ', 10); // Max questions per quiz
define('MIN_SLIDE_VIEW_TIME', 10); // Min seconds per slideEdit assets/css/worker.css for worker portal styles.
Admin styles are inline in admin/includes/header.php.
- Change default admin password immediately
- Use HTTPS in production
- Set proper file permissions
- Database credentials in config should be protected
- Session cookies are HTTP-only by default
training/
├── admin/
│ ├── ajax/
│ │ └── get_attempt_details.php
│ ├── includes/
│ │ ├── header.php
│ │ └── footer.php
│ ├── index.php # Dashboard
│ ├── login.php
│ ├── logout.php
│ ├── trainings.php # Training management
│ ├── slides.php # Slide editor (text/PDF/PPT)
│ ├── questions.php # Quiz editor
│ └── results.php # Reports
├── ajax/
│ ├── save_answer.php
│ └── track_slide.php
├── assets/
│ └── css/
│ └── worker.css
├── config/
│ ├── app.php
│ └── database.php
├── database/
│ └── schema.sql
├── uploads/
│ └── trainings/ # PDF/PPT uploads stored here
├── index.php # Worker home
├── training.php # Slide viewer (supports PDF/PPT)
├── sap_form.php # Worker registration
├── quiz.php # Quiz interface
├── submit_quiz.php # Quiz submission
├── results.php # Worker results
├── .htaccess
└── README.md
- PDF - Displayed directly in an embedded viewer
- PPT/PPTX - Provides download link for workers
- Go to Admin → Slides
- Select a training module
- Click "Upload PDF/PPT" button
- Choose file type (PDF or PowerPoint)
- Select your file (max 50MB)
- Set minimum view time (recommended 30+ seconds)
- Upload
- Convert PowerPoint to PDF for in-browser viewing
- Use meaningful slide titles
- Set appropriate minimum view times based on content length
- Organize slides in logical order using drag-and-drop
For issues or questions, contact your system administrator.
Internal use only. All rights reserved.