<select />
</component>
<component name="ChangeListManager">
- <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5093 @3">
+ <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5041 @0.25">
+ <change afterPath="$PROJECT_DIR$/app/Fields/ElearningMediaPdfID.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/resources/elearningpackage/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningpackage/index.html" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/resources/elearningpackage/sass/app.sass" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningpackage/sass/app.sass" 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$/app/SubForms/ElearningPackageContent.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/SubForms/ElearningPackageContent.php" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/resources/elearningmedia/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningmedia/js/app.js" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/resources/elearningmedia/sass/app.sass" beforeDir="false" afterPath="$PROJECT_DIR$/resources/elearningmedia/sass/app.sass" 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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<property name="add_unversioned_files" value="$PROJECT_DIR$/vendor/backpack/crud/src/resources/views/crud/buttons/bulk_clone.blade.php H:/Works/FluidbookToolbox/vendor/backpack/crud/src/app/Http/Controllers/Auth/ResetPasswordController.php C:/Users/vince/Works/FluidbookToolbox/vendor/cubist/cms-back/src/app/Middleware/BackLocaleSelector.php D:/Works/FluidbookToolbox/vendor/laravel-lang/lang/locales/fr/fr.json D:/Works/FluidbookToolbox/.env" />
<property name="android.sdk.path" value="$PROJECT_DIR$/../../AndroidSDK" />
<property name="aspect.path.notification.shown" value="true" />
- <property name="last_opened_file_path" value="$PROJECT_DIR$/resources/pdfjs" />
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/app/Fields" />
<property name="list.type.of.created.stylesheet" value="Less" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
+ <recent name="D:\Works\FluidbookToolbox\app\Fields" />
<recent name="D:\Works\FluidbookToolbox\resources\pdfjs" />
<recent name="D:\Works\FluidbookToolbox\resources\views\vendor\backpack\crud\buttons" />
<recent name="D:\Works\FluidbookToolbox\app\Http\Controllers\Admin\Operations" />
<recent name="D:\Works\FluidbookToolbox\resources\elearningpackage\js" />
- <recent name="D:\Works\FluidbookToolbox\resources\elearningpackage\sass" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\Works\FluidbookToolbox\resources\elearningpackage" />
<workItem from="1644851528057" duration="636000" />
<workItem from="1644852994411" duration="9344000" />
<workItem from="1644907547410" duration="24512000" />
- <workItem from="1644946789585" duration="233000" />
- </task>
- <task id="LOCAL-00201" summary="wip #4891 @0.5">
- <created>1637249592707</created>
- <option name="number" value="00201" />
- <option name="presentableId" value="LOCAL-00201" />
- <option name="project" value="LOCAL" />
- <updated>1637249592707</updated>
+ <workItem from="1644946789585" duration="461000" />
+ <workItem from="1645000080912" duration="13000" />
+ <workItem from="1645010493117" duration="868000" />
+ <workItem from="1645090369550" duration="6000" />
+ <workItem from="1645197416166" duration="5109000" />
</task>
<task id="LOCAL-00202" summary="wip #4891 @1">
<created>1637315966593</created>
<option name="project" value="LOCAL" />
<updated>1644934041814</updated>
</task>
- <option name="localTasksCounter" value="250" />
+ <task id="LOCAL-00250" summary="wip #5041 @0.25">
+ <created>1644947063162</created>
+ <option name="number" value="00250" />
+ <option name="presentableId" value="LOCAL-00250" />
+ <option name="project" value="LOCAL" />
+ <updated>1644947063163</updated>
+ </task>
+ <option name="localTasksCounter" value="251" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<MESSAGE value="wip #5041" />
<MESSAGE value="wip #5041 @1.5" />
<MESSAGE value="wip #5041 @0.5" />
- <MESSAGE value="wip #5041 @0.25" />
<MESSAGE value="wip #5041 @1" />
<MESSAGE value="wip #5093 @2" />
<MESSAGE value="wip #5093 @0.25" />
<MESSAGE value="wip #5093 @3" />
- <option name="LAST_COMMIT_MESSAGE" value="wip #5093 @3" />
+ <MESSAGE value="wip #5041 @0.25" />
+ <option name="LAST_COMMIT_MESSAGE" value="wip #5041 @0.25" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
--- /dev/null
+<?php
+
+namespace App\Fields;
+
+use App\Models\ELearningMedia;
+use Cubist\Backpack\Magic\Fields\SelectFromModel;
+
+class ElearningMediaPdfID extends ElearningMediaID
+{
+ protected $_allows_null = true;
+
+ public function _postSetAttributes()
+ {
+ parent::_postSetAttributes();
+ $this->setAttribute('optionsmodel_scope', 'pdf');
+ }
+
+}
protected static $_permissionBase = 'elearning-media';
- public const MEDIA_TYPES = ['audio/mpeg', 'video/mp4'];
+ public const MEDIA_TYPES = ['audio/mpeg', 'video/mp4', 'application/pdf'];
protected $_operations = [ImportOperation::class, PreviewOperation::class, DownloadOperation::class];
{
$file = $this->getMediaInField('file')->first();
$spl = new \SplFileInfo($file->getPath());
- $ext = mb_strtolower($spl->getExtension());
- $this->setAttribute('type', $ext === 'mp3' ? 'audio' : 'video');
+
+ $this->setAttribute('type', self::getType($spl->getExtension()));
return parent::preSave();
}
+ public static function getType($ext)
+ {
+ $exts = ['mp3' => 'audio', 'mp4' => 'video', 'pdf' => 'pdf'];
+ $ext = mb_strtolower($ext);
+ if (isset($exts[$ext])) {
+ return $exts[$ext];
+ }
+ }
+
public function getFinalPath()
{
return protected_path('elearningmedia/final/' . $this->id);
$title = $spl->getBasename('.' . $spl->getExtension());
}
+ $type = self::getType($ext);
+
$vdir = new VirtualDirectory($dest);
$vdir->file_put_contents('imsmanifest.xml', new Manifest($title, Manifest::SCORM_2004, $organization, $reference));
$vdir->copyDirectory(resource_path('elearningmedia/dist/css'), 'css');
$vdir->copyDirectory(resource_path('elearningmedia/dist/js'), 'js');
+ if ($type === 'pdf') {
+ $vdir->copyDirectory(resource_path('pdfjs'), 'pdfjs');
+ $css = file_get_contents(resource_path('pdfjs/web/viewer.css'));
+ $css .= 'body{--sidebar-width:400px;}';
+ $css .= '.article #sidebarContainer, .article .toolbar {display:none !important;}';
+ $css .= '.article .pdfViewer{padding:0 !important;}';
+ $css .= '.article #viewerContainer{top:0 !important;overflow:visible !important;}';
+ $css .= '.article{--page-border:0;--page-margin:0;--body-bg-color:transparent;}';
+ $css .= '.openFile,.rotateCw,.rotateCcw,.rotateCcw + .horizontalToolbarSeparator{display:none !important;}';
+ $css .= '.bookmark,.print,.download{display:none !important}';
+ $css .= '#viewLayers,#viewAttachments{display:none !important}';
+ $css .= '#documentProperties,#cursorSelectTool,#cursorHandTool,#cursorHandTool + .horizontalToolbarSeparator,.horizontalToolbarSeparator.spreadModeButtons{display:none !important}';
+ $popup = '.annotationLayer .popupAnnotation .popupWrapper .popup';
+ $css .= $popup . ' h1,' . $popup . ' span{display:none !important;}';
+ $css .= $popup . ' p{border:0 !important;margin-top:0 !important;}';
+ $vdir->file_put_contents('pdfjs/web/viewer.css', $css);
+ }
$vdir->copy($file, 'media.' . $ext);
- $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct, 'title' => $title, 'type' => $ext === 'mp3' ? 'audio' : 'video']));
+ $vdir->file_put_contents('index.html', view('elearningmedia.index', ['complete_pct' => $complete_pct, 'title' => $title, 'type' => $type]));
$vdir->sync(true);
return $title;
}
return $this->id . ' - ' . $this->title;
}
+ public function scopePDF($query)
+ {
+ $query->where('type', 'pdf');
+ }
+
public function scopeAudio($query)
{
$query->where('type', 'audio');
$vdir->copyDirectory(resource_path('elearningpackage/dist/css'), 'css');
$vdir->copyDirectory(resource_path('elearningpackage/dist/js'), 'js');
$vdir->copyDirectory(resource_path('elearningpackage/dist/fonts'), 'fonts');
- $vdir->copyDirectory(resource_path('pdfjs'), 'js/libs/pdfjs');
$vdir->copy(resource_path('elearningpackage/index.html'), 'index.html');
$vdir->sync(true);
}
$moduleTitle = $this->_compileMedia($c['video_id'], $c['video_file'], $vdir, $basePath);
break;
case 'IN':
- $moduleTitle = $this->_compilePDF($c['infographic_file'], $vdir, $basePath);
- $res['path'] = $basePath . '/infographic.pdf';
- $res['scorm'] = false;
+ $moduleTitle = $this->_compileMedia($c['pdf_id'], $c['infographic_file'], $vdir, $basePath);
break;
case 'FC':
default:
namespace App\SubForms;
use App\Fields\ElearningMediaAudioID;
+use App\Fields\ElearningMediaPdfID;
use App\Fields\ElearningMediaVideoID;
use App\Fields\FluidbookID;
use App\Fields\QuizID;
$this->addField('quiz_id', QuizID::class, __('Quiz'), ['when' => ['content_type' => 'QZ']]);
+ $this->addField('pdf_id', ElearningMediaPdfID::class, __('PDF'), ['when' => ['content_type' => 'IN']]);
$this->addField('infographic_file', Files::class, __('Charger une infographie'), ['when' => ['content_type' => ['IN']], 'acceptedFiles' => ['application/pdf']]);
$this->addField('content_file', Files::class, __('Charger un contenu'), ['when' => ['content_type' => ['FC']], 'acceptedFiles' => ['.zip']]);
SCORM.set('cmi.completion_status', 'incomplete');
}
- var pc = (parseInt(progressComplete) / 100);
- var interval = setInterval(function () {
- if (player.duration > 0 && player.currentTime > (player.duration * pc)) {
- SCORM.set('cmi.completion_status', 'completed');
- SCORM.set('cmi.success_status', 'passed');
- SCORM.save();
- clearInterval(interval);
- }
- }, 1000);
+ var pc = (parseInt(window.progressComplete) / 100);
+ var interval;
+ if (window.type === 'audio' || window.type === 'video') {
+ interval = setInterval(function () {
+ if (player.duration > 0 && player.currentTime >= (player.duration * pc)) {
+ markComplete(interval);
+ }
+ }, 1000);
+ } else if (window.type === 'pdf') {
+ var interval = setInterval(function () {
+ try {
+ var pdfViewer = document.getElementById('player').contentWindow.PDFViewerApplication.pdfViewer;
+ var total = pdfViewer.pagesCount;
+ var current = pdfViewer._currentPageNumber;
+ if (total > 0 && current / total >= pc) {
+ markComplete(interval);
+ }
+ } catch (e) {
+
+ }
+ },1000);
+ }
player.on('ready', function () {
player.play();
});
});
+function markComplete(interval) {
+ SCORM.set('cmi.completion_status', 'completed');
+ SCORM.set('cmi.success_status', 'passed');
+ SCORM.save();
+ clearInterval(interval);
+}
+
function setSessionTime() {
var endTime = Date.now();
SCORM.set('cmi.session_time', scormSecondsToTimeInterval((endTime.getTime() - window.openTime.getTime()) / 1000));
font-family: Arial, Helvetica, sans-serif
background-color: #0E2231
-video, audio
+video, audio, iframe
width: 100%
height: 100%
<meta charset="UTF-8">
<link href="css/app.css" rel="stylesheet">
<title>{{$title}}</title>
+ <script>
+ var type = '{{$type}}';
+ var progressComplete = {{$complete_pct}};
+ </script>
</head>
<body>
-@if($type==='audio')
- <button type="button" id="audiobigplay" class="plyr__control plyr__control--overlaid" data-plyr="play" aria-label="Play"><svg aria-hidden="true" focusable="false"><use xlink:href="#plyr-play"></use></svg><span class="plyr__sr-only">Play</span></button>
+@if($type==='pdf')
+ <iframe id="player" frameborder="0" src="pdfjs/web/viewer.html?file=../../media.pdf#page=1"></iframe>
+@elseif($type==='audio')
+ <button type="button" id="audiobigplay" class="plyr__control plyr__control--overlaid" data-plyr="play"
+ aria-label="Play">
+ <svg aria-hidden="true" focusable="false">
+ <use xlink:href="#plyr-play"></use>
+ </svg>
+ <span class="plyr__sr-only">Play</span></button>
<svg id="spectrum"></svg>
<audio id="player" controls>
<source src="media.mp3" type="audio/mp3"/>
<source src="media.mp4" type="video/mp4"/>
</video>
@endif
-<script>var progressComplete = {{$complete_pct}};</script>
<script src="js/app.js"></script>
</body>
</html>