Skip to content

azri-cs/yp-student-portal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ Student Portal

A comprehensive Laravel 11 Student Portal with complete academic management system, examination platform, and institutional administration features.

πŸš€ Features

🎯 Role-Based Access Control (RBAC)

  • Manual RBAC implementation (no external packages)
  • Three user roles: Admin, Lecturer, Student
  • Granular permission system
  • Middleware and gate-based authorization
  • Automatic student role assignment on registration

πŸ“š Academic Management System

  • Grade Management: Complete gradebook system with GPA calculation and academic standing
  • Attendance Tracking: Daily attendance recording with sessions and analytics
  • Assignment System: File upload, grading, and feedback system
  • Progress Reports: Comprehensive student performance tracking with PDF export
  • Academic Calendar: Event management, scheduling, and holiday periods
  • Course Scheduling: Timetable management with conflict detection

πŸ“ Advanced Examination System

  • Server-side timer with precise duration tracking
  • Browser timer synchronization with real-time updates
  • Automatic submission when time expires
  • Multiple question types: MCQ, True/False, Essay, Short Answer
  • Question bank management with advanced options
  • Exam scheduling with calendar view
  • Proctoring and monitoring capabilities
  • Exam statistics and performance analytics

🏒 Institutional Administration

  • Department Management: Complete department administration system
  • Library System: Resource management with borrowing and reservations
  • Communication System: Messaging, announcements, and notifications
  • Analytics Dashboard: Real-time metrics and comprehensive reporting
  • Bulk Operations: Mass student management and data export

πŸ“± Mobile-Optimized Experience

  • Mobile-first design with responsive layouts
  • Touch-optimized interface for all features
  • Device detection with automatic view selection
  • Bottom navigation and mobile-friendly interactions
  • Progressive enhancement for all device types

πŸ‘₯ Role-Based Dashboards

  • Admin Dashboard: System statistics, user management, academic oversight
  • Student Dashboard: Academic progress, assignments, exams, grades
  • Lecturer Dashboard: Subject management, class overview, grading, analytics

🎨 User Experience

  • Responsive design with Tailwind CSS
  • Livewire Volt components for reactive interface
  • Real-time updates without page refreshes
  • Intuitive navigation with role-based menu items
  • Progress indicators and status notifications
  • Search functionality across all modules
  • Dark mode support for all interfaces

πŸ› οΈ Technology Stack

  • Backend: Laravel 11 with PHP 8.3
  • Frontend: Livewire 3 + Volt + Tailwind CSS 3
  • Database: SQLite (default) with Eloquent ORM
  • Testing: PHPUnit 11 with comprehensive coverage
  • Build Tool: Vite with HMR support
  • Authentication: Laravel Breeze with email verification

πŸ“‹ Requirements

  • PHP: 8.2 or higher
  • Composer: Latest version
  • Node.js: 16+ and NPM
  • Database: SQLite (default), MySQL 8+, PostgreSQL 12+
  • Web Server: Apache 2.4+ or Nginx
  • SSL: Required for production (Let's Encrypt recommended)

πŸš€ Development Setup

1. Clone the Repository

git clone <repository-url>
cd yp-student-portal

2. Install Dependencies

# Install PHP dependencies
composer install

# Install Node.js dependencies
npm install

3. Environment Configuration

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Configure environment variables
nano .env  # Or your preferred editor

4. Environment Configuration

# IMPORTANT: Set your local timezone
APP_TIMEZONE=Asia/Kuala_Lumpur  # Change to your timezone

# Other timezone examples:
# APP_TIMEZONE=America/New_York
# APP_TIMEZONE=Europe/London
# APP_TIMEZONE=Asia/Singapore
# APP_TIMEZONE=Australia/Sydney

5. Database Setup

# Run migrations with seeding (creates admin, lecturer, and student accounts)
php artisan migrate:fresh --seed

# For development: Use SQLite (default)
# For production: Configure MySQL/PostgreSQL in .env

6. Asset Compilation

# Development build with HMR
npm run dev

# Production build (optimized)
npm run build

7. Start Development Environment

# Full development environment (recommended)
composer run dev

# Or run individual services:
php artisan serve              # Laravel development server (http://localhost:8000)
npm run dev                   # Vite HMR for frontend
php artisan queue:listen      # Queue worker for background jobs
php artisan pail              # Log monitoring

8. Verify Installation

Visit http://localhost:8000 and test with default credentials:

Role Email Password
Admin admin@example.com password
Lecturer lecturer@example.com password
Student student@example.com password

⚠️ Change default passwords in production!

⚠️ Troubleshooting Common Issues

Timezone Issues

If you encounter problems with examination timing (e.g., exams showing incorrect start/end times):

  1. Check your timezone setting in .env:

    APP_TIMEZONE=Asia/Kuala_Lumpur  # Set to your local timezone
  2. Clear configuration cache after changing timezone:

    php artisan config:clear
  3. Available timezones (find yours at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones):

    • Asia/Kuala_Lumpur (Malaysia/Singapore)
    • Asia/Singapore (Singapore)
    • America/New_York (Eastern Time)
    • America/Los_Angeles (Pacific Time)
    • Europe/London (UK)
    • Australia/Sydney (Australia)

Examination Display Issues

If students can't see examinations:

  1. Verify student enrollment in a class with subjects
  2. Check examination is active and published
  3. Confirm start/end times are correct for your timezone
  4. Ensure student has take_examinations permission

πŸš€ Production Deployment

1. Server Requirements

  • PHP: 8.2+ with required extensions
  • Database: MySQL 8+ or PostgreSQL 12+
  • Web Server: Apache 2.4+ or Nginx
  • SSL Certificate: Required for secure connections
  • File Storage: Adequate space for uploads and logs

2. Environment Configuration

# Production environment settings
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.com

# Database configuration
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=student_portal
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password

# Mail configuration (for notifications)
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="noreply@your-domain.com"

# File storage
FILESYSTEM_DISK=local
AWS_ACCESS_KEY_ID=your-access-key  # For S3 if using
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=your-bucket-name
AWS_USE_PATH_STYLE_ENDPOINT=false

# Cache and session configuration
CACHE_DRIVER=database
SESSION_DRIVER=database
QUEUE_CONNECTION=database

3. Deployment Steps

Using Git Deployment

# Pull latest code
git pull origin main

# Install/update dependencies
composer install --no-dev --optimize-autoloader
npm ci --production

# Run migrations
php artisan migrate --force

# Optimize Laravel
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache

# Build assets
npm run build

# Set permissions
chmod -R 775 storage
chmod -R 775 bootstrap/cache

# Restart services (if using queue workers)
php artisan queue:restart

Using Deployment Tools

Recommended for production:

  • Laravel Forge: Automated server management
  • Envoyer: Zero-downtime deployment
  • Vapor: Serverless deployment

4. Web Server Configuration

Apache Configuration

<VirtualHost *:80>
    ServerName your-domain.com
    Redirect permanent / https://your-domain.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName your-domain.com
    DocumentRoot /var/www/yp-student-portal/public

    SSLEngine on
    SSLCertificateFile /path/to/cert.pem
    SSLCertificateKeyFile /path/to/privkey.pem

    <Directory /var/www/yp-student-portal/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Nginx Configuration

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name your-domain.com;
    root /var/www/yp-student-portal/public;
    index index.php;

    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}

5. Post-Deployment Tasks

# Create storage symlink (if needed)
php artisan storage:link

# Clear caches
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

# Schedule setup (add to crontab)
* * * * * cd /var/www/yp-student-portal && php artisan schedule:run >> /dev/null 2>&1

# Queue worker setup (for background jobs)
# Use Supervisor or systemd for process management

6. Security Considerations

# Set proper file permissions
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod -R 775 storage bootstrap/cache

# Update .env with secure values
# - Change default passwords
# - Use strong APP_KEY
# - Configure secure mail settings
# - Set up proper file permissions

7. Monitoring and Maintenance

# Regular maintenance commands
php artisan backup:run                # If using laravel-backup
php artisan queue:work               # Process queued jobs
php artisan schedule:run            # Run scheduled tasks
php artisan log:clear               # Clear old logs
php artisan cache:clear             # Clear cache

8. Backup Strategy

  • Database: Daily automated backups
  • Files: Regular backup of storage directory
  • Configuration: Backup .env file
  • Code: Version control with Git

9. Performance Optimization

# Enable OPcache
# Configure Redis for caching
# Use CDN for static assets
# Enable gzip compression
# Implement proper database indexing

πŸ” Default Login Credentials

Role Email Password
Admin admin@example.com password
Lecturer lecturer@example.com password
Student student@example.com password

⚠️ Change passwords in production!

πŸ“‚ Project Structure

app/
β”œβ”€β”€ Models/                    # Eloquent models
β”‚   β”œβ”€β”€ User.php              # User model with RBAC methods
β”‚   β”œβ”€β”€ Role.php              # Role model
β”‚   β”œβ”€β”€ Permission.php        # Permission model
β”‚   β”œβ”€β”€ Examination.php       # Examination model with subject relationship
β”‚   β”œβ”€β”€ ExaminationAttempt.php # Attempt tracking
β”‚   β”œβ”€β”€ Subject.php           # Subject model
β”‚   β”œβ”€β”€ ClassModel.php        # Class model with student enrollment
β”‚   β”œβ”€β”€ Question.php          # Questions model with advanced options
β”‚   β”œβ”€β”€ QuestionOption.php    # Question options with relational storage
β”‚   └── Answer.php            # Answer model
β”œβ”€β”€ Http/
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”œβ”€β”€ ExaminationController.php
β”‚   β”‚   β”œβ”€β”€ AdminController.php
β”‚   β”‚   β”œβ”€β”€ StudentDashboardController.php
β”‚   β”‚   β”œβ”€β”€ LecturerDashboardController.php
β”‚   β”‚   β”œβ”€β”€ SubjectController.php
β”‚   β”‚   β”œβ”€β”€ ClassController.php
β”‚   β”‚   └── EnrollmentController.php
β”‚   └── Middleware/
β”‚       β”œβ”€β”€ PermissionMiddleware.php
β”‚       └── RoleMiddleware.php
β”œβ”€β”€ Providers/
β”‚   └── AuthServiceProvider.php # Gates and policies
└── View/
    └── Components/           # Blade components

database/
β”œβ”€β”€ migrations/               # Database schema
β”œβ”€β”€ seeders/                 # Sample data
└── factories/               # Test data generation

resources/
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ admin/               # Admin dashboard views
β”‚   β”œβ”€β”€ student/             # Student dashboard views
β”‚   β”œβ”€β”€ lecturer/            # Lecturer dashboard views
β”‚   β”œβ”€β”€ examinations/        # Examination views
β”‚   β”œβ”€β”€ subjects/            # Subject management views
β”‚   β”œβ”€β”€ classes/             # Class management views
β”‚   β”œβ”€β”€ enrollment/          # Student enrollment views
β”‚   └── livewire/            # Livewire components
β”‚       β”œβ”€β”€ examinations/    # Examination components
β”‚       └── layout/          # Navigation components
└── js/
    └── examination-timer.js  # Timer synchronization

tests/
β”œβ”€β”€ Feature/                # Feature tests
β”œβ”€β”€ Unit/                   # Unit tests
└── TestCase.php           # Base test case

🎯 Core Features

πŸ—οΈ Architecture Improvements

  • Relational Question Options: Migrated from JSON to relational table structure for better data integrity
  • Subject-Based Organization: Examinations categorized by subjects with filtering capabilities
  • Role-Based Navigation: Dynamic navigation showing relevant options based on user roles
  • One-to-Many with Constraints: Flexible many-to-many relationships with one-to-one enforcement where needed
  • Comprehensive Relationships: Well-defined Eloquent relationships across all models

RBAC System

  • User-Role-Permission relationships
  • Dynamic permission checking
  • Role-based middleware
  • Gate definitions for common operations
  • Policy-based authorization ready

Examination System

  • Timer synchronization between server and browser
  • Auto-save functionality for answers
  • Real-time progress tracking
  • Automatic submission on timeout
  • Results calculation and display
  • Question navigation with progress indicators
  • Subject-based filtering and organization
  • Advanced question options with relational storage supporting:
    • Multiple correct answers
    • Weighted scoring per option
    • Better data integrity with foreign key constraints
    • Improved querying and analytics capabilities

Admin Dashboard

  • System statistics dashboard
  • User management with role assignment
  • Role-permission management
  • Examination management (lecturers)
  • Results viewing (admin/lecturers)

Student Dashboard

  • Class enrollment status and management
  • Upcoming examinations based on enrolled subjects
  • Available examinations with subject filtering
  • Recent examination results and performance tracking
  • Academic statistics (exams completed, average score, passed exams)

Lecturer Dashboard

  • Subject management and overview
  • Class management with student enrollment tracking
  • Examination creation and management
  • Student result analysis and performance tracking
  • System analytics and reporting

πŸ§ͺ Testing

Run the test suite:

# Run all tests
php artisan test

# Run specific test file
php artisan test tests/Feature/ExaminationTest.php

# Run with coverage
php artisan test --coverage

Test Coverage

  • RBAC functionality (role/permission management)
  • Examination system (timer, submission, results)
  • Authentication (registration, login, access control)
  • Admin features (dashboard, user management)
  • Student enrollment (class/subject management)
  • Question options (relational storage, multiple correct answers)
  • Role-based dashboards (student/lecturer/admin views)
  • Subject-based examinations (filtering and categorization)
  • API endpoints (examination APIs)

πŸ”„ Development Workflow

Available Commands

# Development
composer run dev              # Full development environment
php artisan serve             # Laravel server
npm run dev                  # Vite HMR
php artisan queue:listen      # Queue worker
php artisan pail              # Log monitoring

# Database
php artisan migrate           # Run migrations
php artisan db:seed           # Seed database
php artisan migrate:fresh     # Fresh migration
php artisan tinker            # Interactive shell

# Testing
php artisan test              # Run tests
php artisan test --filter=testName
vendor/bin/pint --dirty       # Code formatting

# Build
npm run build                # Production build
npm run dev                  # Development build

Code Quality

  • Laravel Pint for code formatting
  • Strict type declarations throughout
  • PSR-12 coding standards
  • Comprehensive test coverage
  • Model factories for test data

πŸš€ Deployment

Production Build

# Build assets
npm run build

# Optimize Laravel
php artisan config:cache
php artisan route:cache
php artisan view:cache

# Set up production database
php artisan migrate --force
php artisan db:seed --force

Environment Variables

APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.com

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

πŸ”’ Security Features

  • Role-based access control (RBAC)
  • Permission-based authorization
  • Email verification support
  • Password confirmation for sensitive actions
  • CSRF protection enabled
  • SQL injection prevention with Eloquent
  • XSS protection with Blade templating
  • Rate limiting on authentication routes

πŸ“Š Performance

  • Database indexing on foreign keys and unique columns
  • Eager loading to prevent N+1 queries
  • Query caching for frequently accessed data
  • Asset optimization with Vite
  • Response caching where appropriate
  • Lazy loading for large datasets

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Standards

  • Follow PSR-12 coding standards
  • Use strict type declarations
  • Write tests for new features
  • Run code formatting before committing
  • Update documentation as needed

πŸ™ Acknowledgments

  • Laravel - The PHP Framework for Web Artisans
  • Livewire - Full-stack framework for Laravel
  • Tailwind CSS - Utility-first CSS framework
  • Volt - Single-file Livewire components

πŸ“ž Support

For support and questions:

About

Yayasan Peneraju Technical Test on 24th September 2025

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages