@extends('frontend.maintemplate.maintemplate') @section('title', 'Workshop Details' . ' :: AgeLess Institute') @section('content')

{{ $workshop->title }}

THEORY MATERIAL

Workshop Date - {{ \Carbon\Carbon::parse($workshop->date)->format('d M Y') }}

0% Complete

done

Completed

Track ID: {{ $registerWorkshop->tracking_id ?? '' }}

{{--
Foundation Course
--}}
@csrf @php $progress = $progressData ?? []; // Pull current progress for this user/workshop $statusReadBook = $progress['read_book']->status ?? 'pending'; $statusWatchVideo = $progress['watch_video']->status ?? 'pending'; $statusMcq = $progress['mcq']->status ?? 'pending'; $jsProgressData = [ 'read_book' => $statusReadBook, 'watch_video' => $statusWatchVideo, 'mcq' => $statusMcq ]; // Map button text/classes dynamically $btnMap = function ($status) { return [ 'text' => $status === 'pending' ? 'Start' : ($status === 'inprogress' ? 'Complete' : 'Completed'), 'class' => $status === 'inprogress' ? 'btn-success' : ($status === 'complete' ? 'btn-secondary' : 'btn-primary'), ]; }; $b1 = $btnMap($statusReadBook); $b2 = $btnMap($statusWatchVideo); $b3 = $btnMap($statusMcq); $hasPassingScore = isset($examAttempts[$workshop->id]) && $examAttempts[$workshop->id]->firstWhere('status', 'pass') !== null; $passScore = env('WORKSHOP_EXAM_PASS_SCORE', 85); $hasPassingScore = isset($examAttempts[$workshop->id]) && $examAttempts[$workshop->id]->first(function ($attempt) use ($passScore) { return $attempt->score >= $passScore; }) !== null; $latestScore = 0; if (isset($examAttempts[$workshop->id]) && $examAttempts[$workshop->id]->isNotEmpty()) { $latestScore = $examAttempts[$workshop->id]->first()['score']; } $workshopPdfs = $workshop->pdfs->sortBy(fn($p) => $p->sequence_number ?? 0)->values(); $totalPdfs = $workshopPdfs->count(); $hasPdfs = $totalPdfs > 0; $statusRow = \App\Models\WorkshopPurchasedStatus::where('workshop_id', $workshop->id) ->where('type', 'read_book') ->first(); $pdfDetails = $statusRow && $statusRow->workshop_pdfs_details ? json_decode($statusRow->workshop_pdfs_details, true) : []; $completedCount = collect($pdfDetails) ->filter(function ($status) { return $status === 'completed'; }) ->count(); $allPdfsRead = $completedCount >= $totalPdfs; @endphp
{{ $workshop->title ?? 'Workshop Title' }}

Module {{ in_array('pending', [$statusReadBook, $statusWatchVideo, $statusMcq]) ? 'In Progress' : 'Completed' }}

{{-- STEP 1: READ BOOK --}} @foreach($workshopPdfs as $index => $workshopPdf) @php $pdfState = $pdfDetails[$workshopPdf->id] ?? null; $isReading = $pdfState === 'reading'; $isCompleted = $pdfState === 'completed'; $prevCompleted = true; // if ($index > 0) { // $prevPdfId = $workshopPdf[$index - 1]->id; // $prevCompleted = isset($pdfDetails[$prevPdfId]) // && $pdfDetails[$prevPdfId] === 'completed'; // } if ($index > 0) { $prevPdfId = $workshopPdfs[$index - 1]->id; $prevCompleted = isset($pdfDetails[$prevPdfId]) && $pdfDetails[$prevPdfId] === 'completed'; } @endphp @endforeach {{-- STEP 2: WATCH VIDEO --}} @php // $videos = $workshop->videos ?? []; $videos = $workshop->videos->sortBy(function($vid) { return $vid->pivot->sequence_number ?? 0; })->values(); // reindex array @endphp @if($videos->count() > 0) {{-- Hidden video list (will appear after Start) --}} @foreach($videos as $index => $vid) @php $token = \Illuminate\Support\Str::uuid()->toString(); $secureUrl = \URL::temporarySignedRoute( 'secure.video', now()->addMinutes(120), ['filename' => $vid->video_upload, 'token' => $token] ); $watched = \App\Models\WorkshopPurchasedStatus::where('workshop_id', $workshop->id) ->where('user_id', auth()->id()) ->where('type', 'watch_video') ->whereRaw("JSON_EXTRACT(video_details, '$.\"{$vid->id}\"') IS NOT NULL") ->exists(); @endphp @endforeach @endif {{-- STEP 3: MCQ --}}
Step 1 Read Book @if ($statusReadBook == 'complete') @elseif($statusReadBook == 'inprogress') @if($allPdfsRead) @else @endif @else @endif @if ($statusReadBook === 'complete')
doneCompleted
@else
{{ ucfirst($statusReadBook) }}
@endif
Read PDF {{ $index + 1 }} {{-- COMPLETED --}} @if($isCompleted) Read {{-- READING (PAGE REFRESH SAFE) --}} @elseif($isReading) Read {{-- NOT STARTED --}} @else Read @endif @if($isCompleted)
doneCompleted
@else
Pending
@endif
Step 2 Watch Video @if($statusWatchVideo === 'complete') @else @if($statusWatchVideo === 'pending') @else @endif @endif @if($statusWatchVideo === 'complete')
doneCompleted
@else
{{ ucfirst($statusWatchVideo) }}
@endif
Watch Video {{ $index + 1 }} @if ($watched) @endif 0) disabled @endif> {{ $watched ? 'Rewatch' : 'View' }} @if($watched)
doneCompleted
@else
Pending
@endif
Step 3 MCQ @php // @dd($statusReadBook,$statusWatchVideo); $mcqEnabled = $statusReadBook === 'complete' && ($statusWatchVideo === 'complete'); $mcqText = $statusMcq === 'pending' ? 'Solve' : $b3['text']; @endphp @if ($statusMcq === 'complete') @if($hasPassingScore) @else @endif @else @endif @if ($statusMcq === 'complete') {{--
doneCompleted
--}} @if($hasPassingScore)
doneCompleted
@else
warning {{ $examScores[$workshop->id] ?? 0 }}%
@endif @else
@endif
@endsection @section('custome_js') {{-- --}} @endsection