<select />
</component>
<component name="ChangeListManager">
- <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041">
+ <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041 @1">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/app/Models/ELearningMedia.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/ELearningMedia.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Models/ELearningPackage.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/ELearningPackage.php" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/resources/elearningpackage/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningpackage/js/app.js" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/resources/views/elearningmedia/index.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/elearningmedia/index.blade.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/app/SubForms/ElearningPackageContent.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/SubForms/ElearningPackageContent.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<workItem from="1644394645639" duration="13635000" />
<workItem from="1644425348765" duration="2270000" />
<workItem from="1644508187200" duration="10853000" />
- <workItem from="1644582031422" duration="1260000" />
- </task>
- <task id="LOCAL-00191" summary="wip #3753 @2">
- <created>1636044131486</created>
- <option name="number" value="00191" />
- <option name="presentableId" value="LOCAL-00191" />
- <option name="project" value="LOCAL" />
- <updated>1636044131486</updated>
+ <workItem from="1644582031422" duration="5202000" />
</task>
<task id="LOCAL-00192" summary="wait #3753 @1">
<created>1636053838335</created>
<option name="project" value="LOCAL" />
<updated>1644578457525</updated>
</task>
- <option name="localTasksCounter" value="240" />
+ <task id="LOCAL-00240" summary="wip #5041 @1">
+ <created>1644583408821</created>
+ <option name="number" value="00240" />
+ <option name="presentableId" value="LOCAL-00240" />
+ <option name="project" value="LOCAL" />
+ <updated>1644583408821</updated>
+ </task>
+ <option name="localTasksCounter" value="241" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<MESSAGE value="wip #5045 @0.75" />
<MESSAGE value="wip #5045 @1.1" />
<MESSAGE value="wait #5045 @0.5" />
- <MESSAGE value="wip #5041 @1" />
<MESSAGE value="wip #5041 @3" />
<MESSAGE value="wip #5041 @1.5" />
<MESSAGE value="wip #5041" />
- <option name="LAST_COMMIT_MESSAGE" value="wip #5041" />
+ <MESSAGE value="wip #5041 @1" />
+ <option name="LAST_COMMIT_MESSAGE" value="wip #5041 @1" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
use Cubist\Scorm\Manifest;
use Cubist\Util\Files\Files;
use Cubist\Util\Files\VirtualDirectory;
+use Cubist\Util\Zip;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class ELearningPackage extends ToolboxModel
$modules = [];
foreach ($this->contents as $id => $content) {
- $modules[] = $this->_compileModule($id, $content, $vdir);
+ $m = $this->_compileModule($id, $content, $vdir);
+ if ($m !== false) {
+ $modules[] = $m;
+ }
}
$data = ['title' => $this->title, 'description' => $this->description, 'modules' => $modules];
switch ($res['type']) {
case 'FB':
- $title = $this->_compileFluidbook($c['fb_id'], $vdir, $basePath);
+ $moduleTitle = $this->_compileFluidbook($c['fb_id'], $vdir, $basePath);
break;
case 'QZ':
- $title = $this->_compileQuiz($c['quiz_id'], $vdir, $basePath);
+ $moduleTitle = $this->_compileQuiz($c['quiz_id'], $vdir, $basePath);
break;
case 'PD':
- $title = $this->_compileMedia($c['audio_id'], $c['audio_file'], $vdir, $basePath);
+ $moduleTitle = $this->_compileMedia($c['audio_id'], $c['audio_file'], $vdir, $basePath);
break;
case 'Ti5':
case 'AN':
- $title = $this->_compileMedia($c['video_id'], $c['video_file'], $vdir, $basePath);
+ $moduleTitle = $this->_compileMedia($c['video_id'], $c['video_file'], $vdir, $basePath);
break;
case 'IN':
- $title = $this->_compilePDF($c['infographic_file'], $vdir, $basePath);
+ $moduleTitle = $this->_compilePDF($c['infographic_file'], $vdir, $basePath);
break;
case 'FC':
default:
- $title = $this->_compileZip($c['content_file'], $vdir, $basePath);
+ $moduleTitle = $this->_compileZip($c['content_file'], $vdir, $basePath);
break;
}
+ if (null === $moduleTitle) {
+ return false;
+ }
if (!$res['title']) {
- $res['title'] = $title;
+ $res['title'] = $moduleTitle;
}
return $res;
$vdir->addTemp($tmp);
$quiz = Quiz::find($id);
+ if (null === $quiz) {
+ return null;
+ }
$quiz->compile($tmp);
$vdir->copyDirectory($tmp, $basePath);
$owner = User::withoutGlobalScopes()->findOrFail($this->owner);
$organization = $owner->companyName;
- $file = $this->getMediaByCollection($media_file)->first()->getPath();
+ $f = $this->getMediaByCollection($media_file)->first();
+ if (null === $f) {
+ return null;
+ }
+ $file = $f->getPath();
return ELearningMedia::compileFromFile($file, $tmp, '', $organization, 'MEDIA_' . $media_file);
}
$vdir->addTemp($tmp);
$media = ELearningMedia::find($id);
+ if (null === $media) {
+ return null;
+ }
$media->compile($tmp);
$vdir->copyDirectory($tmp, $basePath);
protected function _compilePDF($collection, $vdir, $basePath)
{
-
+ $f = $this->getMediaByCollection($collection)->first();
+ if (null === $f) {
+ return null;
+ }
+ $spf = new \SplFileInfo($f->getPath());
+ $vdir->copy($spf->getPathname(), $basePath . '/infographic.pdf');
+ return $spf->getBasename('.' . $spf->getExtension());
}
protected function _compileZip($collection, $vdir, $basePath)
{
+ $tmp = Files::tmpdir();
+ $vdir->addTemp($tmp);
+
+ $f=$this->getMediaByCollection($collection)->first();
+ if(null===$f){
+ return null;
+ }
+ $spf = new \SplFileInfo($f->getPath());
+ Zip::extract($spf->getPathname(), $tmp);
+ $vdir->copyDirectory($tmp, $basePath);
+ return $spf->getBasename('.' . $spf->getExtension());
}
}
$this->addField('infographic_file', Files::class, __('Charger une infographie'), ['when' => ['content_type' => ['IN']], 'acceptedFiles' => ['application/pdf']]);
- $this->addField('content_file', Files::class, __('Charger un contnue'), ['when' => ['content_type' => ['FC']], 'acceptedFiles' => ['application/zip']]);
+ $this->addField('content_file', Files::class, __('Charger un contenu'), ['when' => ['content_type' => ['FC']], 'acceptedFiles' => ['application/zip']]);
$this->addField('mandatory', Checkbox::class, __('Obligatoire'), ['default' => true]);
$this->addField('content_title', Text::class, __('Titre'), ['hint' => __('Laisser vide pour utiliser le titre par défaut')]);