$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']]]]);
}
/** @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);
}
/**
* @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());
}
$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;
}