From 6f25b03d13eaea68e16f1c0a39ef294aa6e6daab Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 31 Jul 2025 18:34:29 +0200 Subject: [PATCH] wait #7677 @1 --- app/Models/ELearningMedia.php | 9 ++++++--- resources/elearningmedia/js/app.js | 9 +++++++++ resources/views/elearningmedia/index.blade.php | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Models/ELearningMedia.php b/app/Models/ELearningMedia.php index 636065d61..7b7bed504 100644 --- a/app/Models/ELearningMedia.php +++ b/app/Models/ELearningMedia.php @@ -87,6 +87,7 @@ class ELearningMedia extends ToolboxModel $this->addField('file', Files::class, __('Media'), ['acceptedFiles' => static::MEDIA_TYPES]); $this->addField('', FormSeparator::class); $this->addField('complete_button', Checkbox::class, __('Marquer terminer après un clic sur un bouton'), ['default' => true, 'when' => ['type' => 'pdf']]); + $this->addField('complete_button_close', Checkbox::class, __('Le bouton ferme également le cours'), ['default' => false, 'when' => ['type' => 'pdf', 'complete_button' => 1]]); $this->addField('complete_pct', Percent::class, __('Marquer terminé quand ce pourcentage est lu'), ['default' => 75, 'when' => ['complete_button' => 0, 'type' => ['logical_operator' => 'OR', 'values' => ['video', 'audio']]]]); } @@ -116,7 +117,8 @@ class ELearningMedia extends ToolboxModel /** @var Media $file */ $file = $this->getMediaInField('file')->first()->getPath(); - self::compileFromFile($file, $dest, $this->title, $organization, 'MEDIA_' . $this->id, $this->locale, $this->scorm_version, $this->type === 'pdf' && $this->complete_button ? "'button'" : $this->complete_pct); + $settings = ['complete_button_close' => $this->complete_button_close]; + self::compileFromFile($file, $dest, $this->title, $organization, 'MEDIA_' . $this->id, $this->locale, $this->scorm_version, $this->type === 'pdf' && $this->complete_button ? "'button'" : $this->complete_pct, $settings); } /** @@ -126,10 +128,11 @@ class ELearningMedia extends ToolboxModel * @param $organization string * @param $reference string * @param $complete_pct int|string + * @param $settings array * @return string * @throws \Exception */ - public static function compileFromFile($file, $dest, $title, $organization, $reference, $locale = 'en', $scorm_version = Version::SCORM_2004, $complete_pct = 75) + public static function compileFromFile($file, $dest, $title, $organization, $reference, $locale = 'en', $scorm_version = Version::SCORM_2004, $complete_pct = 75, $settings = []) { $spl = new \SplFileInfo($file); $ext = mb_strtolower($spl->getExtension()); @@ -159,7 +162,7 @@ class ELearningMedia extends ToolboxModel } $vdir->copy($file, 'media.' . $ext); $translations = ElearningTranslate::getLocaleTranslations($locale, true); - $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct, 'title' => $title, 'type' => $type, 'translations' => $translations])); + $vdir->file_put_contents('index.html', view('elearningmedia.index', ['settings' => $settings, 'complete_pct' => $complete_pct, 'title' => $title, 'type' => $type, 'translations' => $translations])); $vdir->sync(true); return $title; } diff --git a/resources/elearningmedia/js/app.js b/resources/elearningmedia/js/app.js index 5a63fe854..d197bf49d 100644 --- a/resources/elearningmedia/js/app.js +++ b/resources/elearningmedia/js/app.js @@ -97,11 +97,20 @@ function showCompleteButton() { btn.classList.add('visible'); btn.addEventListener('click', function (e) { markComplete(); + if(settings.complete_button_close){ + closeCourse(); + } e.preventDefault(); return false; }); } +function closeCourse(){ + parent.close(); + top.close(); + window.close(); +} + function markComplete() { cubeSCORM.scormMarkAsComplete(); } diff --git a/resources/views/elearningmedia/index.blade.php b/resources/views/elearningmedia/index.blade.php index 6832bc090..e4efd8c0c 100644 --- a/resources/views/elearningmedia/index.blade.php +++ b/resources/views/elearningmedia/index.blade.php @@ -17,6 +17,7 @@ -- 2.39.5