bugfix
All checks were successful
Build & Push Docker Image / docker (push) Successful in 2m10s

This commit is contained in:
Ahmed Darrazi 2025-12-19 01:37:38 +01:00
parent e4d0ac9072
commit 3d67eedf0c
2 changed files with 26 additions and 9 deletions

View File

@ -49,9 +49,8 @@ class PlayerController extends Controller
try {
$user = Auth::user();
$section_id = $watch_history->current_section_id;
$watching_id = $lesson_id ?? $watch_history->current_watching_id;
$watching_type = $watch_history->current_watching_type ?? $type;
$watching_id = $lesson_id ?: $watch_history->current_watching_id;
$watching_type = in_array($type, ['lesson', 'quiz'], true) ? $type : ($watch_history->current_watching_type ?? 'lesson');
$course = $this->courseService->getUserCourseById($watch_history->course_id, $user);
$watching = $this->coursePlay->getWatchingLesson($watching_id, $watching_type);
@ -60,18 +59,14 @@ class PlayerController extends Controller
$totalReviews = $this->reviewService->totalReviews($course->id);
$zoomConfig = $this->zoomLiveService->zoomConfig;
$section = null;
$totalContent = 0;
foreach ($course->sections as $courseSection) {
$totalContent += count($courseSection->section_lessons) + count($courseSection->section_quizzes);
if ($courseSection->id == $section_id) {
$section = $courseSection;
}
}
$watchHistory = $this->coursePlay->watchHistory($course, $watching_id, $watching_type, $user->id);
$section = $course->sections->firstWhere('id', $watchHistory->current_section_id);
// $submissions = null;
// if ($assignment) {
@ -91,6 +86,28 @@ class PlayerController extends Controller
'zoomConfig' => $zoomConfig,
]);
} catch (ModelNotFoundException $th) {
$fallbackId = $watch_history->current_watching_id;
$fallbackType = $watch_history->current_watching_type;
$requestedType = $watching_type ?? $type;
if ($fallbackId && in_array($fallbackType, ['lesson', 'quiz'], true)) {
$isDifferentFromRequested = ((string) $fallbackId !== (string) $lesson_id) || ($fallbackType !== $requestedType);
if ($isDifferentFromRequested) {
try {
$this->coursePlay->getWatchingLesson((string) $fallbackId, $fallbackType);
return redirect()->route('course.player', [
'type' => $fallbackType,
'watch_history' => $watch_history->id,
'lesson_id' => $fallbackId,
]);
} catch (ModelNotFoundException $fallbackException) {
// Fall through to generic error below.
}
}
}
return redirect()->route('category.courses', ['category' => 'all'])->with('error', 'The requested content could not be found.');
} catch (\Throwable $th) {
return redirect()->route('category.courses', ['category' => 'all'])->with('error', $th->getMessage());

View File

@ -251,7 +251,7 @@ interface EnrollmentProgress {
enrollment: ExamEnrollment;
is_active: boolean;
attempts_used: number;
attempts_remaining: number;
attempts_remaining: number | null;
completed_attempts: number;
best_score: number;
has_passed: boolean;