From: Vincent Vanwaelscappel Date: Tue, 8 Feb 2022 19:08:21 +0000 (+0100) Subject: wip #5041 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b6ae1df6b51b96a24571e778fad28d1dc4bb447f;p=fluidbook-toolbox.git wip #5041 @1.5 --- diff --git a/app/Models/ELearningPackage.php b/app/Models/ELearningPackage.php new file mode 100644 index 000000000..2450dfadf --- /dev/null +++ b/app/Models/ELearningPackage.php @@ -0,0 +1,65 @@ + 'elearning-package', + 'singular' => 'package', + 'plural' => 'package']; + + protected static $_permissionBase = 'elearning-package'; + + + protected $_operations = [ImportOperation::class, PreviewOperation::class, DownloadOperation::class]; + + public function setFields() + { + parent::setFields(); + + $this->addField('title', Text::class, __('Titre'), ['column' => true]); + $this->addField('description', Textarea::class, __('Description')); + + $this->addOwnerField(); + $this->addColumnDateFields(); + + $this->addField('contents', BunchOfFieldsMultiple::class, __('Contenus'), ['bunch' => ElearningPackageContent::class, 'edit_label' => __('Editer « :label »', ['label' => '%content_type - %content_title'])]); + } + + public function getFinalPath() + { + return protected_path('elearningpackage/final/' . $this->id); + } + + public function compile($dest) + { + $owner = User::withoutGlobalScopes()->findOrFail($this->owner); + $organization = $owner->companyName; + + $vdir = new VirtualDirectory($dest); + $vdir->file_put_contents('imsmanifest.xml', new Manifest($this->title, Manifest::SCORM_2004, $organization, 'MEDIA_' . $this->id)); + $vdir->copyDirectory(resource_path('elearningmedia/dist/css'), 'css'); + $vdir->copyDirectory(resource_path('elearningmedia/dist/js'), 'js'); + /** @var Media $file */ + $file = $this->getMediaInField('file')->first(); + $spl = new \SplFileInfo($file->getPath()); + $ext = mb_strtolower($spl->getExtension()); + $vdir->copy($file->getPath(), 'media.' . $ext); + $vdir->file_put_contents('index.html', view('elearningmedia.index', ['media' => $this->getPageData(), 'type' => $ext === 'mp3' ? 'audio' : 'video'])); + $vdir->sync(true); + } +} diff --git a/app/SubForms/ElearningPackageContent.php b/app/SubForms/ElearningPackageContent.php new file mode 100644 index 000000000..a7ba28ec3 --- /dev/null +++ b/app/SubForms/ElearningPackageContent.php @@ -0,0 +1,36 @@ +addField('content_title', Text::class, __('Titre')); + + $this->addField('content_type', SelectFromArray::class, __('Type'), [ + 'options' => [ + 'FB' => 'FB - ' . __('Fluidbook'), + 'IN' => 'IN - ' . __('Infographie'), + 'AN' => 'AN - ' . __('Animation'), + 'Ti5' => 'Ti5 - ' . __('Video'), + 'QZ' => 'QZ - ' . __('Quiz'), + 'PD' => 'PD - ' . __('Podcast'), + 'FC' => 'FC - ' . __('Flipcards'), + ] + ]); + + $this->addField('fb_id', SelectFromArray::class, __('Fluidbook'), ['when' => ['content_type' => 'FB']]); + $this->addField('media_id', SelectFromArray::class, __('Media'), ['when' => ['content_type' => ['PD', 'AN', 'Ti5']]]); + $this->addField('quiz_id', SelectFromArray::class, __('Quiz'), ['when' => ['content_type' => 'QZ']]); + $this->addField('content_file', Files::class, __('Charger un fichier'), ['when' => ['content_type' => ['IN', 'FC']]]); + $this->addField('media_file', Files::class, __('Charger un media'), ['when' => ['content_type' => ['PD', 'AN', 'Ti5'], 'media_id' => '']]); + } +} diff --git a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php index 984172cc4..ebbf7e5d6 100644 --- a/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php +++ b/resources/views/vendor/backpack/base/inc/sidebar_content.blade.php @@ -14,6 +14,10 @@ @endcan + @can('elearning-package:read') + + @endcan @can('quiztranslation:read')