@extends('layouts.app') @section('title', $module->title) @section('content') @include('partials.flash')
arrow_back Back to {{ $course->title }}
@php $minSeconds = $minSeconds ?? $module->effectiveMinSeconds(); $remaining = $completed ? 0 : max(0, (int) $minSeconds - (int) ($secondsSpent ?? 0)); $timerActive = ! $completed && (int) $minSeconds > 0 && $remaining > 0; // Interactive blocks (video / flip card / knowledge check / carousel / accordion) must be completed before finishing. $interactionCount = $module->blocks->whereIn('type', ['video', 'flip_card', 'knowledge_check', 'carousel', 'accordion'])->count(); $gateLocked = ! $completed && ($remaining > 0 || $interactionCount > 0); // Plain-language guide to the activities a learner must engage with. $activityDefs = [ 'video' => fn ($n) => 'Watch '.($n > 1 ? "all {$n} videos" : 'the video'), 'accordion' => fn ($n) => 'Open every section of '.($n > 1 ? "{$n} accordions" : 'the accordion'), 'carousel' => fn ($n) => 'View every slide of '.($n > 1 ? "{$n} carousels" : 'the carousel'), 'knowledge_check' => fn ($n) => 'Answer '.($n > 1 ? "all {$n} knowledge checks" : 'the knowledge check'), 'flip_card' => fn ($n) => 'Flip '.($n > 1 ? "all {$n} cards" : 'the card'), ]; $activityCounts = $module->blocks->whereIn('type', array_keys($activityDefs))->groupBy('type')->map->count(); $activityGuide = collect($activityDefs)->filter(fn ($f, $t) => isset($activityCounts[$t]))->map(fn ($f, $t) => $f($activityCounts[$t]))->values(); $currentIndex = $modules->search(fn ($m) => $m->id === $module->id); $typeLabel = [ 'content' => 'Content', 'knowledge_check' => 'Knowledge Check', 'final_assessment' => 'Final Assessment', 'certificate' => 'Certificate', ]; @endphp {{-- Modules stepper (interactive) --}}
@php // Frontier = first module not yet completed. Anything after it is locked. $firstIncomplete = $modules->search(fn ($m) => $m->progress_status !== 'completed'); if ($firstIncomplete === false) { $firstIncomplete = $modules->count(); } @endphp @foreach($modules as $i => $m) @php $isCurrent = $m->id === $module->id; $isDone = $m->progress_status === 'completed'; $isQuiz = in_array($m->module_type, ['knowledge_check','final_assessment'], true); $isLocked = $i > $firstIncomplete && ! $isCurrent; $to = $isQuiz ? auth()->user()->learnRoute('course.assessment.start', [$course->slug, $m->id]) : auth()->user()->learnRoute('course.module.show', [$course->slug, $m->id]); $node = $isDone ? 'bg-primary text-on-primary' : ($isCurrent ? 'bg-primary text-on-primary ring-4 ring-primary/20' : 'bg-surface border border-outline-variant text-outline'); @endphp <{{ $isLocked ? 'div' : 'a' }} @unless($isLocked) href="{{ $to }}" @endunless title="{{ $isLocked ? 'Complete the previous module first' : $m->title }}" class="step-link relative flex flex-col items-center w-[150px] shrink-0 {{ $isLocked ? 'cursor-not-allowed opacity-60' : '' }}"> {{-- connector to next node --}} @unless($loop->last) @endunless {{-- node with animated ring on the current step --}} @if($isCurrent && !$isDone) @endif @if($isDone) check @elseif($isLocked) lock @elseif($isQuiz) quiz @else {{ $i + 1 }} @endif {{-- labels --}}

{{ $i + 1 }}. {{ $m->title }}

{{ $typeLabel[$m->module_type] ?? 'Module' }}

@endforeach
{{-- Content --}}
@if($module->module_image) {{ $module->title }} @endif

Module {{ $module->module_number }}

{{ $module->title }}

@php // Group consecutive flip cards so they render side by side in a row. $blockGroups = []; foreach ($module->blocks as $b) { $n = count($blockGroups); if ($b->type === 'flip_card' && $n && $blockGroups[$n - 1]['type'] === 'flip_card') { $blockGroups[$n - 1]['items'][] = $b; } else { $blockGroups[] = ['type' => $b->type, 'items' => [$b]]; } } @endphp @forelse($blockGroups as $group) @if($group['type'] === 'flip_card')
@foreach($group['items'] as $block) @include('partials._content-block', ['block' => $block]) @endforeach
@else @include('partials._content-block', ['block' => $group['items'][0]]) @endif @empty
description

This module has no content yet.

@endforelse {{-- End-of-module marker: signals the learner has reached the end of the reading --}} @if($module->blocks->isNotEmpty())
{{ $completed ? 'verified' : 'task_alt' }} {{ $completed ? 'Module completed' : "End of module — you've read it all" }}
@unless($completed)

Nice work reaching the end. Complete the steps to finish this module and continue.

@endunless
@endif
{{-- Sticky sidebar: timer (left) + Your progress (right) in one card --}}
{{-- LEFT: timer / status --}}
@if($timerActive) @php $r = 42; $circ = 2 * M_PI * $r; @endphp
--:--
@elseif($completed) check_circle @else {{ (int) $minSeconds > 0 ? 'timer' : 'menu_book' }} @endif
{{-- RIGHT: Your progress --}}

Your progress

@if($completed)

Module completed

@elseif($timerActive)

Unlocks when the timer ends — keep this open.

@elseif((int) $minSeconds > 0)

Minimum time reached

@else

Work through the content, then mark it complete.

@endif
@if($completed) @php $curIdx = $modules->search(fn ($m) => $m->id === $module->id); $nextMod = $curIdx !== false ? ($modules[$curIdx + 1] ?? null) : null; $nextHref = $nextMod ? (in_array($nextMod->module_type, ['knowledge_check', 'final_assessment'], true) ? auth()->user()->learnRoute('course.assessment.start', [$course->slug, $nextMod->id]) : auth()->user()->learnRoute('course.module.show', [$course->slug, $nextMod->id])) : null; @endphp @if($nextMod) Continue to next module arrow_forward

Next: {{ $nextMod->title }}

Back to course @else task_alt Back to course @endif @else @php // Plain-spoken version of the checklist, for the text-to-speech button. $mins = (int) ceil($minSeconds / 60); $speak = 'To complete this module. '; if ((int) $minSeconds > 0) { $speak .= 'First, spend at least '.$mins.' '.($mins === 1 ? 'minute' : 'minutes').' of active time on this page. The page must stay open and in view for the time to count. '; } if ($interactionCount > 0) { $speak .= ((int) $minSeconds > 0 ? 'Then, ' : 'You must ').'complete every activity in this module: '.$activityGuide->implode(', ').'. Each activity shows a tick once you have done it. '; } if ((int) $minSeconds <= 0 && $interactionCount <= 0) { $speak .= 'Read through the content on this page. '; } $speak .= 'When '.(((int) $minSeconds > 0 && $interactionCount > 0) ? 'both are' : 'that is').' done, the Mark complete button unlocks and you can finish the module.'; @endphp {{-- Guidance: exactly what's needed to complete this module --}}

To complete this module

    @if((int) $minSeconds > 0)
  • {{ $remaining > 0 ? 'radio_button_unchecked' : 'check_circle' }} Spend at least {{ (int) ceil($minSeconds / 60) }} min of active time on this page
  • @endif @if($interactionCount > 0)
  • radio_button_unchecked Complete every activity — 0/{{ $interactionCount }} {{ $activityGuide->implode(' · ') }}. Each shows a done tick when done.
  • @endif @if((int) $minSeconds <= 0 && $interactionCount <= 0)
  • menu_book Read through the content below, then mark it complete.
  • @endif
@csrf
@endif
@unless($completed) @endunless
{{-- /focus-container --}} @endsection