]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5754 @2.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 14 Mar 2023 14:51:18 +0000 (15:51 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 14 Mar 2023 14:51:18 +0000 (15:51 +0100)
app/Fields/SCORMVersion.php
app/Fluidbook/Packager/Download.php
app/Fluidbook/Packager/Packager.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php
app/Models/Traits/PublicationSettings.php
resources/views/columns/owner.blade.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/download.blade.php

index 70930aff4a511a5bef4c64292f3697d69cb83cd3..3d272edaef49e47038ce31c14dfad4f48deb6b82 100644 (file)
@@ -11,6 +11,11 @@ class SCORMVersion extends SelectFromArray
     protected $_default = Version::SCORM_1_2;
 
     public function getOptions()
+    {
+        return static::getSCORMVersions();
+    }
+
+    public static function getSCORMVersions()
     {
         return [
             Version::SCORM_1_2 => 'SCORM 1.2',
index 6c4e0da38845e043b27d29d360689c5e643fb70f..281418ddfa94e5d416ffcb71720571d0bd142b44 100644 (file)
@@ -22,9 +22,12 @@ class Download extends DownloadBase
     // __('Fluidbook ":title" (#:nb) installé sur :server')
     protected $_installSubject = 'Fluidbook ":title" (#:nb) installé sur :server';
 
-    public function __construct($entry, $version, $action, $user)
+    protected $_params = [];
+
+    public function __construct($entry, $version, $action, $user, $params = [])
     {
         parent::__construct($entry, $action, $user);
+        $this->_params = $params;
         $this->setVersion($version);
     }
 
@@ -126,7 +129,7 @@ class Download extends DownloadBase
 
     protected function _compileandpackage($zip = true)
     {
-        $packager = Packager::package($this->entry->id, $this->version, $zip);
+        $packager = Packager::package($this->entry->id, $this->version, $zip, true, $this->_params);
         $packager->makePackage($zip);
         $url = $packager->getFinalURL();
         if ($url) {
index e8bfd1b933ab1434d27aaf47494ef05a83b1c344..7fc495d57ab8768a3a1527a4f05af17b5d768c79 100644 (file)
@@ -60,7 +60,7 @@ class Packager extends \App\Jobs\Base
                 $packager = new Online($book_id, null, $options);
                 break;
             case 'scorm':
-                $packager = new SCORM($book_id, null, $options);
+                $packager = new Scorm($book_id, null, $options);
                 break;
             case 'sharepoint':
                 $packager = new Sharepoint($book_id, null, $options);
index dbf6d70ecc2307fc2f7c6857ab54e20074b9a842..190c89579998a091ded47631ab4500cd88e600c0 100644 (file)
@@ -8,6 +8,7 @@ use App\Models\FluidbookPublication;
 use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
 use Illuminate\Support\Facades\Route;
 use Prologue\Alerts\Facades\Alert;
+
 // __('!!Paramètres des fluidbooks')
 trait DownloadOperation
 {
@@ -15,6 +16,7 @@ trait DownloadOperation
     {
         Route::match(['get'], $segment . '/{id}/delivery', $controller . '@delivery');
         Route::match(['get'], $segment . '/{id}/package/{action}/{version}', $controller . '@package');
+        Route::match(['get'], $segment . '/{id}/package/{action}/scorm/{scormversion}', $controller . '@packageScorm');
         Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);;
     }
 
@@ -67,4 +69,18 @@ trait DownloadOperation
         Alert::add('success', __('La compilation a été placée en file d\'attente. Vous recevrez un email lorsqu\'elle sera terminée.'))->flash();
         return redirect(backpack_url('fluidbook-publication'));
     }
+
+    protected function packageScorm($id, $action, $scormVersion)
+    {
+        if (!FluidbookPublication::hasPermission($id)) {
+            abort(401, __('Cette publication ne peut pas être téléchargée'));
+        }
+        $fluidbook = FluidbookPublication::find($id);
+        if (!$fluidbook->scorm_enabled && !can('fluidbook-publication:download:all-versions')) {
+            abort(401, __('Cette version n\'est pas disponible au téléchargement'));
+        }
+        Download::dispatch($fluidbook, 'scorm', $action, backpack_user(), ['scorm_version' => $scormVersion])->onQueue('download');
+        Alert::add('success', __('La compilation a été placée en file d\'attente. Vous recevrez un email lorsqu\'elle sera terminée.'))->flash();
+        return redirect(backpack_url('fluidbook-publication'));
+    }
 }
index 44908440fe2b8c589f39a17b36b8376543fddd48..126b067373bfbe29cf7585dfae2557f3f22ecf70 100644 (file)
@@ -2977,11 +2977,6 @@ trait PublicationSettings
             'fake' => true,
             'store_in' => 'settings',
             'translatable' => false,
-            'column' => true,
-            'column_label' => '<i class="las la-chalkboard-teacher" title="' . __('Version SCORM') . '"></i>',
-            'column_type' => 'model_function',
-            'column_view_namespace' => 'crud::columns',
-            'column_function_name' => 'getSCORMVersion',
         ]);
         $this->addField('scorm_id', LongText::class, $this->__('Identifiant SCORM'), [
             'v2' => '{"type":"text","default":"","editable":true,"label":"\\u00a7!\\u00a7Identifiant SCORM!\\u00a7!","grade":5}',
index 2f35f711c3d290eb3a6a197531bd541cd82394b9..47cbc46d56f57c2cdca3f1ddd189eea276da827f 100644 (file)
@@ -6,7 +6,8 @@
 
 
 @if(!isset($crud->seenOwnersList))
-    @php     $crud->seenOwnersList=true;
+    @php
+        $crud->seenOwnersList=true;
         $crud->ajaxOwnerList=\Cubist\Backpack\Magic\Fields\SelectFromArray::hashOptions($column['options']);
     @endphp
     <style>
@@ -67,5 +68,5 @@
             <option value="{{$values}}" selected>{!! $v !!}</option>
         </select>
     </div>
-    <a href="#" class="changeowner" title="{{__('Changer le propriétaire')}}">{!! $v !!}</a>
+    <a href="#" class="changeowner" title="{{__('Modifier le propriétaire')}}">{!! $v !!}</a>
 </span>
index 5d763be8ff33f5eec9fde38c7d6996655fb232ca..c7f37fbebe76ee5ad23f450ce1e0aa40d8600adc 100644 (file)
                 'url'=>$base.'/delivery',
                 ],
         ];
+    $actions['sep_download']='---------';
     foreach (\App\Models\FluidbookPublication::getDownloadVersions() as $k=>$v) {
-        $actions['sep_download']='---------';
+        if($k==='scorm'){
+            continue;
+        }
         if($entry->{'download_'.$k}){
             $actions['download_'.$k]=[
                 'label'=>$v['label'],
                 ];
         }
     }
+    if($entry->scorm_enable){
+        $actions['sep_scorm']='---------';
+        foreach (\App\Fields\SCORMVersion::getSCORMVersions() as $k=>$v) {
+                $actions['download_scorm_'.$k]=[
+                'label'=>__('Version :version',['version'=>$v]),
+                'url'=>$basePackage.'/download/scorm/'.$k
+                ];
+        }
+    }
     if(can('fluibook-publication:download:install-hosting') && ($entry->install_online || $entry->scorm_enable)){
-
         $installActions['sep_install']='---------';
         if($entry->install_online && $entry->install_online->server && isset($servers[$entry->install_online->server])){
-
             $server=$servers[$entry->install_online->server];
             if($entry->install_online->path || $server['allows_root']){
                 $installActions['install_online']=[
@@ -37,7 +47,7 @@
 
         if($entry->scorm_enable){
             $installActions['scormcloud']=['label'=>__('Tester sur SCORM Cloud'),
-            'url'=> $basePackage.'/scormcloud/scorm'
+                'url'=> $basePackage.'/scormcloud/scorm'
             ];
         }
         if(count($installActions)>1){