From 8d058ee624eca7cb8ec83b30d8c9ea0c63c1d726 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 8 Dec 2023 14:50:50 +0100 Subject: [PATCH] wait #6563 @2 --- .../Operations/Base/BaseDownloadOperation.php | 29 +++- .../ELearningMedia/PreviewOperation.php | 31 ++-- .../ELearningPackage/PreviewOperation.php | 31 ++-- .../Operations/ElearningPreviewOperation.php | 134 ++++++++++++++++++ .../FluidbookCollection/DownloadOperation.php | 46 +----- .../Operations/Quiz/PreviewOperation.php | 96 ++----------- app/Jobs/DownloadBase.php | 2 +- .../CheckPublicationsHashAndCid.php | 5 +- app/Models/Base/ToolboxDownloadable.php | 2 +- app/Models/Base/ToolboxModel.php | 11 ++ app/Models/ELearningMedia.php | 2 +- app/Models/ELearningPackage.php | 1 + app/Models/Quiz.php | 14 +- .../fluidbook_collection/download.blade.php | 2 +- .../backpack/crud/buttons/preview.blade.php | 3 + .../crud/buttons/quiz/preview.blade.php | 3 - 16 files changed, 215 insertions(+), 197 deletions(-) create mode 100644 app/Http/Controllers/Admin/Operations/ElearningPreviewOperation.php create mode 100644 resources/views/vendor/backpack/crud/buttons/preview.blade.php delete mode 100644 resources/views/vendor/backpack/crud/buttons/quiz/preview.blade.php diff --git a/app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php b/app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php index 9c4d816a8..438621433 100644 --- a/app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php +++ b/app/Http/Controllers/Admin/Operations/Base/BaseDownloadOperation.php @@ -5,6 +5,8 @@ namespace App\Http\Controllers\Admin\Operations\Base; // __('!! e-Learning') use App\Http\Middleware\CheckIfAdmin; +use App\Jobs\ScormDownloadBase; +use App\Models\Base\ToolboxStatusModel; use Cubist\Backpack\Http\Controllers\Base\XSendFileController; use Illuminate\Support\Facades\Route; use Prologue\Alerts\Facades\Alert; @@ -13,7 +15,7 @@ trait BaseDownloadOperation { protected function setupDownloadRoutes($segment, $routeName, $controller) { - Route::match(['get'], $segment . '/{id}/package/{action}/{version?}', $controller . '@package'); + Route::match(['get'], $segment . '/{id}/package/{action}/{version?}', $controller . '@package')->whereNumber('id'); Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);; } @@ -32,14 +34,32 @@ trait BaseDownloadOperation abort(401); } $instance = $model::withoutGlobalScopes()->find($id); - $version = $version ?? $instance->scorm_version; - $job::dispatch($instance, $action, $version, backpack_user())->onQueue('download');; + if (is_subclass_of($job, ScormDownloadBase::class)) { + $version = $version ?? $instance->scorm_version ?? null; + $job::dispatch($instance, $action, $version, backpack_user())->onQueue('download'); + } else { + $job::dispatch($instance, $action, backpack_user())->onQueue('download'); + } + + if ($instance instanceof ToolboxStatusModel) { + // Mark the fluidbook as downloaded when status is ready and user is not an admin + if ($instance->status == 1 && backpack_user() && $instance->canAdmin(backpack_user())) { + $instance->setStatus(2); + $instance->save(); + } + } + + 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) { + $e = explode('-', $file); + if ($e[1] != $id) { + abort(404, __('Erreur de correspondance du fichier')); + } $entry = $this->getModelInstance(); $model = get_class($entry); @@ -47,10 +67,11 @@ trait BaseDownloadOperation if (null === $instance) { abort(404, __('Ce fichier est indisponible')); } - $path = protected_path($entry->getOption('name') . '/download/' . $id . '/' . $file); + $path = protected_path(str_replace('-', '', $entry->getOption('name')) . '/download/' . $id . '/' . $file); if (!file_exists($path)) { abort(404, __('Le fichier n\'existe pas')); } return XSendFileController::sendfile($path); } + } diff --git a/app/Http/Controllers/Admin/Operations/ELearningMedia/PreviewOperation.php b/app/Http/Controllers/Admin/Operations/ELearningMedia/PreviewOperation.php index faccc6266..ebdace52f 100644 --- a/app/Http/Controllers/Admin/Operations/ELearningMedia/PreviewOperation.php +++ b/app/Http/Controllers/Admin/Operations/ELearningMedia/PreviewOperation.php @@ -4,33 +4,22 @@ namespace App\Http\Controllers\Admin\Operations\ELearningMedia; -use Cubist\Util\Files\Files; -use Illuminate\Support\Facades\Route; +use App\Http\Controllers\Admin\Operations\ElearningPreviewOperation; +use App\Models\ELearningMedia; trait PreviewOperation { - protected function setupPreviewRoutes($segment, $routeName, $controller) - { - Route::match(['get'], $segment . '/{id}/preview/{path?}', $controller . '@preview') - ->where(['id' => '[0-9]+', 'path' => '.*']); - } + use ElearningPreviewOperation; - protected function setupPreviewDefaults() - { - $this->crud->addButtonFromView('line', 'open_preview', 'elearningmedia.preview', 'begining'); - } + protected $button = 'elearningmedia'; + protected $path = 'elearningmedia'; + protected $entryClass=ElearningMedia::class; - protected function preview($id, $path = 'index.html') - { - $entry = $this->crud->getEntry($id); - $dest = $entry->getFinalPath(); - if ($path === 'index.html') { + protected function getCompileMessage() + { + return __('Compilation du media en cours'); + } - $entry->compile($dest); - } - $p = $dest . '/' . $path; - return response(null)->header('Content-Type', Files::_getMimeType($p))->header('X-Sendfile', $p); - } } diff --git a/app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php b/app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php index 480047215..380b49396 100644 --- a/app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php +++ b/app/Http/Controllers/Admin/Operations/ELearningPackage/PreviewOperation.php @@ -2,34 +2,23 @@ namespace App\Http\Controllers\Admin\Operations\ELearningPackage; -use Cubist\Util\Files\Files; -use Illuminate\Support\Facades\Route; +use App\Http\Controllers\Admin\Operations\ElearningPreviewOperation; +use App\Models\ELearningMedia; +use App\Models\ELearningPackage; // __('!! e-Learning') trait PreviewOperation { - protected function setupPreviewRoutes($segment, $routeName, $controller) - { - Route::match(['get'], $segment . '/{id}/preview/{path?}', $controller . '@preview') - ->where(['id' => '[0-9]+', 'path' => '.*']); - } + use ElearningPreviewOperation; - protected function setupPreviewDefaults() - { - $this->crud->addButtonFromView('line', 'open_preview', 'elearningpackage.preview', 'begining'); - } + protected $button = 'elearningpackage'; + protected $path = 'elearningpackage'; - protected function preview($id, $path = 'index.html') - { - $entry = $this->crud->getEntry($id); - $dest = $entry->getFinalPath(); - - if ($path === 'index.html') { - $entry->compile($dest); - } + protected $entryClass = ELearningPackage::class; - $p = $dest . '/' . $path; - return response(null)->header('Content-Type', Files::_getMimeType($p))->header('X-Sendfile', $p); + protected function getCompileMessage() + { + return __('Compilation du package en cours'); } } diff --git a/app/Http/Controllers/Admin/Operations/ElearningPreviewOperation.php b/app/Http/Controllers/Admin/Operations/ElearningPreviewOperation.php new file mode 100644 index 000000000..55e42ef8f --- /dev/null +++ b/app/Http/Controllers/Admin/Operations/ElearningPreviewOperation.php @@ -0,0 +1,134 @@ +_preview($segment, $id, $hash, null, 'index.html'); + })->where('id', '([0-9]+)(-[0-9]+)?') + ->where('hash', '[0-9a-f]{32}') + ->withoutMiddleware([CheckIfAdmin::class]) + ->name($segment . '_preview'); + + Route::match(['get'], $segment . '/preview/{id}_{hash}_{time}/{path?}', function ($id, $hash, $time, $path = 'index.html') use ($segment, $controller) { + return $this->_preview($segment, $id, $hash, $time, $path); + })->where('id', '([0-9]+)(-[0-9]+)?') + ->where('hash', '[0-9a-f]{32}') + ->where('path', '.*') + ->whereNumber('time') + ->withoutMiddleware([CheckIfAdmin::class]) + ->name($segment . '_preview_with_time'); + } + + protected function setupPreviewDefaults() + { + $this->crud->addButtonFromView('line', 'open_preview', 'preview', 'begining'); + } + + protected function _preview($segment, $id, $hash, $time = null, $path = null) + { + PHP::neverStop(true); + $q = request()->getQueryString(); + if ($q) { + $q = '?' . $q; + } + $nointerface = !!request('nointerface', false); + $shortLoading = !!request('shortLoading', false); + $forceTheme = false; + + $this->_getEntryAndTheme($id, $hash, $entry, $theme, $forceTheme); + + if (null === $time || ((null === $path || $path === 'index.html') && $time > 0 && $time < (time() - 60) && !$nointerface && !$shortLoading)) { + $url = backpack_url($segment . '/preview/' . $id . '_' . $hash . '_' . time()) . '/' . $q; + return $this->loadingCompile($url, $id, $hash); + } + + return $this->preview($entry, $theme, $forceTheme, $path); + } + + /** + * @param Quiz $quiz + * @param QuizTheme $theme + * @param string $path + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Foundation\Application|\Illuminate\Http\Response + */ + protected function preview($entry, $theme, $forceTheme = false, $path = 'index.html') + { + $id = $forceTheme ? $entry->id . '-' . $theme->id : $entry->id; + + $dest = protected_path($this->path . '/final/' . $id); + if ($path === 'index.html') { + $entry->compile($dest, $theme); + } + $p = $dest . '/' . $path; + return response(null)->header('Content-Type', Files::_getMimeType($p))->header('X-Sendfile', $p); + } + + /** + * @param $url string + * @param $id string + * @param $hash string + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response + */ + public function loadingCompile($url, $id, $hash) + { + PHP::neverStop(false); + + self::_getEntryAndTheme($id, $hash, $entry, $theme, $forceTheme); + if (null === $entry) { + abort(404); + } + + $back = $theme->backgroundColor; + $text = (new Color($back))->closestColor([(new Color('#000000')), (new Color('#ffffff'))], true)->toCss(); + + $res = $this->_compileScreen( + $entry->title, $url, $this->getCompileMessage() + , + __('Cette étape ne sera pas nécessaire lorsque le contenu sera installé sur son emplacement définitif'), + $back, + $text, + ); + return response($res); + } + + protected function getCompileMessage() + { + return __('Compilation du quiz en cours'); + } + + /** + * @param $id string + * @param $hash string + * @param $entry Quiz + * @param $theme QuizTheme + * @return void + */ + protected function _getEntryAndTheme($id, $hash, &$entry, &$theme, &$forceTheme) + { + $theme = new \stdClass(); + $theme->backgroundColor = '#ffffff'; + $this->id = 0; + + $c = $this->entryClass; + + $entry = $c::withoutGlobalScopes()->where('id', $id)->where('hash', $hash)->first(); + if (null === $entry) { + abort(404, __('Lien de prévisualisation invalide')); + } + $forceTheme = false; + } +} diff --git a/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php index 8f2702c62..968440458 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookCollection/DownloadOperation.php @@ -2,8 +2,10 @@ namespace App\Http\Controllers\Admin\Operations\FluidbookCollection; +use App\Http\Controllers\Admin\Operations\Base\BaseDownloadOperation; use App\Http\Middleware\CheckIfAdmin; use App\Jobs\FluidbookCollectionDownload; +use App\Jobs\QuizDownload; use App\Models\FluidbookCollection; use Cubist\Backpack\Http\Controllers\Base\XSendFileController; use Illuminate\Support\Facades\Route; @@ -13,47 +15,9 @@ use Prologue\Alerts\Facades\Alert; trait DownloadOperation { - protected function setupDownloadRoutes($segment, $routeName, $controller) - { + use BaseDownloadOperation; - Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@downloadFile')->withoutMiddleware([CheckIfAdmin::class]);; - Route::match(['get'], $segment . '/{id}/download/{action}', $controller . '@download')->whereNumber('id'); - } + protected $button = 'fluidbook_collection'; + protected $downloadJob = FluidbookCollectionDownload::class; - protected function setupDownloadDefaults() - { - $this->crud->addButtonFromView('line', 'download', 'fluidbook_collection.download', 'end'); - } - - protected function download($id, $action) - { - $collection = FluidbookCollection::withoutGlobalScopes()->find($id); - FluidbookCollectionDownload::dispatch($collection, $action, backpack_user())->onQueue('download'); - - // Mark the fluidbook as downloaded when status is ready and user is not an admin - if ($collection->status == 1 && !can('fluidbook-publication:admin')) { - $collection->setStatus(2); - $collection->save(); - } - - 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-collection')); - } - - protected function downloadFile($id, $hash, $file) - { - $e = explode('-', $file); - if ($e[1] != $id) { - abort(404, __('Erreur de correspondance du fichier')); - } - $collection = FluidbookCollection::where('id', $id)->where('hash', $hash)->first(); - if (null === $collection) { - abort(404, __('Ce fichier est indisponible')); - } - $path = protected_path('fluidbookcollection/download/' . $id . '/' . $file); - if (!file_exists($path)) { - abort(404, __('Le fichier n\'existe pas')); - } - return XSendFileController::sendfile($path); - } } diff --git a/app/Http/Controllers/Admin/Operations/Quiz/PreviewOperation.php b/app/Http/Controllers/Admin/Operations/Quiz/PreviewOperation.php index d26f28029..b46f035b2 100644 --- a/app/Http/Controllers/Admin/Operations/Quiz/PreviewOperation.php +++ b/app/Http/Controllers/Admin/Operations/Quiz/PreviewOperation.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin\Operations\Quiz; use App\Http\Controllers\Admin\Operations\FluidbookPreviewOperation; +use App\Http\Controllers\Admin\Operations\ElearningPreviewOperation; use App\Http\Middleware\CheckIfAdmin; use App\Models\FluidbookTheme; use App\Models\Quiz; @@ -16,98 +17,17 @@ use Illuminate\Support\Facades\Route; trait PreviewOperation { - use FluidbookPreviewOperation; - protected function setupPreviewRoutes($segment, $routeName, $controller) - { - Route::match(['get'], $segment . '/preview/{id}_{hash}', function ($id, $hash) use ($segment) { - return $this->_preview($segment, $id, $hash, null, 'index.html'); - })->where('id', '([0-9]+)(-[0-9]+)?') - ->where('hash', '[0-9a-f]{32}') - ->withoutMiddleware([CheckIfAdmin::class]) - ->name('quiz_preview'); - - Route::match(['get'], $segment . '/preview/{id}_{hash}_{time}/{path?}', function ($id, $hash, $time, $path = 'index.html') use ($segment, $controller) { - return $this->_preview($segment, $id, $hash, $time, $path); - })->where('id', '([0-9]+)(-[0-9]+)?') - ->where('hash', '[0-9a-f]{32}') - ->where('path', '.*') - ->whereNumber('time') - ->withoutMiddleware([CheckIfAdmin::class]) - ->name('quiz_preview_with_time'); - } - - protected function setupPreviewDefaults() - { - $this->crud->addButtonFromView('line', 'open_preview', 'quiz.preview', 'begining'); - } - - - protected function _preview($segment, $id, $hash, $time = null, $path = null) - { - PHP::neverStop(true); - $q = request()->getQueryString(); - if ($q) { - $q = '?' . $q; - } - $nointerface = !!request('nointerface', false); - $shortLoading = !!request('shortLoading', false); - $forceTheme = false; - - self::_getQuizAndTheme($id, $hash, $quiz, $theme, $forceTheme); - - if (null === $time || ((null === $path || $path === 'index.html') && $time > 0 && $time < (time() - 60) && !$nointerface && !$shortLoading)) { - $url = backpack_url($segment . '/preview/' . $id . '_' . $hash . '_' . time()) . '/' . $q; - return $this->loadingCompile($url, $id, $hash); - } - - return $this->preview($quiz, $theme, $forceTheme, $path); - } + use ElearningPreviewOperation; + protected $button = 'quiz'; + protected $entryClass = Quiz::class; - /** - * @param Quiz $quiz - * @param QuizTheme $theme - * @param string $path - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Foundation\Application|\Illuminate\Http\Response - */ - protected function preview($quiz, $theme, $forceTheme = false, $path = 'index.html') - { - $id = $forceTheme ? $quiz->id . '-' . $theme->id : $quiz->id; - - $dest = protected_path('quiz/final/' . $id); - if ($path === 'index.html') { - $quiz->compile($dest, $theme); - } - $p = $dest . '/' . $path; - return response(null)->header('Content-Type', Files::_getMimeType($p))->header('X-Sendfile', $p); - } - - /** - * @param $url string - * @param $id string - * @param $hash string - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response - */ - public function loadingCompile($url, $id, $hash) - { - PHP::neverStop(false); - - self::_getQuizAndTheme($id, $hash, $quiz, $theme, $forceTheme); - if (null === $theme || null === $quiz) { - abort(404); - } + protected $path='quiz'; - $back = $theme->backgroundColor; - $text = (new Color($back))->closestColor([(new Color('#000000')), (new Color('#ffffff'))], true)->toCss(); - $res = $this->_compileScreen( - $quiz->title, $url, __('Compilation du quiz en cours'), - __('Cette étape ne sera pas nécessaire lorsque le fluidbook sera installé sur son emplacement définitif'), - $back, - $text, - ); - return response($res); + protected function getCompileMessage(){ + return __('Compilation du quiz en cours'); } /** @@ -117,7 +37,7 @@ trait PreviewOperation * @param $theme QuizTheme * @return void */ - protected static function _getQuizAndTheme($id, $hash, &$quiz, &$theme, &$forceTheme) + protected function _getEntryAndTheme($id, $hash, &$quiz, &$theme, &$forceTheme) { $ee = explode('-', $id); $forceThemeData = request('theme', false); diff --git a/app/Jobs/DownloadBase.php b/app/Jobs/DownloadBase.php index ff8767393..f88a010f9 100644 --- a/app/Jobs/DownloadBase.php +++ b/app/Jobs/DownloadBase.php @@ -102,7 +102,7 @@ class DownloadBase extends Base protected function _url($fname) { - return url('/' . $this->getBaseURL() . '/' . $this->entry->id . '_' . $this->entry->hash . '/' . $fname); + return url('/' . $this->getBaseURL() . '/' . $this->entry->id . '_' . $this->entry->hash . '/download/' . $fname); } protected function _title() diff --git a/app/Jobs/Maintenance/CheckPublicationsHashAndCid.php b/app/Jobs/Maintenance/CheckPublicationsHashAndCid.php index 601b6dd7f..606924bc7 100644 --- a/app/Jobs/Maintenance/CheckPublicationsHashAndCid.php +++ b/app/Jobs/Maintenance/CheckPublicationsHashAndCid.php @@ -5,6 +5,7 @@ namespace App\Jobs\Maintenance; use App\Jobs\Base; use App\Models\ELearningMedia; use App\Models\ELearningPackage; +use App\Models\FluidbookCollection; use App\Models\FluidbookPublication; use App\Models\Quiz; use Illuminate\Support\Facades\Log; @@ -13,7 +14,7 @@ class CheckPublicationsHashAndCid extends Base { public function handle() { - $classes = ['Quiz' => Quiz::class, 'Elearning Media' => ELearningMedia::class, 'Elearning Package' => ELearningPackage::class]; + $classes = ['Quiz' => Quiz::class, 'Elearning Media' => ELearningMedia::class, 'Elearning Package' => ELearningPackage::class, 'Collection' => FluidbookCollection::class]; foreach ($classes as $name => $class) { $class::withoutGlobalScopes()->where('created_ok', '0')->forceDelete(); @@ -22,8 +23,6 @@ class CheckPublicationsHashAndCid extends Base })->get() as $instance) { $instance->save(); }; - - } /** @var FluidbookPublication $fluidbook */ diff --git a/app/Models/Base/ToolboxDownloadable.php b/app/Models/Base/ToolboxDownloadable.php index 050d6e243..2c3364672 100644 --- a/app/Models/Base/ToolboxDownloadable.php +++ b/app/Models/Base/ToolboxDownloadable.php @@ -17,6 +17,6 @@ trait ToolboxDownloadable public function getFinalPath() { - return Files::mkdir(protected_path($this->getOption('name') . '/final/' . $this->id)); + return Files::mkdir(protected_path(str_replace('-', '', $this->getOption('name')) . '/final/' . $this->id)); } } diff --git a/app/Models/Base/ToolboxModel.php b/app/Models/Base/ToolboxModel.php index dd1097c5a..ac97bba5c 100644 --- a/app/Models/Base/ToolboxModel.php +++ b/app/Models/Base/ToolboxModel.php @@ -158,4 +158,15 @@ class ToolboxModel extends CubistMagicAbstractModel $this->{static::$_ownerAttribute} = $owner; } + + public function getPreviewURL($attrs = []) + { + $routeName = $this->getOption('name') . '_preview'; + if (isset($attrs['time']) || isset($attrs['path'])) { + $routeName .= '_with_time'; + $default = ['path' => '', 'time' => time()]; + $attrs = array_merge($default, $attrs); + } + return route($routeName, array_merge(['id' => $this->id, 'hash' => $this->hash], $attrs)); + } } diff --git a/app/Models/ELearningMedia.php b/app/Models/ELearningMedia.php index dd0630fe4..dc5e578a3 100644 --- a/app/Models/ELearningMedia.php +++ b/app/Models/ELearningMedia.php @@ -25,6 +25,7 @@ class ELearningMedia extends ToolboxModel { use SCORMVersionTrait; use ToolboxDownloadable; + use CheckHash; protected $table = 'elearning_media'; @@ -100,7 +101,6 @@ class ELearningMedia extends ToolboxModel $owner = User::withoutGlobalScopes()->findOrFail($this->owner); $organization = $owner->companyName; - /** @var Media $file */ $file = $this->getMediaInField('file')->first()->getPath(); self::compileFromFile($file, $dest, $this->title, $organization, 'MEDIA_' . $this->id, $this->scorm_version, 75); diff --git a/app/Models/ELearningPackage.php b/app/Models/ELearningPackage.php index de03b0b6a..8253c1254 100644 --- a/app/Models/ELearningPackage.php +++ b/app/Models/ELearningPackage.php @@ -28,6 +28,7 @@ class ELearningPackage extends ToolboxModel { use SCORMVersionTrait; use ToolboxDownloadable; + use CheckHash; protected $table = 'elearning_package'; diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index ab2330034..6ea20c2cb 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -333,7 +333,8 @@ class Quiz extends ToolboxModel } // Create data.js - $locale = $data->get('translation', 'en') ?? 'en'; + $locale = $data->get('translation', + 'en') ?? 'en'; // Countries $d['countriesList'] = \Cubist\Locale\Country::getList($locale); @@ -384,17 +385,6 @@ class Quiz extends ToolboxModel return parent::create($data); } - public function getPreviewURL($attrs = []) - { - $routeName = 'quiz_preview'; - if (isset($attrs['time']) || isset($attrs['path'])) { - $routeName .= '_with_time'; - $default = ['path' => '', 'time' => time()]; - $attrs = array_merge($default, $attrs); - } - return route($routeName, array_merge(['id' => $this->id, 'hash' => $this->hash], $attrs)); - } - /** * @return QuizTheme */ diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php index 513265bfb..031cdcbfc 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_collection/download.blade.php @@ -38,7 +38,7 @@ data-context-confirm="{{json_encode($confirm)}}" @endif data-context-actions="{{json_encode($actions)}}" - data-context-route="{{$crud->route}}/$id/download/$action" + data-context-route="{{$crud->route}}/$id/package/$action" data-context-id="{{$entry->getKey()}}" > {{__('Export')}} diff --git a/resources/views/vendor/backpack/crud/buttons/preview.blade.php b/resources/views/vendor/backpack/crud/buttons/preview.blade.php new file mode 100644 index 000000000..c8587c775 --- /dev/null +++ b/resources/views/vendor/backpack/crud/buttons/preview.blade.php @@ -0,0 +1,3 @@ +{{-- __('!! e-Learning') --}} + {{__('Prévisualiser')}} diff --git a/resources/views/vendor/backpack/crud/buttons/quiz/preview.blade.php b/resources/views/vendor/backpack/crud/buttons/quiz/preview.blade.php deleted file mode 100644 index c686cabc4..000000000 --- a/resources/views/vendor/backpack/crud/buttons/quiz/preview.blade.php +++ /dev/null @@ -1,3 +0,0 @@ -{{-- __('!! e-Learning') --}} - {{__('Prévisualiser')}} -- 2.39.5