fields ?? []; $showExams = $fields['show_student_exams'] ?? true; $showWishlist = $fields['show_student_wishlist'] ?? true; if ($tab === 'exams' && !$showExams) { abort(404); } if ($tab === 'wishlist' && !$showWishlist) { abort(404); } if ($tab !== 'courses' && !$request->user()->hasVerifiedEmail()) { return redirect() ->route('student.index', ['tab' => 'courses']) ->with('error', 'Please verify your email address.'); } $props = $this->studentService->getStudentData($tab); return Inertia::render('student/index', [ ...$props, 'tab' => $tab, 'status' => $request->session()->get('status'), ]); } public function show_course(int $id, string $tab) { $system = app('system_settings'); $fields = $system?->fields ?? []; $showCourseCertificate = $fields['show_course_certificate'] ?? true; $showCourseMarksheet = $fields['show_course_marksheet'] ?? true; if ($tab === 'certificate' && !$showCourseCertificate && !$showCourseMarksheet) { return redirect()->route('student.course.show', ['id' => $id, 'tab' => 'modules']); } $user = Auth::user(); $course = $this->studentService->getEnrolledCourse($id, $user); $props = $this->studentService->getEnrolledCourseOverview($id, $tab, $user); $zoomConfig = $tab === 'live_classes' ? $this->zoomLiveService->zoomConfig : null; $watchHistory = $this->coursePlayerService->getWatchHistory($id, $user->id); $completion = $this->coursePlayerService->calculateCompletion($course, $watchHistory); return Inertia::render('student/course', [ ...$props, 'tab' => $tab, 'course' => $course, 'watchHistory' => $watchHistory, 'zoomConfig' => $zoomConfig, 'completion' => $completion, ]); } public function show_exam(Request $request, int $id, string $tab) { $system = app('system_settings'); $fields = $system?->fields ?? []; if (($fields['show_student_exams'] ?? true) === false) { abort(404); } $user = Auth::user(); $exam = $this->examEnrollment->getEnrolledExam($id, $user); $attempts = $this->examAttempt->getExamAttempts(['exam_id' => $id, 'user_id' => $user->id]); $bestAttempt = $this->examAttempt->getBestExamAttempt($id, $user->id); $props = $this->studentService->getEnrolledExamTabProps($id, $tab, $user); if ($tab === 'resources') { $exam->load('resources'); } if ($tab === 'attempts' && $request->attempt) { $attemptId = (int) $request->attempt; $props['attempt'] = $this->examAttempt->getExamAttempt($attemptId, ['user_id' => $user->id]); } return Inertia::render('student/exam/index', [ ...$props, 'tab' => $tab, 'exam' => $exam, 'attempts' => $attempts, 'bestAttempt' => $bestAttempt, ]); } /** * Update the authenticated student's profile information. */ public function update_profile(UpdateStudentProfileRequest $request) { $this->studentService->updateProfile($request->validated(), Auth::user()->id); return redirect()->back()->with('success', 'Profile updated successfully'); } }