]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6186 @2.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 22 Sep 2023 06:29:40 +0000 (08:29 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 22 Sep 2023 06:29:40 +0000 (08:29 +0200)
44 files changed:
app/Console/Commands/Base/ToolboxCommand.php [new file with mode: 0644]
app/Console/Commands/ElearningMediaDownload.php [new file with mode: 0644]
app/Console/Commands/ElearningPackageDownload.php [new file with mode: 0644]
app/Console/Commands/FluidbookCollection.php
app/Console/Commands/FluidbookCompile.php
app/Console/Commands/FluidbookDocumentProcess.php
app/Console/Commands/FluidbookFarmPing.php
app/Console/Commands/FluidbookGeneratePreview.php
app/Console/Commands/FluidbookLinksFromPDF.php
app/Console/Commands/FluidbookLoadbalancerPing.php
app/Console/Commands/FluidbookPackage.php
app/Console/Commands/FluidbookPreprocessImages.php
app/Console/Commands/FluidbookPullSources.php
app/Console/Commands/FluidbookQuote.php
app/Console/Commands/FluidbookSocialImage.php
app/Console/Commands/FluidbookThemePreview.php
app/Console/Commands/QuizDownload.php [new file with mode: 0644]
app/Console/Commands/QuizLogReplay.php [deleted file]
app/Console/Commands/QuizPullSources.php
app/Console/Commands/ToolboxPrecache.php
app/Console/Commands/ToolboxToWorkshop.php
app/Console/Commands/ToolboxTranslations.php [deleted file]
app/Console/Commands/UpdateNWJS.php
app/Console/Commands/UpdatePDFJSLibrary.php
app/Console/Commands/WorkshopMigration.php
app/Elearning/QuizCompiler.php
app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php [new file with mode: 0644]
app/Http/Controllers/Admin/Operations/ELearningMedia/DownloadOperation.php
app/Http/Controllers/Admin/Operations/ELearningPackage/DownloadOperation.php
app/Http/Controllers/Admin/Operations/Quiz/DownloadOperation.php
app/Jobs/Base.php
app/Jobs/DownloadBase.php
app/Jobs/ElearningMediaDownload.php
app/Jobs/ElearningPackageDownload.php
app/Jobs/FluidbookDocumentUpload.php
app/Jobs/QuizDownload.php
app/Jobs/ScormDownloadBase.php [new file with mode: 0644]
app/Models/Base/ToolboxDownloadable.php [new file with mode: 0644]
app/Models/ELearningMedia.php
app/Models/ELearningPackage.php
app/Models/FluidbookCollection.php
app/Models/FluidbookPublication.php
app/Models/Quiz.php
app/Notifications/ToolboxNotification.php

diff --git a/app/Console/Commands/Base/ToolboxCommand.php b/app/Console/Commands/Base/ToolboxCommand.php
new file mode 100644 (file)
index 0000000..85524cf
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Console\Commands\Base;
+
+use App\Models\User;
+use Cubist\Backpack\Console\Commands\CubistCommand;
+
+class ToolboxCommand extends CubistCommand
+{
+    protected $signature = 'toolbox';
+    protected $description = 'Base command for Toolbox';
+
+    protected function getUser($id = 5)
+    {
+        return User::withoutGlobalScope('ownerclause')->findOrFail($id);
+    }
+}
diff --git a/app/Console/Commands/ElearningMediaDownload.php b/app/Console/Commands/ElearningMediaDownload.php
new file mode 100644 (file)
index 0000000..60289f2
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\ELearningMedia;
+
+class ElearningMediaDownload extends ToolboxCommand
+{
+    protected $signature = 'elearningmedia:download {id} {--action=download} {--scormversion=default}';
+    protected $description = 'Compile a Elearning Media';
+
+    public function handle()
+    {
+        $instance = ELearningMedia::withoutGlobalScopes()->find($this->argument('id'));
+        $scormVersion = $this->option('scormversion') !== 'default' ? $this->option('scormversion') : null;
+        (new \App\Jobs\ElearningMediaDownload($instance, $this->option('action'), $scormVersion, $this->getUser()))->handle();
+    }
+}
diff --git a/app/Console/Commands/ElearningPackageDownload.php b/app/Console/Commands/ElearningPackageDownload.php
new file mode 100644 (file)
index 0000000..9f3954e
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\ELearningPackage;
+
+class ElearningPackageDownload extends ToolboxCommand
+{
+    protected $signature = 'elearningpackage:download {id} {--action=download} {--scormversion=default}';
+    protected $description = 'Compile a Elearning package';
+
+    public function handle()
+    {
+        $instance = ELearningPackage::withoutGlobalScopes()->find($this->argument('id'));
+        $scormVersion = $this->option('scormversion') !== 'default' ? $this->option('scormversion') : null;
+        (new \App\Jobs\ElearningPackageDownload($instance, $this->option('action'), $scormVersion, $this->getUser()))->handle();
+    }
+}
index ce8aa4d0aa5a16b193afd83eb3c63b6aa705b06b..46a5e7cfc1319f278e3f9db9d8c490e9711a71e9 100644 (file)
@@ -2,13 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Jobs\FluidbookCollectionDownload;
-
-use App\Models\User;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\PHP;
 
-class FluidbookCollection extends CubistCommand
+class FluidbookCollection extends ToolboxCommand
 {
     protected $signature = 'fluidbook:collection {id} {action}';
     protected $description = 'Compile a fluidbook';
@@ -20,7 +18,7 @@ class FluidbookCollection extends CubistCommand
     {
         PHP::neverStop(true);
         $collection = \App\Models\FluidbookCollection::find($this->argument('id'));
-        $job = new FluidbookCollectionDownload($collection, $this->argument('action'), User::withoutGlobalScope('ownerclause')->findOrFail(5));
+        $job = new FluidbookCollectionDownload($collection, $this->argument('action'), $this->getUser());
         $job->handle();
     }
 }
index a52dc5b7f56e8998699506323c1b12e91d3ffdb6..ce2e16e4452bc592ae50e6430410882f15cbf9f6 100644 (file)
@@ -2,13 +2,14 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Fluidbook\Compiler\Compiler;
 use App\Models\FluidbookPublication;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\PHP;
 
-class FluidbookCompile extends CubistCommand
+class FluidbookCompile extends ToolboxCommand
 {
+
     protected $signature = 'fluidbook:compile {id}';
     protected $description = 'Compile a fluidbook';
 
index 009457e7af7ed220ed3e2a60aa7a9e50d363cfbd..a618e250f5484c76912e2c2f2503df51e7df62f0 100644 (file)
@@ -2,15 +2,15 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Jobs\FluidbookDocumentUpload;
 use App\Models\FluidbookDocument;
 use App\Models\User;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\PHP;
 use Cubist\Util\Str;
 use Illuminate\Support\Facades\Log;
 
-class FluidbookDocumentProcess extends CubistCommand
+class FluidbookDocumentProcess extends ToolboxCommand
 {
     protected $signature = 'fluidbook:document:process {id}';
     protected $description = 'Reprocess a fluidbook document';
index d7ef3c62bd13d8b4bff4c6778c7aa07b1963361e..95992f9cd10cb014b290a298a2173bdd08994779 100644 (file)
@@ -3,11 +3,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Fluidbook\Farm;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 
 
-class FluidbookFarmPing extends CubistCommand
+class FluidbookFarmPing extends ToolboxCommand
 {
     protected $signature = 'fluidbook:farm:ping {--force}';
     protected $description = 'Manage fluidbook farm';
index 1f9ab63e4d22ec0e390d754bf775e012d7ec30a3..7c13af30003fd89da3b624c62900002b5b3cf465 100644 (file)
@@ -2,12 +2,10 @@
 
 namespace App\Console\Commands;
 
-use App\Jobs\GenerateDeliveryThumbnailsPreview;
-use Illuminate\Console\Command;
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Models\FluidbookPublication;
-use Illuminate\Support\Facades\Bus;
 
-class FluidbookGeneratePreview extends Command
+class FluidbookGeneratePreview extends ToolboxCommand
 {
     /**
      * The name and signature of the console command.
index 61767997a41bdbfe283d9549341c2e97f039b889..3f3270a4b799435a05e3b9431444573d3dee9d77 100644 (file)
@@ -2,10 +2,10 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Fluidbook\Link\LinksData;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 
-class FluidbookLinksFromPDF extends CubistCommand
+class FluidbookLinksFromPDF extends ToolboxCommand
 {
     protected $signature = 'fluidbook:links:importfrompdf  {id}';
     protected $description = 'Import links from PDF';
index 452b4d2e49d99c8c7a19ef774b328ce910d2297f..27acb4f174e9b56355dc4dcb52ada6ceed43e5f2 100644 (file)
@@ -3,12 +3,11 @@
 
 namespace App\Console\Commands;
 
-use App\Fluidbook\Farm;
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Fluidbook\HostingLoadBalancer;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 
 
-class FluidbookLoadbalancerPing extends CubistCommand
+class FluidbookLoadbalancerPing extends ToolboxCommand
 {
     protected $signature = 'fluidbook:loadbalancer:ping {--force}';
     protected $description = 'Manage fluidbook loadbalancer';
index b8281c1b58766299c7f1e44263af1def11af7099..d1ca4dd8cbe72940c604e197884487420051985a 100644 (file)
@@ -2,12 +2,12 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Fluidbook\Packager\Download;
 use App\Models\FluidbookPublication;
 use App\Models\User;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 
-class FluidbookPackage extends CubistCommand
+class FluidbookPackage extends ToolboxCommand
 {
     protected $signature = 'fluidbook:package {id} {type=online} {action=download} {--zip}';
     protected $description = 'Compile a fluidbook';
@@ -17,7 +17,7 @@ class FluidbookPackage extends CubistCommand
      */
     public function handle()
     {
-        $download = new Download(FluidbookPublication::find($this->argument('id')), $this->argument('type'), $this->argument('action'), User::withoutGlobalScope('ownerclause')->findOrFail(5));
+        $download = new Download(FluidbookPublication::find($this->argument('id')), $this->argument('type'), $this->argument('action'), $this->getUser());
         $download->handle();
     }
 }
index 6edb950da1b0f6a1f0bd149e6d2edcdff6885df6..cd0d48fa84c6ea1f2c42be129f96f37aca290943 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Jobs\FluidbookImagesPreprocess;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\PHP;
 
-class FluidbookPreprocessImages extends CubistCommand
+class FluidbookPreprocessImages extends ToolboxCommand
 {
     protected $signature = 'fluidbook:preprocess {id}';
     protected $description = 'Compile a fluidbook';
index 0e0316c12bee67ab0927e36629d96366aaba9465..bb7882219e5d11b41928a2d7ca06d804dd592ed0 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Models\Traits\FluidbookPlayerBranches;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\PHP;
 
-class FluidbookPullSources extends CubistCommand
+class FluidbookPullSources extends ToolboxCommand
 {
     protected $signature = 'fluidbook:player:updatesources';
     protected $description = 'Update fluidbook player sources from git repos';
index d555f8eddb41fb3fe245048a3fdd3c22e7030abb..4b91008d7b4e3a1011a35d2e77ec9b5034b24ae6 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Slack\Slack;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Backpack\Facades\App;
 
-class FluidbookQuote extends CubistCommand
+class FluidbookQuote extends ToolboxCommand
 {
     protected $signature = 'fluidbook:quote {--reminder}';
     protected $description = 'Fluidbook Quotes';
index b6a6a65decd58b63d902fdfd150d0f6357eb3a7c..d77e5781a863228c20c9de99b1d4c87a2448c264 100644 (file)
@@ -2,12 +2,12 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Models\FluidbookPublication;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\ArrayUtil;
 use Cubist\Util\PHP;
 
-class FluidbookSocialImage extends CubistCommand
+class FluidbookSocialImage extends ToolboxCommand
 {
     protected $signature = 'fluidbook:socialimage {id} {--force}';
     protected $description = 'Generate image for social networks';
index 62a103a51bb204a7631896e09f0fb050695d46d3..85e54e487567eacb63219b21b153b87fb916879f 100644 (file)
@@ -2,13 +2,13 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Jobs\GenerateThemePreview;
 use App\Models\FluidbookTheme;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\ArrayUtil;
 use Illuminate\Database\Query\Builder;
 
-class FluidbookThemePreview extends CubistCommand
+class FluidbookThemePreview extends ToolboxCommand
 {
     protected $signature = 'fluidbook:theme:preview {id?}';
     protected $description = 'Generate a theme preview';
diff --git a/app/Console/Commands/QuizDownload.php b/app/Console/Commands/QuizDownload.php
new file mode 100644 (file)
index 0000000..013c798
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Console\Commands\Base\ToolboxCommand;
+use App\Models\Quiz;
+
+class QuizDownload extends ToolboxCommand
+{
+    protected $signature = 'quiz:download {id} {--action=download} {--scormversion=default}';
+    protected $description = 'Compile a quiz';
+
+    public function handle()
+    {
+        $instance = Quiz::withoutGlobalScopes()->find($this->argument('id'));
+        $scormVersion = $this->option('scormversion') !== 'default' ? $this->option('scormversion') : null;
+        (new \App\Jobs\QuizDownload($instance, $this->option('action'), $scormVersion, $this->getUser()))->handle();
+    }
+}
diff --git a/app/Console/Commands/QuizLogReplay.php b/app/Console/Commands/QuizLogReplay.php
deleted file mode 100644 (file)
index 95f8c55..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-
-namespace App\Console\Commands;
-
-use App\Models\QuizAttempt;
-use Carbon\Carbon;
-use Cubist\Backpack\Console\Commands\CubistCommand;
-use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
-use Illuminate\Support\Facades\Storage;
-use Lucy\Document;
-use Lucy\Parser;
-
-class QuizLogReplay extends CubistCommand
-{
-
-    protected $signature = 'quiz:log:replay';
-    protected $description = 'Replay quiz logs';
-
-    public function handle()
-    {
-        $files = Storage::disk('storage')->files('quizlogs', true);
-        $this->_parseFile('quizlogs/toolbox-audit.log');
-//        foreach ($files as $file) {
-//            $this->_parseFile($file);
-//        }
-    }
-
-    public function _parseFile($file)
-    {
-        $log = new Document(storage_path($file), Parser::class);
-        foreach ($log->getParsers() as $parser) {
-
-            if ($parser->getMethod() !== 'POST') {
-                continue;
-            }
-            if (!preg_match('/^\/quiz\/([0-9]+)\/log$/', $parser->getPath(), $matches)) {
-                continue;
-            }
-            $data = $parser->getPostData();
-            $log = new QuizAttempt();
-            $log->quiz = $matches[1];
-            $log->score = $data['score'];
-            $log->passed = $data['passed'] !== 'false' ? '1' : '0';
-            $log->answers = json_encode($data['questions']);
-            $log->created_at=$parser->getDate()->toDateTimeString();
-            $log->updated_at=$parser->getDate()->toDateTimeString();
-            dd($log);
-            //$log->save();
-        }
-
-    }
-}
index 0cd7d8df90b431644edc03a38d8bd2553f06afd5..e9546ddb20824e1dc4fab98e799c7089fbdd1e57 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Models\Traits\QuizBranches;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Cubist\Util\PHP;
 
-class QuizPullSources extends CubistCommand
+class QuizPullSources extends ToolboxCommand
 {
     protected $signature = 'quiz:player:updatesources';
     protected $description = 'Update quiz player sources from git repos';
index 2d8d663d629ad28ffee95e5078e49b1a70e05afe..4805375afa2735d66f14e8d6659a8336e158ecaa 100644 (file)
@@ -2,13 +2,12 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Fields\FluidbookTTSVoice;
-use App\Fluidbook\Farm;
 use App\Models\FluidbookTranslate;
 use Cubedesigners\UserDatabase\Permissions;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 
-class ToolboxPrecache extends CubistCommand
+class ToolboxPrecache extends ToolboxCommand
 {
     protected $signature = 'toolbox:precache';
     protected $description = 'Precache Toolbox';
index 7c72de9d13d918ed9f11cbe1abd32088817647bd..7fde1dade8e2491ddc82fe76e54163bc46742021 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Models\FluidbookPublication;
-use Cubist\Backpack\Console\Commands\CubistCommand;
 use Illuminate\Support\Facades\DB;
 
-class ToolboxToWorkshop extends CubistCommand
+class ToolboxToWorkshop extends ToolboxCommand
 {
     protected $signature = 'toolboxtows {id} {targetid=new}';
     protected $description = 'Migrate a fluidbook made on the toolbox back to the workshop';
@@ -43,7 +43,5 @@ class ToolboxToWorkshop extends CubistCommand
         } else {
             DB::table(self::$_wstable)->where('book_id', $targetid)->update($data);
         }
-
-        //DB::table(self::$_wstable)->in
     }
 }
diff --git a/app/Console/Commands/ToolboxTranslations.php b/app/Console/Commands/ToolboxTranslations.php
deleted file mode 100644 (file)
index 00dba77..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Models\ToolboxTranslate;
-use App\Models\Traits\FluidbookPlayerBranches;
-use Cubist\Backpack\Console\Commands\CubistCommand;
-use Cubist\Backpack\Facades\App;
-use Cubist\Locale\Translate;
-use Cubist\Util\PHP;
-
-class ToolboxTranslations extends CubistCommand
-{
-    protected $signature = 'translate:toolbox';
-
-
-    use FluidbookPlayerBranches;
-
-    public function handle()
-    {
-        App::setLocale('en');
-
-        dd(ToolboxTranslate::find(1));
-
-        $paths = [];
-        foreach (self::getActiveBranches() as $branch) {
-            $paths['Player - git:' . $branch] = 'resources/fluidbookpublication/player/branches/' . $branch . '/js';
-            $paths['Player - local:' . $branch] = 'resources/fluidbookpublication/player/local/' . $branch . '/js';
-        }
-
-        $t = new Translate();
-        $t->setExtensions(['js']);
-        foreach ($paths as $path) {
-            $t->addPath(base_path() . '/' . $path);
-        }
-        $t->parseFiles();
-        dd($t->getStringToTranslate());
-    }
-}
index d193e03572f974b9b0cd73cd8c097fbdb29377bd..ad8ced8f3ff391244ef9d43469d313153b2ec33b 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
-use Cubist\Backpack\Console\Commands\CubistCommand;
+use App\Console\Commands\Base\ToolboxCommand;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Zip;
 
-class UpdateNWJS extends CubistCommand
+class UpdateNWJS extends ToolboxCommand
 {
     /** @see https://nwjs.io/ */
 
index 3d0d43cfc7ec8b1783e2c7a1f4aef127d4c506f4..7a9ae3468216a5b783626e7a2ac8a42fe1ff48c8 100644 (file)
@@ -2,11 +2,11 @@
 
 namespace App\Console\Commands;
 
-use Cubist\Backpack\Console\Commands\CubistCommand;
+use App\Console\Commands\Base\ToolboxCommand;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Zip;
 
-class UpdatePDFJSLibrary extends CubistCommand
+class UpdatePDFJSLibrary extends ToolboxCommand
 {
     /** @see https://mozilla.github.io/pdf.js/getting_started/#download */
 
index c5e037c5faa4483a87090530ea96b6238d220961..4cfa1f60af047fba247e39170b1c94effe231367 100644 (file)
@@ -3,6 +3,7 @@
 
 namespace App\Console\Commands;
 
+use App\Console\Commands\Base\ToolboxCommand;
 use App\Models\FluidbookDocument;
 use App\Models\FluidbookPublication;
 use App\Models\FluidbookTheme;
@@ -14,20 +15,18 @@ use Cubist\Util\ArrayUtil;
 use Cubist\Util\Json;
 use Cubist\Util\ObjectUtil;
 use Cubist\Util\PHP;
-use Cubist\Util\Text;
 use Illuminate\Contracts\Cache\Lock;
 use Illuminate\Support\Facades\Artisan;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 
-class WorkshopMigration extends CubistCommand
+class WorkshopMigration extends ToolboxCommand
 {
     protected $signature = 'ws:migrate {--publications=v2} {--documents=missing} {--quick} {--force}';
     protected $description = 'Migrate data from Workshop V2';
     protected $_wsRanks = [];
     const OLD_DB = 'extranet_clean';
     protected $_oldRoot = '/home/extranet/www/fluidbook/';
-    protected static $_admin = 5;
 
     /** @var Lock */
     protected Lock $_lock;
index 65e5134d99c31015adc575a897889325dac5bb00..3038adc9e99d931265c814a00910c3420f7ba3f6 100644 (file)
@@ -54,11 +54,16 @@ class QuizCompiler extends Base
     {
         $this->quiz = $quiz instanceof Quiz ? $quiz : Quiz::withoutGlobalScopes()->find($quiz);
         $this->theme = $this->quiz->getTheme();
-        $this->compilePath = protected_path('quiz/compile/' . $this->quiz->id);
+        $this->compilePath = protected_path($this->getBaseURL() . '/compile/' . $this->quiz->id);
         $this->dest = $dest;
         $this->forceScorm = $forceScorm;
     }
 
+    protected function getBaseURL()
+    {
+        return $this->quiz->getOption('name');
+    }
+
     public function handle()
     {
         $compileVdir = new VirtualDirectory($this->compilePath);
diff --git a/app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php b/app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php
new file mode 100644 (file)
index 0000000..9c4d816
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Http\Controllers\Admin\Operations\Base;
+
+// __('!! e-Learning')
+
+use App\Http\Middleware\CheckIfAdmin;
+use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
+use Illuminate\Support\Facades\Route;
+use Prologue\Alerts\Facades\Alert;
+
+trait BaseDownloadOperation
+{
+    protected function setupDownloadRoutes($segment, $routeName, $controller)
+    {
+        Route::match(['get'], $segment . '/{id}/package/{action}/{version?}', $controller . '@package');
+        Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);;
+    }
+
+    protected function setupDownloadDefaults()
+    {
+        $this->crud->addButtonFromView('line', 'download', $this->button . '.download', 'end');
+    }
+
+    protected function package($id, $action, $version = null)
+    {
+        $entry = $this->getModelInstance();
+        $model = get_class($entry);
+        $job = $this->downloadJob;
+
+        if (!$model::hasPermission($id, 'read')) {
+            abort(401);
+        }
+        $instance = $model::withoutGlobalScopes()->find($id);
+        $version = $version ?? $instance->scorm_version;
+        $job::dispatch($instance, $action, $version, backpack_user())->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($entry->getOption('name')));
+    }
+
+    protected function download($id, $hash, $file)
+    {
+        $entry = $this->getModelInstance();
+        $model = get_class($entry);
+
+        $instance = $model::withoutGlobalScopes()->where('id', $id)->where('hash', $hash)->first();
+        if (null === $instance) {
+            abort(404, __('Ce fichier est indisponible'));
+        }
+        $path = protected_path($entry->getOption('name') . '/download/' . $id . '/' . $file);
+        if (!file_exists($path)) {
+            abort(404, __('Le fichier n\'existe pas'));
+        }
+        return XSendFileController::sendfile($path);
+    }
+}
index 296d2f425797dd78e4d54033fa383509bc7b9150..63c76d6a74216353617ddffe76b7e45f7f52a4a3 100644 (file)
@@ -4,58 +4,14 @@ namespace App\Http\Controllers\Admin\Operations\ELearningMedia;
 
 // __('!! e-Learning')
 
-use App\Http\Middleware\CheckIfAdmin;
+use App\Http\Controllers\Admin\Operations\Base\BaseDownloadOperation;
 use App\Jobs\ElearningMediaDownload;
-use App\Jobs\QuizDownload;
-use App\Models\ELearningMedia;
-use App\Models\Quiz;
-use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
-use Illuminate\Support\Facades\Route;
-use Prologue\Alerts\Facades\Alert;
 
 trait DownloadOperation
 {
-    protected function setupDownloadRoutes($segment, $routeName, $controller)
-    {
-        Route::match(['get'], $segment . '/{id}/package/{action}/{version?}', $controller . '@package');
-        Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);;
-    }
 
-    protected function setupDownloadDefaults()
-    {
+    use BaseDownloadOperation;
 
-        $this->crud->addButtonFromView('line', 'download', 'elearningmedia.download', 'end');
-    }
-
-    protected function package($id, $action, $version = null)
-    {
-        if (!ElearningMedia::hasPermission($id, 'read')) {
-            abort(401);
-        }
-        $media = ElearningMedia::withoutGlobalScopes()->find($id);
-        $version = $version ?? $media->scorm_version;
-        ElearningMediaDownload::dispatch($media, $action, $version, backpack_user())->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('elearning-media'));
-    }
-
-    protected function download($id, $hash, $file)
-    {
-        $media = ElearningMedia::withoutGlobalScopes()->where('id', $id)->where('hash', $hash)->first();
-        if (null === $media) {
-            abort(404, __('Ce fichier est indisponible'));
-        }
-        $path = protected_path('elearning-media/download/' . $id . '/' . $file);
-        if (!file_exists($path)) {
-            abort(404, __('Le fichier n\'existe pas'));
-        }
-        return XSendFileController::sendfile($path);
-    }
-
-//    protected function download($id, $action)
-//    {
-//        ElearningMediaDownload::dispatch(ELearningMedia::find($id), $action, backpack_user())->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('elearning-media'));
-//    }
+    protected $button = 'elearningmedia';
+    protected $downloadJob = ElearningMediaDownload::class;
 }
index ab4dca292acd6abacb0aba10aafd23dea3be8213..edbe68a39edbe129db17d9dc1207c86e3564ad4c 100644 (file)
@@ -2,57 +2,15 @@
 
 namespace App\Http\Controllers\Admin\Operations\ELearningPackage;
 
-use App\Http\Middleware\CheckIfAdmin;
+use App\Http\Controllers\Admin\Operations\Base\BaseDownloadOperation;
 use App\Jobs\ElearningPackageDownload;
-use App\Models\ELearningPackage;
-use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
-use Illuminate\Support\Facades\Route;
-use Prologue\Alerts\Facades\Alert;
 
 // __('!! e-Learning')
 
 trait DownloadOperation
 {
-    protected function setupDownloadRoutes($segment, $routeName, $controller)
-    {
-        Route::match(['get'], $segment . '/{id}/package/{action}/{version?}', $controller . '@package');
-        Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);;
-    }
+    use BaseDownloadOperation;
 
-    protected function setupDownloadDefaults()
-    {
-        $this->crud->addButtonFromView('line', 'download', 'elearningpackage.download', 'end');
-    }
-
-    protected function package($id, $action, $version = null)
-    {
-        if (!ElearningPackage::hasPermission($id, 'read')) {
-            abort(401);
-        }
-        $media = ElearningPackage::withoutGlobalScopes()->find($id);
-        $version = $version ?? $media->scorm_version;
-        ElearningPackageDownload::dispatch($media, $action, $version, backpack_user())->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('elearning-package'));
-    }
-
-    protected function download($id, $hash, $file)
-    {
-        $media = ElearningPackage::withoutGlobalScopes()->where('id', $id)->where('hash', $hash)->first();
-        if (null === $media) {
-            abort(404, __('Ce fichier est indisponible'));
-        }
-        $path = protected_path('elearningmedia/download/' . $id . '/' . $file);
-        if (!file_exists($path)) {
-            abort(404, __('Le fichier n\'existe pas'));
-        }
-        return XSendFileController::sendfile($path);
-    }
-
-//    protected function download($id, $action)
-//    {
-//        ElearningPackageDownload::dispatch(ELearningPackage::find($id), $action, backpack_user())->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('elearning-package'));
-//    }
+    protected $button = 'elearningpackage';
+    protected $downloadJob = ELearningPackageDownload::class;
 }
index f3744839804f6de9b896383d4282e6a96c6004eb..5f5b3e0e84b5cf41becaa2e26b86c525d5faeb81 100644 (file)
@@ -2,54 +2,15 @@
 
 namespace App\Http\Controllers\Admin\Operations\Quiz;
 
-use App\Fields\SCORMVersion;
-use App\Http\Middleware\CheckIfAdmin;
+use App\Http\Controllers\Admin\Operations\Base\BaseDownloadOperation;
 use App\Jobs\QuizDownload;
-use App\Models\FluidbookPublication;
-use App\Models\Quiz;
-use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
-use Cubist\Scorm\Version;
-use Illuminate\Support\Facades\Route;
-use Prologue\Alerts\Facades\Alert;
 
 // __('!! e-Learning')
 
 trait DownloadOperation
 {
-    protected function setupDownloadRoutes($segment, $routeName, $controller)
-    {
-        Route::match(['get'], $segment . '/{id}/package/{action}/{version?}', $controller . '@package');
-        Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);;
-    }
+    use BaseDownloadOperation;
 
-    protected function setupDownloadDefaults()
-    {
-
-        $this->crud->addButtonFromView('line', 'download', 'quiz.download', 'end');
-    }
-
-    protected function package($id, $action, $version = null)
-    {
-        if (!Quiz::hasPermission($id, 'read')) {
-            abort(401);
-        }
-        $quiz = Quiz::withoutGlobalScopes()->find($id);
-        $version = $version ?? $quiz->scorm_version;
-        QuizDownload::dispatch($quiz, $action, $version, backpack_user())->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('quiz'));
-    }
-
-    protected function download($id, $hash, $file)
-    {
-        $quiz = Quiz::withoutGlobalScopes()->where('id', $id)->where('hash', $hash)->first();
-        if (null === $quiz) {
-            abort(404, __('Ce fichier est indisponible'));
-        }
-        $path = protected_path('quiz/download/' . $id . '/' . $file);
-        if (!file_exists($path)) {
-            abort(404, __('Le fichier n\'existe pas'));
-        }
-        return XSendFileController::sendfile($path);
-    }
+    protected $button = 'quiz';
+    protected $downloadJob = QuizDownload::class;
 }
index 8000a997080a7c66f254eb58b55123d956ba2e0a..2a340e5b0499e8e1ad8ff5a12a5d5f9470ffa44d 100644 (file)
@@ -9,6 +9,8 @@ use Illuminate\Support\Facades\Cache;
 class Base extends \Cubist\Backpack\Jobs\Base
 {
 
+    protected $tries = 1;
+
     /**
      * @var User|null
      */
index bdf2067606fe7e683217a1a53c46c70b68ad56bd..da61686fa6257c521538a6061bffaf02f738db1d 100644 (file)
@@ -6,27 +6,18 @@ use App\Mail\DeferredDownload;
 use App\Models\User;
 use App\Notifications\DownloadReady;
 use App\Services\ScormCloud;
-use App\Slack\Message;
 use App\Slack\Slack;
 use Cubist\Backpack\Facades\App;
 use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Str;
 use Cubist\Util\Zip;
-use GrahamCampbell\Markdown\Facades\Markdown;
-use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Mail;
-use JoliCode\Slack\ClientFactory;
 use League\CommonMark\CommonMarkConverter;
 use League\CommonMark\Exception\CommonMarkException;
 
 class DownloadBase extends Base
 {
-    /**
-     * @var string
-     */
-    protected $type = 'base';
-
     /**
      * @var CubistMagicAbstractModel
      */
@@ -85,23 +76,33 @@ class DownloadBase extends Base
         Mail::send($mail);
     }
 
+    protected function getBaseURL()
+    {
+        return $this->entry->getOption('name');
+    }
+
+    protected function getType()
+    {
+        return str_replace('-', '', $this->getBaseURL());
+    }
+
     protected function _fname($title = null, $extension = 'zip')
     {
         if (null === $title) {
             $title = $this->_title();
         }
-        return Str::slugCase($this->type . '-' . date('Ymdhis') . '-' . md5(rand(10000, 100000000)) . '-' . Str::slug($title)) . '.' . $extension;
+        return Str::slugCase($this->getType() . '-' . date('Ymdhis') . '-' . md5(rand(10000, 100000000)) . '-' . Str::slug($title)) . '.' . $extension;
     }
 
 
     protected function _dest($fname)
     {
-        return Files::mkdir(protected_path($this->type . '/download/' . $this->entry->id . '/')) . $fname;
+        return Files::mkdir(protected_path($this->getBaseURL() . '/download/' . $this->entry->id . '/')) . $fname;
     }
 
     protected function _url($fname)
     {
-        return url('/' . $this->type . '/' . $this->entry->id . '_' . $this->entry->hash . '/download/' . $fname);
+        return url('/' . $this->getBaseURL() . '/' . $this->entry->id . '_' . $this->entry->hash . '/download/' . $fname);
     }
 
     protected function _title()
@@ -126,7 +127,7 @@ class DownloadBase extends Base
             $showTextIfNotEmail = false;
             if ($this->action === 'scormcloud') {
                 try {
-                    $scormURL = ScormCloud::send($url, env('SCORM_CLOUD_PREFIX', 'toolbox_') . $this->type . '_' . $this->_id());
+                    $scormURL = ScormCloud::send($url, env('SCORM_CLOUD_PREFIX', 'toolbox_') . $this->getType() . '_' . $this->_id());
                     $actions[__('Tester sur SCORM Cloud')] = $scormURL;
                 } catch (\Exception $e) {
                     $text .= "\n\n" . __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error (:url)', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID'), 'url' => $url]);
@@ -134,7 +135,7 @@ class DownloadBase extends Base
                 }
             }
         } catch (\Exception $e) {
-            $subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->type]);
+            $subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->getType()]);
             $text = __('Détails de l\'erreur :message', ['message' => $e->getMessage() . ' at line ' . $e->getLine() . ' of ' . $e->getFile()]);
             $showTextIfNotEmail = true;
             $actions = [];
@@ -151,10 +152,12 @@ class DownloadBase extends Base
     protected function _compileandpackage()
     {
 
+        echo 'Compile' . "\n";
         $compilepath = $this->_compile();
+        echo 'Compiled : ' . $compilepath . "\n";
         $fname = $this->_fname();
-        $dest = Files::mkdir(protected_path($this->type . '/download/' . $this->entry->id . '/')) . $fname;
-
+        $dest = Files::mkdir(protected_path($this->getBaseURL() . '/download/' . $this->entry->id . '/')) . $fname;
+        echo 'Zip to ' . $dest . "\n";
         Zip::archive($compilepath, $dest);
         if (!file_exists($dest)) {
             throw new \Exception('An error occured while compiling the collection');
@@ -166,6 +169,7 @@ class DownloadBase extends Base
     protected function _compile()
     {
         $compilepath = $this->entry->getFinalPath();
+        echo 'Compile to '.$compilepath."\n";
         $this->entry->compile($compilepath);
         return $compilepath;
     }
index 8d350e1ae7fd24fa6c4ffc694412b5835de65857..694cce547c933bdd72d8be98c71ad7976f507a6e 100644 (file)
@@ -2,13 +2,8 @@
 
 namespace App\Jobs;
 
-use App\Services\ScormCloud;
-use Cubist\Util\Files\Files;
-use Cubist\Util\Zip;
-
-class ElearningMediaDownload extends DownloadBase
+class ElearningMediaDownload extends ScormDownloadBase
 {
-    protected $type = 'elearningmedia';
     // __('Media ":title" (#:nb) prêt au téléchargement')
     protected $_subject = 'Media ":title" (#:nb) prêt au téléchargement';
     // __('Le media ":title" est prêt au téléchargement');
index 53a73876c2dbfc24bbf47d0c095ab8087766788f..12bb2f006845370ce05faef6dd994ac8a9911c2b 100644 (file)
@@ -2,13 +2,8 @@
 
 namespace App\Jobs;
 
-use App\Services\ScormCloud;
-use Cubist\Util\Files\Files;
-use Cubist\Util\Zip;
-
-class ElearningPackageDownload extends DownloadBase
+class ElearningPackageDownload extends ScormDownloadBase
 {
-    protected $type = 'elearningpackage';
     // __('Package ":title" (#:nb) prêt au téléchargement')
     protected $_subject = 'Package ":title" (#:nb) prêt au téléchargement';
     // __('Le package ":title" est prêt au téléchargement');
index 91a64c42fabfb1d0b84e7830ca1ee2c2f98fbd6c..ba68b9ae5cfa21bd869744a245c9bebfe9ba59ba 100644 (file)
@@ -21,11 +21,6 @@ class FluidbookDocumentUpload extends Base
      */
     protected $fluidbook_id;
 
-    /**
-     * @var int
-     */
-    public $tries = 1;
-
     public $queue = 'fluidbookprocess';
 
     /**
index a67a0ed2c1fa277a18dae570c682ced2fd01f48e..d4b560e56bed96859bea802c1a4d63e166338947 100644 (file)
@@ -2,33 +2,10 @@
 
 namespace App\Jobs;
 
-use App\Services\ScormCloud;
-use Cubist\Util\Files\Files;
-use Cubist\Util\Zip;
-
-class QuizDownload extends DownloadBase
+class QuizDownload extends ScormDownloadBase
 {
-
-    protected $type = 'quiz';
     // __('Quiz ":title" (#:nb) prêt au téléchargement')
     protected $_subject = 'Quiz ":title" (#:nb) prêt au téléchargement';
     // __('Le quiz ":title" est prêt au téléchargement')
     protected $_text = 'Le quiz ":title" est prêt au téléchargement';
-
-    protected $_scormVersion = null;
-
-    public function __construct($entry, $action, $scormVersion = null, $user = null)
-    {
-        $this->_scormVersion = $scormVersion;
-        parent::__construct($entry, $action, $user);
-    }
-
-    protected function _compile()
-    {
-        if (null !== $this->_scormVersion) {
-            $this->entry->scorm_version = $this->_scormVersion;
-        }
-        return parent::_compile();
-    }
-
 }
diff --git a/app/Jobs/ScormDownloadBase.php b/app/Jobs/ScormDownloadBase.php
new file mode 100644 (file)
index 0000000..6479b6a
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Jobs\DownloadBase;
+
+class ScormDownloadBase extends DownloadBase
+{
+    protected $_scormVersion = null;
+
+    public function __construct($entry, $action, $scormVersion = null, $user = null)
+    {
+        $this->_scormVersion = $scormVersion;
+        parent::__construct($entry, $action, $user);
+    }
+
+    protected function _compile()
+    {
+        if (null !== $this->_scormVersion) {
+            $this->entry->scorm_version = $this->_scormVersion;
+        }
+        return parent::_compile();
+    }
+}
diff --git a/app/Models/Base/ToolboxDownloadable.php b/app/Models/Base/ToolboxDownloadable.php
new file mode 100644 (file)
index 0000000..050d6e2
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models\Base;
+
+use App\Models\Traits\CheckHash;
+use Cubist\Util\Files\Files;
+
+trait ToolboxDownloadable
+{
+    use CheckHash;
+
+    public function onSaving(): bool
+    {
+        $this->checkHash();
+        return parent::onSaving();
+    }
+
+    public function getFinalPath()
+    {
+        return Files::mkdir(protected_path($this->getOption('name') . '/final/' . $this->id));
+    }
+}
index 9b781559324ea1c98ee5a55515ff88d4f8c1dc70..dd0630fe44995034e059c3865c3b82231d608521 100644 (file)
@@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
 use App\Http\Controllers\Admin\Operations\ELearningMedia\ImportOperation;
 use App\Http\Controllers\Admin\Operations\ELearningMedia\PreviewOperation;
 use App\Http\Controllers\Admin\Operations\ELearningMedia\DownloadOperation;
+use App\Models\Base\ToolboxDownloadable;
 use App\Models\Base\ToolboxModel;
 use App\Models\Traits\CheckHash;
 use App\Models\Traits\SCORMVersionTrait;
@@ -23,7 +24,7 @@ use Spatie\MediaLibrary\MediaCollections\Models\Media;
 class ELearningMedia extends ToolboxModel
 {
     use SCORMVersionTrait;
-    use CheckHash;
+    use ToolboxDownloadable;
 
     protected $table = 'elearning_media';
 
@@ -94,11 +95,6 @@ class ELearningMedia extends ToolboxModel
         }
     }
 
-    public function getFinalPath()
-    {
-        return protected_path('elearningmedia/final/' . $this->id);
-    }
-
     public function compile($dest)
     {
         $owner = User::withoutGlobalScopes()->findOrFail($this->owner);
@@ -154,12 +150,6 @@ class ELearningMedia extends ToolboxModel
         return $title;
     }
 
-    public function onSaving(): bool
-    {
-        $this->checkHash();
-        return parent::onSaving();
-    }
-
     public function getIdTitleAttribute()
     {
         return $this->id . ' - ' . $this->title;
index b5d2ae68e7af4bf287c9f0ac8461921c79414498..de03b0b6a3c8416763829fe519d40b935a398d4e 100644 (file)
@@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
 use App\Http\Controllers\Admin\Operations\ELearningPackage\ImportOperation;
 use App\Http\Controllers\Admin\Operations\ELearningPackage\PreviewOperation;
 use App\Http\Controllers\Admin\Operations\ELearningPackage\DownloadOperation;
+use App\Models\Base\ToolboxDownloadable;
 use App\Models\Base\ToolboxModel;
 use App\Models\Traits\CheckHash;
 use App\Models\Traits\SCORMVersionTrait;
@@ -26,7 +27,7 @@ use DirectoryIterator;
 class ELearningPackage extends ToolboxModel
 {
     use SCORMVersionTrait;
-    use CheckHash;
+    use ToolboxDownloadable;
 
     protected $table = 'elearning_package';
 
@@ -75,10 +76,6 @@ class ELearningPackage extends ToolboxModel
         $this->addField('contents', BunchOfFieldsMultiple::class, __('Contenus'), ['bunch' => ElearningPackageContent::class, 'edit_label' => __('Editer « :label »', ['label' => '%content_type'])]);
     }
 
-    public function getFinalPath()
-    {
-        return protected_path('elearningpackage/final/' . $this->id);
-    }
 
     public function compile($dest, $user = null)
     {
@@ -163,12 +160,6 @@ class ELearningPackage extends ToolboxModel
         return $res;
     }
 
-    public function onSaving(): bool
-    {
-        $this->checkHash();
-        return parent::onSaving();
-    }
-
     /**
      * @param $id int
      * @param $vdir VirtualDirectory
index ce9d86d1a355912229fdc907a72071c9ddbe61e3..6d32f4c3d884ea920349c906e32f406a91002721 100644 (file)
@@ -6,6 +6,7 @@ use App\Fields\FluidbookExportVersion;
 use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
 use App\Http\Controllers\Admin\Operations\FluidbookCollection\DownloadOperation;
 use App\Http\Controllers\Admin\Operations\FluidbookCollection\PreviewOperation;
+use App\Models\Base\ToolboxDownloadable;
 use App\Models\Base\ToolboxModel;
 use App\Models\Traits\CheckHash;
 use App\Slack\Slack;
@@ -22,7 +23,7 @@ use Cubist\Util\Files\Files;
 // __('!! Collections de fluidbooks')
 class FluidbookCollection extends ToolboxModel
 {
-    use CheckHash;
+    use ToolboxDownloadable;
 
     protected $table = 'fluidbook_collection';
     protected $_options = ['name' => 'fluidbook-collection',
@@ -41,7 +42,7 @@ class FluidbookCollection extends ToolboxModel
 
         $this->addOwnerField();
 
-        $this->addField('hash', Hidden::class);
+        $this->addHashField();
         $this->addField('type', SelectFromArray::class, __('Type'), ['can' => 'fluidbook-collection:write', 'column' => true, 'options' => ['export' => __('Export'), 'export_multilang' => __('Export multilingue'), 'scorm_multilang' => __('SCORM multilingue')]]);
         $this->addField('locale_switch', Checkbox::class, __('Permettre le changement de langue'), ['when' => ['type' => ['scorm_multilang', 'export_multilang']], 'default' => true]);
         $this->addField('redirection_algorithm', SelectFromArray::class, __('Algorithme de choix de la version'),
@@ -63,11 +64,6 @@ class FluidbookCollection extends ToolboxModel
         return Files::mkdir(protected_path('fluidbookcollection/final/' . $this->id));
     }
 
-    public function onSaving(): bool
-    {
-        $this->checkHash();
-        return parent::onSaving();
-    }
 
 
     public function allowsPreview()
index f251e3924082b92155039f570a3c041e91e32f33..e9d3f7a9d38ca891a463ee1c07bbc3e1b3efdbb8 100644 (file)
@@ -31,6 +31,7 @@ use App\Http\Controllers\Admin\Operations\FluidbookPublication\YSLOperation;
 use App\Jobs\FluidbookImagesPreprocess;
 use App\Jobs\FluidbookSocialImage;
 use App\Jobs\GenerateDeliveryThumbnailsPreview;
+use App\Models\Base\ToolboxDownloadable;
 use App\Models\Base\ToolboxSettingsModel;
 use App\Models\Traits\CheckHash;
 use App\Models\Traits\PublicationSettings;
@@ -112,7 +113,7 @@ class FluidbookPublication extends ToolboxSettingsModel
     use PublicationSettings;
     use PublicationTags;
     use SCORMVersionTrait;
-    use CheckHash;
+    use ToolboxDownloadable;
 
     public static function addOwnerClause(Builder $builder)
     {
index 10db4324992db18d67b2ba681129a5629329b510..3bc42e68673a5679bd5e3ba3bbf8b538d3339806 100644 (file)
@@ -8,12 +8,11 @@ use App\Fields\QuizDevelopmentVersion;
 use App\Fields\SCORMVersion;
 use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
 use App\Http\Controllers\Admin\Operations\Quiz\DownloadOperation;
-use App\Http\Controllers\Admin\Operations\Quiz\ImportOperation;
 use App\Http\Controllers\Admin\Operations\Quiz\LogOperation;
 use App\Http\Controllers\Admin\Operations\Quiz\PreviewOperation;
 use App\Http\Controllers\Admin\Operations\Quiz\ReportOperation;
+use App\Models\Base\ToolboxDownloadable;
 use App\Models\Base\ToolboxModel;
-use App\Models\Traits\CheckHash;
 use App\Models\Traits\SCORMVersionTrait;
 use Cubist\Backpack\Magic\Fields\Checkbox;
 use Cubist\Backpack\Magic\Fields\Code;
@@ -21,7 +20,6 @@ use Cubist\Backpack\Magic\Fields\FormBigSection;
 use Cubist\Backpack\Magic\Fields\FormSection;
 use Cubist\Backpack\Magic\Fields\FormSeparator;
 use Cubist\Backpack\Magic\Fields\FormSuperSection;
-use Cubist\Backpack\Magic\Fields\Hidden;
 use Cubist\Backpack\Magic\Fields\SelectFromArray;
 use Cubist\Backpack\Magic\Fields\Text;
 use Cubist\Backpack\Magic\Fields\Textarea;
@@ -31,7 +29,8 @@ use Spatie\MediaLibrary\MediaCollections\Models\Media;
 // __('!! e-Learning')
 class Quiz extends ToolboxModel
 {
-    use CheckHash;
+    use ToolboxDownloadable;
+    use SCORMVersionTrait;
 
     protected $table = 'quiz';
 
@@ -47,7 +46,7 @@ class Quiz extends ToolboxModel
 
     protected $_operations = [PreviewOperation::class, DownloadOperation::class, LogOperation::class, ReportOperation::class, ChangeownerOperation::class];
 
-    use SCORMVersionTrait;
+
 
     protected static function _getColors()
     {
@@ -354,17 +353,6 @@ class Quiz extends ToolboxModel
         return parent::create($data);
     }
 
-    public function getFinalPath()
-    {
-        return protected_path('quiz/final/' . $this->id);
-    }
-
-    public function onSaving(): bool
-    {
-        $this->checkHash();
-        return parent::onSaving();
-    }
-
     public function getPreviewURL($attrs = [])
     {
         $routeName = 'quiz_preview';
index ac9f520fe29e5d08e99a181c2be205535fd6a055..11f90ef1de60665c84ff3c16378b7a3b265ce26c 100644 (file)
@@ -65,7 +65,7 @@ class ToolboxNotification extends Notification
         foreach ($this->actions as $label => $url) {
             $m->line(new HtmlString($label . __(': ') . ' <a href="' . $url . '">' . $url . '</a>'));
         }
-        $m->salutation(new HtmlString(__('Cordialement,') . "<br>" . __('L\'équipe :teamname',['team_name'=>env('MAIL_TEAM_NAME')])));
+        $m->salutation(new HtmlString(__('Cordialement,') . "<br>" . __('L\'équipe :teamname', ['teamname' => env('MAIL_TEAM_NAME')])));
         return $m;
 
     }