]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6300 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 27 Sep 2023 16:14:01 +0000 (18:14 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 27 Sep 2023 16:14:01 +0000 (18:14 +0200)
app/Elearning/QuizCompiler.php
app/Models/QuizTheme.php

index afa4f758badd59d299c991bf6c07f7788ea6cb19..8348f27cab1198dca493426a13c316f6775002a0 100644 (file)
@@ -19,10 +19,7 @@ use Cubist\Util\Files\Files;
 use Cubist\Util\Files\VirtualDirectory;
 use Cubist\Util\Graphics\Color;
 use Cubist\Util\Text;
-use Illuminate\Translation\Translator;
-use Psy\Output\Theme;
 use RyanChandler\Blade\Blade;
-use function PHPUnit\Framework\matches;
 
 class QuizCompiler extends Base
 {
@@ -147,6 +144,13 @@ class QuizCompiler extends Base
         // Fonts size:Line Height
         $this->sassVariables['fonts-size'] = "(14: 20px, 16: 22px, 20: 28px, 24: 35px)";
 
+        // fill areas
+        $this->sassVariables['intro-fill-area'] = $this->theme->introColor ?: 'transparent';
+        $this->sassVariables['outro-fill-area'] = $this->theme->outroColor ?: 'transparent';
+        $this->sassVariables['standard-fill-area'] = $this->theme->standardColor ?: 'transparent';
+        $this->sassVariables['drangandrop-area1-fill-area'] = $this->theme->draganddropArea1Color ?: 'transparent';
+        $this->sassVariables['drangandrop-area2-fill-area'] = $this->theme->draganddropArea2Color ?: 'transparent';
+
         // Main background
         $this->sassVariables['background-color'] = Color::colorToCSS($this->theme->backgroundColor);
         $this->sassVariables['background-custom'] = $this->theme->backgroundCustom ? 'true' : 'false';
@@ -252,6 +256,10 @@ class QuizCompiler extends Base
 
     protected function _escapeSassValue($value)
     {
+        $value = trim($value);
+        if (str_starts_with($value, 'rgb')) {
+            return $value;
+        }
         if (stristr($value, '.')) {
             return '"' . $value . '"';
         }
index 175065cd47e43c350b6f8e62c0fcdc0500d675c1..312248bdb410d7f358a19a49b176488b2550e1b7 100644 (file)
@@ -182,6 +182,7 @@ class QuizTheme extends ToolboxModel
             'nokColor' => (string)$quiz->nokColor,
             'logo' => hash_file('sha256', $logo),
             'banner' => hash_file('sha256', $banner),
+            'overlay' => (string)$quiz->overlay,
         ];
         $hash = hash('sha256', print_r($data, true));
         $theme = QuizTheme::withoutGlobalScopes()->where('hash', $hash)->first();
@@ -189,13 +190,16 @@ class QuizTheme extends ToolboxModel
             return $theme->id;
         }
 
+
         $theme = new QuizTheme();
         $theme->hash = $hash;
         $theme->name = $quiz->client . ' - ' . $quiz->title;
         $theme->mainColor = \Cubist\Util\Graphics\Color::colorToCSS($quiz->mainColor);
-        $theme->neutralColor = \Cubist\Util\Graphics\Color::colorToCSS('#333333');
         $theme->okColor = \Cubist\Util\Graphics\Color::colorToCSS($quiz->okColor);
         $theme->nokColor = \Cubist\Util\Graphics\Color::colorToCSS($quiz->nokColor);
+        $theme->introColor = 'transparent';
+        $theme->outroColor = $theme->standardColor = $theme->draganddropArea1Color = $theme->draganddropArea2Color = \Cubist\Util\Graphics\Color::colorToCSS($quiz->overlay);
+        $theme->neutralColor = \Cubist\Util\Graphics\Color::colorToCSS($quiz->overlay);
         $theme->backgroundColor = '#ffffff';
 
         $theme->owner = 5;
@@ -215,7 +219,6 @@ class QuizTheme extends ToolboxModel
         $tmp = Files::tempnam() . '.jpg';
         $blur = Files::tempnam() . '.jpg';
 
-
         $resizer = new Resizer();
         $resizer->loadImage($banner);
         $resizer->resize(1200, 680, true, true);
@@ -223,6 +226,8 @@ class QuizTheme extends ToolboxModel
         Imagemagick::blur($tmp, $blur);
         $theme->addMediaToField('backgroundImage', $blur);
 
+
+        $blur = Files::tempnam() . '.jpg';
         $resizer = new Resizer();
         $resizer->loadImage($banner);
         $resizer->resize(390, 844, true, true);
@@ -235,8 +240,6 @@ class QuizTheme extends ToolboxModel
         $theme->backgroundHorizontalAlignMobile = HorizontalAlign::CENTER;
         $theme->backgroundVerticalAlignMobile = VerticalAlign::MIDDLE;
 
-        $theme->introCustom = '0';
-
         $theme->save();
         return $theme->id;
     }