@extends('layouts.dashboard')
@section('title', $course->title)
@section('page_title', __('Learning'))
@php
$total = $course->sections->sum(fn ($s) => $s->lessons->count());
$doneCount = count($completedIds);
$media = $current ? \App\Support\Video::resolve($current, true) : ['kind' => 'none', 'url' => null, 'hls' => false, 'subtitles' => [], 'poster' => null, 'downloadable' => false, 'provider' => null];
// YouTube's own control bar keeps a clickable logo/title/related-videos
// overlay that opens youtube.com — no embed param removes it. Instead we
// render the raw player with native controls off and skin it with our
// own play/seek/mute/fullscreen bar, so nothing inside the iframe is
// reachable by a click.
$ytId = null;
if ($media['kind'] === 'iframe' && \Illuminate\Support\Str::contains((string) $media['url'], ['youtube.com', 'youtube-nocookie.com', 'youtu.be'])) {
preg_match('#/embed/([A-Za-z0-9_-]{6,})#', (string) $media['url'], $ytMatch);
$ytId = $ytMatch[1] ?? null;
}
@endphp
@section('content')
{{-- Shown only when the tutor can actually answer: enabled, and a key
is configured. Otherwise a learner would type a question and get an
administrator's error message back. --}}
@if(module_enabled('ai')
&& tenant_setting('ai_tutor_enabled', '1') === '1'
&& app(\Modules\Ai\Services\AiClient::class)->isConfigured())
@include('ai::partials.tutor')
@endif