set mycourese

This commit is contained in:
imadhigp 2026-08-05 12:58:03 +05:30
parent 41934b31fc
commit 679e37b780
10 changed files with 422 additions and 169 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class CoureseAssignController extends Controller
{
public function showMyCourse()
{
$studentLogId = session('student_log_id');
$studentId = session('student_id');
if (!$studentLogId && !$studentId) {
return redirect('/signin')->with('error', 'Please login first!');
}
$student = DB::table('student_details')
->where('student_portal_log_id', $studentLogId)
->orWhere('student_id', $studentId)
->first();
if (!$student) {
return redirect()->back()->with('error', 'Student record not found!');
}
$course = DB::table('courses')
->join('course_assign_student', 'courses.id', '=', 'course_assign_student.course_id')
->where('course_assign_student.student_details_id', $student->id)
->select('courses.*')
->first();
return view('mycourse', compact('course', 'student'));
}
public function showModule($id)
{
return view('module', ['moduleId' => $id]);
}
}

View File

@ -9,18 +9,18 @@ class ResultsController extends Controller
{
public function index()
{
// 1. Session එකෙන් ID එක ලබා ගැනීම
$studentLogId = session('student_log_id') ?? session('student_id');
// Session එකේ ID එකක් නොමැති නම් Login එකට Redirect කිරීම
if (!$studentLogId) {
return redirect('/signin')->with('error', 'Please login first!');
}
// 2. Log වී සිටින Student ගේ student_log_id එකට අදාළව දත්ත ලබා ගැනීම
$results = Result::where('student_log_id', $studentLogId)->get();
// 3. Calculations
$totalModules = $results->count();
$passedModules = $results->filter(function ($item) {
@ -29,7 +29,7 @@ class ResultsController extends Controller
$averageMarks = $totalModules > 0 ? round($results->avg('marks'), 1) : 0;
// View එකට Data Pass කිරීම
return view('results', compact('results', 'totalModules', 'passedModules', 'averageMarks'));
}
}

View File

@ -10,22 +10,20 @@ class TimetableController extends Controller
{
public function index()
{
// Session Check
$studentLogId = session('student_log_id') ?? session('student_id');
if (!$studentLogId) {
return redirect('/signin')->with('error', 'Please login first!');
}
// 1. All Timetable Records Get
// (තනි Student ට අදාළ දත්ත හෝ පොදු Timetable දත්ත)
$rawTimetables = Timetable::whereNull('student_log_id')
->orWhere('student_log_id', $studentLogId)
->orderBy('sort_order', 'asc')
->get();
// Data එක Table එකට ලෙහෙසියෙන් Group කර ගැනීම
// Array structure: $schedule[TimeSlot][Day] = Item
$schedule = [];
$timeSlots = [];
@ -36,8 +34,8 @@ class TimetableController extends Controller
$schedule[$item->time_slot][$item->day] = $item;
}
// 2. Today's Schedule (අද දවසේ පන්ති පමණක් ලබා ගැනීම)
$todayName = Carbon::now()->format('l'); // Monday, Tuesday etc.
$todayName = Carbon::now()->format('l');
$todaySchedule = Timetable::where('day', $todayName)
->where(function($q) use ($studentLogId) {
$q->whereNull('student_log_id')

View File

@ -27,4 +27,14 @@ class courses extends Model
'course_code',
'status'
];
public function students()
{
return $this->belongsToMany(
StudentDetail::class,
'course_assign_student',
'course_id',
'student_details_id'
);
}
}

View File

@ -19,8 +19,8 @@ return new class extends Migration
$table->string('semester');
$table->string('module_name');
$table->integer('marks');
$table->string('grade'); // e.g., 'A+', 'A', 'B', 'C', 'F'
$table->string('status')->default('Pass'); // 'Pass' or 'Fail'
$table->string('grade');
$table->string('status')->default('Pass');
$table->timestamps();
});
}

View File

@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::create('timetables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('student_log_id')->nullable(); // Student-specific Timetable එකක් නම්
$table->unsignedBigInteger('student_log_id')->nullable();
$table->string('time_slot');
$table->string('day');
$table->string('subject_name');

View File

@ -0,0 +1,219 @@
@extends('layouts.studentportalnav')
@section('title', 'Module Details')
@section('content')
<style>
:root {
--theme-navy: #2D355B;
--theme-navy-dark: #1F2541;
--theme-red: #822424;
--theme-red-hover: #df2c3e;
--theme-yellow: #FFEA85;
--bg-light: #F6F6F6;
--white: #ffffff;
}
body {
background: var(--bg-light);
font-family: 'Segoe UI', sans-serif;
}
.main-portal-content {
padding: 10px 5px;
min-height: 100vh;
}
/* Header styling */
.module-header {
background: var(--theme-navy);
color: var(--white);
border-radius: 16px;
padding: 25px 30px;
margin-bottom: 25px;
border-left: 5px solid var(--theme-red);
}
/* Video Wrapper */
.video-container {
position: relative;
padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
height: 0;
overflow: hidden;
border-radius: 14px;
background: #000;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
/* Card Styling */
.content-card {
border: 1px solid #e2e8f0;
border-radius: 14px;
background: var(--white);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
margin-bottom: 20px;
}
/* Lesson List */
.lesson-list .list-group-item {
border: none;
border-bottom: 1px solid #f1f5f9;
padding: 14px 20px;
transition: all 0.2s;
}
.lesson-list .list-group-item:hover {
background-color: #f8fafc;
}
.lesson-list .list-group-item.active {
background-color: rgba(130, 36, 36, 0.08);
color: var(--theme-red);
font-weight: 600;
border-left: 4px solid var(--theme-red);
}
.btn-theme-red {
background-color: var(--theme-red) !important;
border-color: var(--theme-red) !important;
color: #fff !important;
border-radius: 8px;
font-weight: 600;
}
.btn-theme-red:hover {
background-color: var(--theme-red-hover) !important;
}
@media (min-width: 768px) {
.main-portal-content { padding: 15px; }
}
</style>
<div class="main-portal-content">
<div class="container-fluid">
<!-- Back Button & Header -->
<div class="mb-3">
<a href="{{ route('mycourse') }}" class="text-decoration-none text-muted small fw-semibold">
<i class="fa fa-arrow-left me-1"></i> Back to My Course
</a>
</div>
<div class="module-header d-flex flex-wrap align-items-center justify-content-between gap-3">
<div>
<span class="badge bg-danger mb-2">Module {{ $moduleId ?? 1 }}</span>
<h2 class="fw-bold mb-1">Introduction & Fundamentals</h2>
<p class="mb-0 opacity-75 small">Learn the basic concepts, core principles, and foundational theories.</p>
</div>
<div>
<button class="btn btn-outline-light btn-sm px-3">
<i class="fa-solid fa-check-circle me-1"></i> Mark as Complete
</button>
</div>
</div>
<!-- Main Content Area -->
<div class="row g-4">
<!-- LEFT: Video Player & Module Details -->
<div class="col-lg-8 col-12">
<!-- Video Container -->
<div class="content-card p-2">
<div class="video-container">
<!-- Sample Video URL (replace with actual video stream/iframe) -->
<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="Lesson Video" allowfullscreen></iframe>
</div>
</div>
<!-- Module Description Card -->
<div class="content-card p-4">
<h4 class="fw-bold mb-3" style="color: var(--theme-navy);">Overview & Description</h4>
<p class="text-secondary lh-base">
In this module, you will explore the essential foundational topics. We will cover step-by-step concepts to help you build a strong understanding before moving on to the advanced practical modules.
</p>
<hr class="my-4" style="color: #cbd5e1;">
<h5 class="fw-bold mb-3" style="color: var(--theme-navy);">Resources & Downloads</h5>
<div class="d-flex flex-wrap gap-2">
<a href="#" class="btn btn-light border btn-sm text-dark">
<i class="fa-solid fa-file-pdf text-danger me-2"></i> Lecture Notes.pdf
</a>
<a href="#" class="btn btn-light border btn-sm text-dark">
<i class="fa-solid fa-file-lines text-primary me-2"></i> Assignment Guide.docx
</a>
</div>
</div>
<!-- Navigation Buttons -->
<div class="d-flex justify-content-between align-items-center mb-4">
<button class="btn btn-secondary btn-sm px-4 py-2" disabled>
<i class="fa fa-chevron-left me-1"></i> Previous Module
</button>
<a href="#" class="btn btn-theme-red btn-sm px-4 py-2">
Next Module <i class="fa fa-chevron-right ms-1"></i>
</a>
</div>
</div>
<!-- RIGHT: Lesson Playlist Sidebar -->
<div class="col-lg-4 col-12">
<div class="content-card overflow-hidden">
<div class="p-3 border-bottom bg-light">
<h6 class="fw-bold mb-0" style="color: var(--theme-navy);">
<i class="fa-solid fa-list-ul me-2" style="color: var(--theme-red);"></i> Course Playlist
</h6>
</div>
<ul class="list-group list-group-flush lesson-list">
<li class="list-group-item active d-flex justify-content-between align-items-center">
<div>
<i class="fa-solid fa-circle-play me-2"></i>
<span>1. Introduction to Course</span>
</div>
<span class="badge bg-danger rounded-pill">10 mins</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<i class="fa-regular fa-circle-play me-2 text-muted"></i>
<span>2. Core Concepts Explained</span>
</div>
<span class="badge bg-secondary rounded-pill">15 mins</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<i class="fa-regular fa-circle-play me-2 text-muted"></i>
<span>3. Practical Application</span>
</div>
<span class="badge bg-secondary rounded-pill">20 mins</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<i class="fa-solid fa-lock me-2 text-muted"></i>
<span class="text-muted">4. Summary & Quiz</span>
</div>
<span class="badge bg-light text-dark border">Locked</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -189,35 +189,37 @@ body {
border-radius: 2px;
}
/* Responsive Media Queries */
@media (min-width: 768px) {
.main-portal-content {
padding: 10px;
}
.hero {
padding: 40px;
}
.course-card img {
height: 280px;
}
.main-portal-content { padding: 10px; }
.hero { padding: 40px; }
.course-card img { height: 280px; }
}
</style>
<div class="main-portal-content">
<div class="container-fluid">
@if($course)
{{-- Dynamic Image URL Handler --}}
@php
$imageSrc = Str::startsWith($course->image, ['http://', 'https://'])
? $course->image
: asset('storage/' . $course->image);
@endphp
<!-- Hero Section -->
<div class="hero">
<div class="row align-items-center">
<div class="col-lg-9 col-md-8 text-start">
<h1 class="fw-bold display-6 mb-2">Diploma in Automotive Engineering</h1>
<h1 class="fw-bold display-6 mb-2">{{ $course->title }}</h1>
<p class="lead mb-4 small opacity-75">Welcome back! Continue your learning journey and complete all modules.</p>
<a href="#" class="btn btn-continue px-4 py-2 fw-semibold shadow-sm">
<i class="fa fa-play me-2"></i> Continue Learning
</a>
</div>
<div class="col-lg-3 col-md-4 text-center d-none d-md-block">
<i class="fa-solid fa-car-side" style="font-size: 157px;opacity: 0.35;color: #8C080F;"></i>
<i class="fa-solid fa-graduation-cap" style="font-size: 140px; opacity: 0.35; color: #8C080F;"></i>
</div>
</div>
</div>
@ -230,29 +232,31 @@ body {
<!-- Main Course Card -->
<div class="card course-card">
<img src="https://images.unsplash.com/photo-1486262715619-67b85e0b08d3?auto=format&fit=crop&w=1200&q=80" alt="Course Image">
<img src="{{ $imageSrc }}" alt="{{ $course->title }}" onerror="this.onerror=null;this.src='https://images.unsplash.com/photo-1486262715619-67b85e0b08d3?auto=format&fit=crop&w=1200&q=80';">
<div class="card-body p-4">
<div class="d-flex flex-wrap justify-content-between align-items-start gap-2 mb-3">
<div>
<h3 class="fw-bold mb-1" style="color: var(--theme-navy);">AE101</h3>
<h3 class="fw-bold mb-1" style="color: var(--theme-navy);">{{ $course->course_code ?? $course->title }}</h3>
<p class="text-muted small mb-0">
<i class="fa-solid fa-building me-1" style="color: var(--theme-red);"></i> Automotive Engineering Department
<i class="fa-solid fa-user me-1" style="color: var(--theme-red);"></i> {{ $course->author ?? 'Instructor' }}
</p>
</div>
<span class="badge px-3 py-2 rounded-pill" style="background-color: var(--theme-navy); color: var(--theme-yellow);">Diploma</span>
<span class="badge px-3 py-2 rounded-pill" style="background-color: var(--theme-navy); color: var(--theme-yellow);">
{{ $course->badge ?? 'Active Course' }}
</span>
</div>
<p class="text-secondary small lh-base">
Master engine diagnostics, suspension systems, transmission technology, electrical systems, and hybrid vehicle maintenance through hands-on training and theoretical modules.
{{ $course->desc ?? 'No description available for this course.' }}
</p>
<div class="mt-4">
<div class="d-flex justify-content-between mb-2 small">
<span class="fw-semibold" style="color: var(--theme-navy);">Overall Progress</span>
<span class="fw-bold" style="color: var(--theme-red);">55%</span>
<span class="fw-bold" style="color: var(--theme-red);">0%</span>
</div>
<div class="progress">
<div class="progress-bar" style="width:55%"></div>
<div class="progress-bar" style="width:0%"></div>
</div>
</div>
</div>
@ -265,75 +269,22 @@ body {
</h4>
</div>
<!-- Modules Sub-Grid -->
<!-- Modules Sub-Grid (Sample Modules Interface) -->
<div class="row g-4">
<!-- Module 1 -->
<div class="col-md-6 col-12">
<div class="card module-card h-100">
<div class="card-body p-4 d-flex flex-column justify-content-between">
<div>
<div class="d-flex justify-content-between align-items-start gap-2 mb-2">
<h6 class="fw-bold mb-0" style="color: var(--theme-navy);">Engine Fundamentals</h6>
<span class="status completed">Completed</span>
</div>
<p class="text-muted small mb-0">Learn engine parts and working principles.</p>
</div>
<div class="mt-4">
<button class="btn btn-theme-navy w-100 btn-sm py-2">Review Module</button>
</div>
</div>
</div>
</div>
<!-- Module 2 -->
<div class="col-md-6 col-12">
<div class="card module-card h-100">
<div class="card-body p-4 d-flex flex-column justify-content-between">
<div>
<div class="d-flex justify-content-between align-items-start gap-2 mb-2">
<h6 class="fw-bold mb-0" style="color: var(--theme-navy);">Transmission Systems</h6>
<h6 class="fw-bold mb-0" style="color: var(--theme-navy);">Introduction & Fundamentals</h6>
<span class="status progressing">In Progress</span>
</div>
<p class="text-muted small mb-0">Manual & Automatic transmission systems.</p>
<p class="text-muted small mb-0">Basic concepts and core theories.</p>
</div>
<div class="mt-4">
<button class="btn btn-theme-red w-100 btn-sm py-2">Continue Learning</button>
</div>
</div>
</div>
</div>
<!-- Module 3 -->
<div class="col-md-6 col-12">
<div class="card module-card h-100">
<div class="card-body p-4 d-flex flex-column justify-content-between">
<div>
<div class="d-flex justify-content-between align-items-start gap-2 mb-2">
<h6 class="fw-bold text-secondary mb-0">Brake Systems</h6>
<span class="status locked"><i class="fa fa-lock me-1"></i> Locked</span>
</div>
<p class="text-muted small mb-0">Complete previous module to unlock.</p>
</div>
<div class="mt-4">
<button class="btn btn-secondary w-100 btn-sm py-2" disabled>Locked</button>
</div>
</div>
</div>
</div>
<!-- Module 4 -->
<div class="col-md-6 col-12">
<div class="card module-card h-100">
<div class="card-body p-4 d-flex flex-column justify-content-between">
<div>
<div class="d-flex justify-content-between align-items-start gap-2 mb-2">
<h6 class="fw-bold text-secondary mb-0">Hybrid Technology</h6>
<span class="status locked"><i class="fa fa-lock me-1"></i> Locked</span>
</div>
<p class="text-muted small mb-0">Learn EV and Hybrid systems.</p>
</div>
<div class="mt-4">
<button class="btn btn-secondary w-100 btn-sm py-2" disabled>Locked</button>
<button type="button" onclick="goToModule(1)" class="btn btn-theme-red w-100 btn-sm py-2">
Continue Learning
</button>
</div>
</div>
</div>
@ -347,10 +298,10 @@ body {
<div class="row g-3">
<div class="col-12">
<div class="info-box d-flex align-items-center">
<div class="stat-icon"><i class="fa fa-book"></i></div>
<div class="stat-icon"><i class="fa fa-layer-group"></i></div>
<div class="ms-3">
<h5 class="fw-bold mb-0" style="color: var(--theme-navy);">12</h5>
<span class="text-muted small">Modules Available</span>
<h5 class="fw-bold mb-0" style="color: var(--theme-navy);">{{ $course->level ?? 'General' }}</h5>
<span class="text-muted small">Course Level</span>
</div>
</div>
</div>
@ -359,7 +310,7 @@ body {
<div class="info-box d-flex align-items-center">
<div class="stat-icon"><i class="fa fa-clock"></i></div>
<div class="ms-3">
<h5 class="fw-bold mb-0" style="color: var(--theme-navy);">2 Years</h5>
<h5 class="fw-bold mb-0" style="color: var(--theme-navy);">{{ $course->duration ?? 'N/A' }}</h5>
<span class="text-muted small">Course Duration</span>
</div>
</div>
@ -369,8 +320,8 @@ body {
<div class="info-box d-flex align-items-center">
<div class="stat-icon"><i class="fa fa-award"></i></div>
<div class="ms-3">
<h5 class="fw-bold mb-0" style="color: var(--theme-navy);">NVQ Level 5</h5>
<span class="text-muted small">Qualification</span>
<h5 class="fw-bold mb-0" style="color: var(--theme-navy);">{{ $course->status ?? 'Enrolled' }}</h5>
<span class="text-muted small">Status</span>
</div>
</div>
</div>
@ -379,7 +330,29 @@ body {
</div> <!-- End Row -->
@else
<!-- Empty State: When no course is assigned -->
<div class="row justify-content-center py-5">
<div class="col-md-8 text-center">
<div class="p-5 rounded-4 shadow-sm bg-white border">
<i class="fas fa-graduation-cap fa-4x text-muted mb-3"></i>
<h3 class="fw-bold text-dark mb-2">No Assigned Course Found</h3>
<p class="text-muted mb-0">You do not have any course assigned to your profile yet. Please contact the administration for assistance.</p>
</div>
</div>
</div>
@endif
</div>
</div>
<script>
function goToModule(moduleId) {
window.location.href = "{{ url('/module') }}/" + moduleId;
}
</script>
@endsection

View File

@ -336,7 +336,7 @@ Download Card
</div>
</div>
</div> <!-- End Printable Area Container -->
</div>
<!-- Performance & Download Section (Side by Side) -->
<div class="row g-4 align-items-stretch">
@ -396,7 +396,7 @@ function generatePDF() {
const element = document.getElementById('pdf-download-area');
const button = document.getElementById('download-pdf-btn');
// Button status change while generating
button.disabled = true;
button.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>Generating PDF...';
@ -408,7 +408,7 @@ function generatePDF() {
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
// Generate PDF and restore button state
html2pdf().set(options).from(element).save().then(() => {
button.disabled = false;
button.innerHTML = '<i class="fas fa-download me-2"></i>Download PDF';

View File

@ -10,7 +10,10 @@ use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\coursesController;
use App\Http\Controllers\ApplyController;
use App\Http\Controllers\ResultsController;
use App\Http\Controllers\TimetableController; // 1. TimetableController එක Import කළා
use App\Http\Controllers\TimetableController;
use App\Http\Controllers\CoureseAssignController;
/*
|--------------------------------------------------------------------------
@ -121,4 +124,8 @@ Route::middleware(['web'])->group(function () {
Route::get('/Feedback&Complain', [FeedbackController::class, 'index'])->name('feedback.index');
Route::post('/Feedback&Complain/store', [FeedbackController::class, 'store'])->name('feedback.store');
Route::get('/mycourse', [CoureseAssignController::class, 'showMyCourse'])->name('mycourse');
Route::get('/module/{id}', [CoureseAssignController::class, 'showModule'])->name('module.show');
});