From 24a56cc6ef73e6030ae716ce18d31378cbccf42e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 27 Jul 2023 14:48:29 +0200 Subject: [PATCH] wip #6180 @2 --- app/Elearning/QuizCompiler.php | 17 +-- .../Operations/FluidbookPreviewOperation.php | 30 ++++- .../Operations/Quiz/PreviewOperation.php | 110 ++++++++++++++++-- .../CheckPublicationsHashAndCid.php | 9 ++ app/Models/FluidbookPublication.php | 2 +- app/Models/Quiz.php | 33 +++++- app/Models/QuizTheme.php | 18 +++ .../crud/buttons/quiz/preview.blade.php | 2 +- 8 files changed, 188 insertions(+), 33 deletions(-) diff --git a/app/Elearning/QuizCompiler.php b/app/Elearning/QuizCompiler.php index 1eef0bdc9..b7b80bc23 100644 --- a/app/Elearning/QuizCompiler.php +++ b/app/Elearning/QuizCompiler.php @@ -35,7 +35,7 @@ class QuizCompiler extends Base public function __construct($quiz, $dest, $forceScorm = false) { $this->quiz = Quiz::withoutGlobalScopes()->find($quiz); - $this->theme = QuizTheme::withoutGlobalScopes()->find($this->quiz->theme ?: 3); + $this->theme =$this->quiz->getTheme(); $this->compilePath = protected_path('quiz/compile/' . $this->quiz->id); $this->dest = $dest; $this->forceScorm = $forceScorm; @@ -69,20 +69,7 @@ class QuizCompiler extends Base protected function writeStyles() { // Main texts color - $this->sassVariables['texts-color'] = $this->theme->textsColor; - if ($this->theme->textsColor == 'auto' || !$this->theme->textsColor) { - // IF auto mode, check between black and white which have the biggest distance (i.e. most contrast) with neutralColor - $neutral = new Color($this->theme->neutralColor); - $black = new Color('#000000'); - $white = new Color('#ffffff'); - $distBlack = $neutral->distance($black); - $distWhite = $neutral->distance($white); - if ($distWhite > $distBlack) { - $this->sassVariables['texts-color'] = '#ffffff'; - } else { - $this->sassVariables['texts-color'] = '#000000'; - } - } + $this->sassVariables['texts-color'] = $this->theme->getTextsColor(); // Font $this->sassVariables['font'] = $this->_font($this->theme->font); // Colors diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPreviewOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPreviewOperation.php index 62d27f677..b799f88ea 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPreviewOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPreviewOperation.php @@ -38,13 +38,33 @@ trait FluidbookPreviewOperation $tcolor = $scolor; } + return $this->_compileScreen( + $title, $url, + __('Compilation du fluidbook en cours'), + __('Cette étape ne sera pas nécessaire lorsque le fluidbook sera installé sur son emplacement définitif'), + $bgcolor->toCSS(), + $tcolor->toCSS(), + $lcolor->toCSS(), + $scolor->toCSS() + ); + + } + + protected function _compileScreen($title, $url, $messageTitle, $messageText, $backgroundColor, $messageColor, $loaderBackgroundColor = null, $loaderLineColor = null) + { + if (null === $loaderBackgroundColor) { + $loaderBackgroundColor = $messageColor; + } + if (null === $loaderLineColor) { + $loaderLineColor = $backgroundColor; + } $res = ''; $res .= ''; $res .= ''; if (!request('shortLoading', false)) { $res .= ''; - $res .= '