]> _ Git - bonaquiz.git/commitdiff
WIP #2647 @7:00
authornael <nael@cubedesigners.com>
Tue, 16 Apr 2019 15:59:49 +0000 (17:59 +0200)
committernael <nael@cubedesigners.com>
Tue, 16 Apr 2019 15:59:49 +0000 (17:59 +0200)
images/13-0.jpg [new file with mode: 0644]
images/13-1.jpg [new file with mode: 0644]
images/13-2.jpg [new file with mode: 0644]
images/13-3.jpg [new file with mode: 0644]
images/14-0.jpg [new file with mode: 0644]
images/14-1.jpg [new file with mode: 0644]
images/14-2.jpg [new file with mode: 0644]
images/14-3.jpg [new file with mode: 0644]
index.php
js/bonaquiz.js
style/style.sass

diff --git a/images/13-0.jpg b/images/13-0.jpg
new file mode 100644 (file)
index 0000000..255d457
Binary files /dev/null and b/images/13-0.jpg differ
diff --git a/images/13-1.jpg b/images/13-1.jpg
new file mode 100644 (file)
index 0000000..c6e7bbe
Binary files /dev/null and b/images/13-1.jpg differ
diff --git a/images/13-2.jpg b/images/13-2.jpg
new file mode 100644 (file)
index 0000000..17af160
Binary files /dev/null and b/images/13-2.jpg differ
diff --git a/images/13-3.jpg b/images/13-3.jpg
new file mode 100644 (file)
index 0000000..1d9b385
Binary files /dev/null and b/images/13-3.jpg differ
diff --git a/images/14-0.jpg b/images/14-0.jpg
new file mode 100644 (file)
index 0000000..91643f7
Binary files /dev/null and b/images/14-0.jpg differ
diff --git a/images/14-1.jpg b/images/14-1.jpg
new file mode 100644 (file)
index 0000000..4ee8b59
Binary files /dev/null and b/images/14-1.jpg differ
diff --git a/images/14-2.jpg b/images/14-2.jpg
new file mode 100644 (file)
index 0000000..7788c00
Binary files /dev/null and b/images/14-2.jpg differ
diff --git a/images/14-3.jpg b/images/14-3.jpg
new file mode 100644 (file)
index 0000000..44ffa01
Binary files /dev/null and b/images/14-3.jpg differ
index 77d6b34cf96c1ce678c27584c04b4d6398138c84..b9b1f0c4f459fb4ed347256f2c52cd8b4f530b64 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,5 +1,5 @@
 <?php
-$question = [
+$questions = [
     ['id' => 1,
         'type' => 'text',
         'label' => 'What kind of business was Bona founder Wilhelm Edner running when he started to sell  floor wax?',
@@ -155,7 +155,7 @@ $question = [
     <title>The Bona 100-year anniversary quiz</title>
     <link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="style/style.css?j=<?php echo time(); ?>">
-    <script>var nbquestions =<?php echo count($question)?>;</script>
+    <script>var nbquestions =<?php echo count($questions)?>;</script>
     <script>let scoreValue;</script>
 </head>
 <body>
@@ -176,133 +176,16 @@ $question = [
 
     <!-- **************************************** SECTION QUESTION 1 ******************************* -->
     <?php
-    for ($i = 0; $i < count($question); $i++) {
-        if ($question[$i]['type'] === 'text') {
-            echo '
-                    <div class="section data" data-section="home" data-question="' . $question[$i]['id'] . '" >
-                        <section class="home questions ">
-                            <h4 id="questionNumber">Question ' . $question[$i]['id'] . '/' . count($question) . '</h4>
-                            <h4 id="questionAsk">' . $question[$i]['label'] . '</h4>
-                            <ul>';
-            foreach ($question[$i]['choices'] as $key => $value) {
-
-                $number = $key;
-                $num = $number + 65;
-
-                $score = 0;
 
-                $correct = $question[$i]['correct'] - 1;
+    $question_count = count($questions);
 
-                if ($correct === $key) {
-                    $score = 1;
-                }
-                echo '<a class="btn-next value" href="#" data-score="' . $score . '">';
+    foreach ($questions as $question) {
 
-                echo '
-                                <li class="questions__list">
-                                    <div class="questions__contain">
-                                        <div class="questions__list--circle">
-                                            <span class="questions__list--letter">' . chr($num) . '</span>
-                                        </div>
-                                        <span class="questions__list--text" >' . $value . '</span>
-                                    </div>
-                                </li>
-                                </a>';
-            }
-            echo '
-                            </ul>
-                        </section>
-                    </div>';
-            $v = $question[$i]['correct'] - 1;
-            $answer = $question[$i]['choices'][$v];
-            $letter = $question[$i]['correct'] + 64;
-            echo '
-
-                    <div class="section">
-                        <section class="home questions ">
-                            <h4 id="questionNumber">Question ' . $question[$i]['id'] . '/' . count($question) . '</h4>
-                            <h4 id="questionAsk">' . $question[$i]['label'] . '</h4>
-                            <span class="correctInfo">Correct answer : </span>
-                            <ul style="display: block">
-                                <li class="questions__list correctAnswer">
-                                    <div class="questions__contain">
-                                        <div class="questions__list--circle">
-                                            <span class="questions__list--letter">' . chr($letter) . '</span>
-                                        </div>
-                                        <span class="questions__list--text">' . $answer . '</span>
-                                    </div>
-                                </li>
-                            </ul>
+        //DISABLE text Qs
+        if ($question['type'] === 'text') continue;
 
-                            <p class="response">' . $question[$i]['explaination'] . '</p>
-
-                            <a href="#" class="button btn-next next" >Next</a>
-
-                            <!--<div class="progressbar"></div>-->
-                        </section>
-                    </div>';
-        } else {
-            echo '
-                    <div class=" section data" data-question="' . $question[$i]['id'] . '">
-                        <section class="home questions " data-section="home" >
-                            <h4 id="questionNumber">Question ' . $question[$i]['id'] . '/' . count($question) . '</h4>
-
-                            <h4 id="questionAsk">' . $question[$i]['label'] . '</h4>
-                            <ul class="circleContainer">';
-
-            for ($z = 0; $z < $question[$i]['imagesnb']; $z++) {
-                $numb = $z;
-                $num = $numb + 65;
-//                if ($z % 2 == 0) // pair
-//                {
-//                    echo '<span>';
-//                }
-                $score = 0;
-
-                $correct = $question[$i]['correct'];
-                $imgCorrect = $z + 1;
-
-                if ($correct === $imgCorrect) {
-                    $score = 1;
-                }
-                echo '<li data-score="' . $score . '" class="questionsCircle btn-next value" style="background-image: url(\'images/' . $question[$i]['id'] . '-' . $imgCorrect . '.jpg\')">
-                            <div class="questionsCircle__container">
-                                <span class="questionsCircle__container--letter">' . chr($num) . '</span>
-                            </div>
-                        </li>';
-
-//                if ($z % 2 == 1) // impair
-//                {
-//                    echo '</span>';
-//                }
-            }
-            echo '</ul>
-                                    <!--<div class="progressbar"></div>-->
-                        </section>
-                    </div>';
-            // reponse question img
-            $letter = $question[$i]['correct'] + 64;
-            echo '
-                    <div class="section">
-                        <section class="questions" >
-                            <h4 id="questionNumber">Question ' . $question[$i]['id'] . '/' . count($question) . '</h4>
-                            <h4 id="questionAsk">' . $question[$i]['label'] . '</h4>
-
-                            <span class="correctInfo">Correct answer : </span>
-
-                            <ul class="circleContainer" style="display: block">
-                                <span>
-                                    <li class="questionsCircle answerCircle" style="background-image: url(\'images/' . $question[$i]['id'] . '-' . $imgCorrect . '.jpg\')">
-                                        <div class="questionsCircle__container">
-                                            <span class="questionsCircle__container--letter">' . chr($letter) . '</span>
-                                        </div>
-                                    </li>
-                                </span>
-                            </ul>
-                            <a href="#" class="btn-next button next">Next</a>
-                        </section>
-                </div>';
-        }
+        displayQuestion($question, $question_count);
+        displayAnswer($question, $question_count);
     }
 
     ?>
@@ -318,7 +201,7 @@ $question = [
                 <div class="borderScore">
                     <div class="score">
                         <div class="inner">
-                            <span id="finalScore"></span>/<?= count($question) ?>
+                            <span id="finalScore"></span>/<?= count($questions) ?>
                         </div>
                     </div>
                 </div>
@@ -338,4 +221,130 @@ $question = [
 <script type="text/javascript" src="js/RaphaelPlugin.min.js"></script>
 <script type="text/javascript" src="js/bonaquiz.js?j=<?php echo time(); ?>"></script>
 </body>
-</html>
\ No newline at end of file
+</html>
+
+<?php
+
+
+function displayQuestion($question, $question_count) {
+
+    $correct_index = $question['correct'] - 1;
+
+    echo '
+            <div class="section data" data-section="home" data-question="' . $question['id'] . '" >
+                <section class="questions">
+                    <h4 id="questionNumber">Question ' . $question['id'] . '/' . $question_count . '</h4>
+                    <h4 id="questionAsk">' . $question['label'] . '</h4>';
+
+    if ($question['type'] === 'text') {
+
+        echo '<ul>';
+
+        foreach ($question['choices'] as $index => $value) {
+
+            if ($correct_index === $index) {
+                $score = 1;
+            } else {
+                $score = 0;
+            }
+
+            echo '
+                    <li class="questions__list btn-next value"  data-score="' . $score . '">
+                        <div class="questions__contain">
+                            <div class="questions__list--circle">
+                                <span class="questions__list--letter">' . numberToLetter($index) . '</span>
+                            </div>
+                            <span class="questions__list--text" >' . $value . '</span>
+                        </div>
+                    </li>';
+        }
+
+    } else {
+
+        echo '<ul class="circleContainer">';
+
+        for ($image_id = 0; $image_id < $question['imagesnb']; $image_id++) {
+
+            if ($correct_index === $image_id) {
+                $score = 1;
+            } else {
+                $score = 0;
+            }
+
+            echo '<li data-score="' . $score . '" class="questionsCircle btn-next value" style="background-image: url(\'images/' . $question['id'] . '-' . $image_id . '.jpg\')">
+                    <div class="questionsCircle__container">
+                        <span class="questionsCircle__container--letter">' . numberToLetter($image_id) . '</span>
+                    </div>
+                  </li>';
+
+        }
+
+    }
+
+    echo '
+                    </ul>
+                </section>
+            </div>';
+
+}
+
+
+function displayAnswer($question, $question_count) {
+    $correct_index = $question['correct'] - 1;
+
+    echo '
+         <div class="section">
+            <section class="questions">
+                <h4 id="questionNumber">Question ' . $question['id'] . '/' .$question_count . '</h4>
+                <h4 id="questionAsk">' . $question['label'] . '</h4>
+                <span class="correctInfo">Correct answer:</span>';
+
+                if ($question['type'] === 'text') {
+
+                    $answer = $question['choices'][$correct_index];
+
+                    echo '<ul style="display: block">
+                        <li class="questions__list correctAnswer">
+                            <div class="questions__contain">
+                                <div class="questions__list--circle">
+                                    <span class="questions__list--letter">' . numberToLetter($correct_index) . '</span>
+                                </div>
+                                <span class="questions__list--text">' . $answer . '</span>
+                            </div>
+                        </li>
+                    </ul>
+    
+                    <p class="response">' . $question['explaination'] . '</p>';
+
+                } else {
+
+                    echo '<ul class="circleContainer" style="display: block">
+                                <span>
+                                    <li class="questionsCircle answerCircle" style="background-image: url(images/' . $question['id'] . '-' . $correct_index . '.jpg)">
+                                        <div class="questionsCircle__container">
+                                            <span class="questionsCircle__container--letter">' . numberToLetter($correct_index) . '</span>
+                                        </div>
+                                    </li>
+                                </span>
+                            </ul>';
+                }
+
+                echo '<a href="#" class="button btn-next next" >Next</a>
+
+                <!--<div class="progressbar"></div>-->
+            </section>
+        </div>';
+}
+
+
+/**
+ * Convert a number to a letter (0 => A, 1 => B etc)
+ * @param $number
+ * @return string
+ */
+function numberToLetter($number) {
+    return chr($number + 65);
+}
+
+
+?>
\ No newline at end of file
index 531d0060da3503a0805b8064d3e0b5cffb0a70f0..611d7e5d42f2269367b50571a59cddcd4f2563ad 100644 (file)
@@ -3,10 +3,11 @@ $(function () {
 
     $(window).on('orientationchange', function () {
         console.log('orientation');
+        resize();
 
         setTimeout(function () {
             resize()
-        }, 3000);
+        }, 200);
     });
 
     resize();
@@ -55,8 +56,8 @@ $('.value').on('click', function () {
     }
 
     // alert($(this).data('score'));
-    console.log(`Votre score est de : ${scoreValue}`);
-    $('#finalScore').html(`${scoreValue}`);
+    //console.log(`Votre score est de : ${scoreValue}`);
+    $('#finalScore').html(scoreValue);
     AfterTransition();
 });
 
@@ -111,7 +112,7 @@ function AfterTransition() {
         }
 
         updateAngle();
-        console.log(`Le rayon est: ${paperRadius}`);
+        // console.log(`Le rayon est: ${paperRadius}`);
         TweenMax.to(window, animationDuration, {
             angle: angleEnd,
             onUpdate: updateAngle,
@@ -181,8 +182,8 @@ function displayProgress() {
 
 // FUNCTION RESIZE CONTENT
 
-let breakpoint = 750, // Stop scaling the height below this width (let it scroll)
-    scaler = $('#container');
+let scaler = $('#container'),
+    progressBar = $('.progressbar');
 
 function resize() {
 
@@ -193,6 +194,7 @@ function resize() {
         sections = $('.section'),
         baseWidth, // = scaler.outerWidth(),
         baseHeight, // = scaler.outerHeight(),
+        gutter = 80, // space around the content
         scale,
         translateAmount;
 
@@ -200,85 +202,20 @@ function resize() {
     baseWidth = Math.max.apply(Math, sections.map(function(x) { return $(sections[x]).outerWidth(); }));
     baseHeight = Math.max.apply(Math, sections.map(function(x) { return $(sections[x]).outerHeight(); }));
 
+    baseWidth += gutter * 2;
+    baseHeight += gutter * 2;
+
     console.log(baseWidth, baseHeight);
 
-    //// background resize
-    // $("#background,#projector").css({width: ww, maxWidth: ww, minWidth: ww, height: wh, maxHeight: wh, minHeight: wh});
-    //
-    // var vs = $("section:visible");
-    // var home = vs.hasClass('home');
-    //
-    // var sh = vs.outerHeight();
-    // sh *= 1.1; // Margins
-    // if (home) {
-    //     sh *= 1.1;
-    // }
-    // var cssSection = {};
-    // cssSection.top = Math.max((wh - sh) / 2, wh * 0.05);
-    // if (home) {
-    //     $("#projector").css('bottom', Math.max(cssSection.top, wh * 0.05));
-    // }
-    /**************************************************************************/
     // Work out how much content needs to be scaled down, if at all
     scale = Math.min(1, ww / baseWidth, wh / baseHeight);
 
-    // Once we're below the breakpoint, only scale based on the width, not height
-    // if (ww < breakpoint) {
-    //     scale = Math.min(1, ww / baseWidth);
-    // }
-
     // When translating a scaled element, the translate value needs to be scaled (-50% / scale)
     translateAmount = (-50 / scale) + '%';
 
-    // Different translation needed when only scaling for width
-    // if (ww < breakpoint) {
-    //     scaler.css('transform', 'scale('+ scale +') translateX('+ translateAmount +')');
-    //     scaler.css('transform-origin', 'top');
-    //     scaler.css('top', 0);
-    // } else {
-        scaler.css('transform', 'scale('+ scale +') translate('+ translateAmount +', '+ translateAmount +')');
-    // }
-
-}
-
-
-
-
+    scaler.css('transform', 'scale('+ scale +') translateX('+ translateAmount +')');
+    progressBar.css('transform', 'scale('+ scale +') translateX('+ translateAmount +')');
+    progressBar.css('bottom', 45 * scale + 'px');
 
 
-//
-//
-// function resize() {
-//     var ww = $(window).outerWidth();
-//     var hh = $(window).outerHeight();
-//
-//     $("#background,#projector").css({width: ww, maxWidth: ww, minWidth: ww, height: hh, maxHeight: hh, minHeight: hh});
-//
-//     var vs = $("section:visible");
-//     var home = vs.hasClass('home');
-//     $("section:visible").css('font-size', 10);
-//     var sh = vs.outerHeight();
-//     sh *= 1.1; // Margins
-//     if (home) {
-//         sh *= 1.1;
-//     }
-//     console.log('resize', sh, hh);
-//     var cssSection = {};
-//     if (sh > hh) {
-//         var scale = hh / sh;
-//         console.log('scale', scale);
-//         $("section:visible").css('font-size', 10 * scale);
-//         sh = vs.outerHeight();
-//         if (home) {
-//             sh *= 1.1;
-//         }
-//     }
-//     cssSection.top = Math.max((hh - sh) / 2, hh * 0.05);
-//
-//     $("section:visible").css(cssSection);
-//
-//     if (home) {
-//         $("#projector").css('bottom', Math.max(cssSection.top, hh * 0.05));
-//     }
-// }
-//
+}
\ No newline at end of file
index ffda9d8ee99358593a42f477a10980a070ed8d6d..cd00930f0a5505b239331fce5c31b24209886202 100644 (file)
@@ -6,6 +6,10 @@ $base-font-size: 16 // Default
 @function rem($pixels, $context: $base-font-size)
   @return #{$pixels/$context}rem
 
+@mixin breakpoint()
+  @media (max-aspect-ratio: 11/10)
+    @content
+
 *
   margin: 0
   padding: 0
@@ -34,22 +38,21 @@ body
   max-width: 100%
   opacity: 0
   transition: opacity 500ms
+
   &.loaded
     opacity: 1
 
+  //@include breakpoint
+  //  font-size: rem(20)
+
 #container
-  //min-height: 100%
-  //height: 100%
-  //width: 100%
-  //min-width: 100%
-  //overflow-x: hidden
-  //overflow-y: auto
   padding: 80px
   position: absolute
   z-index: 2
-  top: 50%
+  top: 0
   left: 50%
-  transform: translate(-50%, -50%)
+  transform: translateX(-50%)
+  transform-origin: top center
   //width: 100%
 
 .active
@@ -60,8 +63,8 @@ body
   //height: 100%
   width: 1500px
 
-  @media (max-width: 750px)
-    width: 750px
+  @include breakpoint
+    width: 760px
 
 a.btn-next
   text-decoration: none
@@ -96,17 +99,17 @@ section
     background-color: $green
     border-radius: 1.25em
     border: 0
-    padding: 0.54em 1.96em
-    margin-top: 2.14em
+    padding: 0.5em 2em
+    margin-top: 1em
     cursor: pointer
     text-decoration: none
 
   .logo
     display: block
-    width: 26em
+    width: 400px
     text-align: center
     margin: 0 auto
-    margin-top: 10em
+    margin-top: 115px
 
 #background
   position: absolute
@@ -127,6 +130,11 @@ section
     background-size: auto 100%
     opacity: 0.5
 
+    @include breakpoint
+      background-size: auto 50%
+      bottom: 10%
+
+
   &[data-section="home"]
     background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #000000 100%)
 
@@ -149,10 +157,10 @@ section
       top: 1.250em
 
   #questionAsk
-    margin: 4em auto 2em auto
-    max-width: 800px
-    @media (max-width: 750px)
-      max-width: 1200px
+    margin: 3.2em auto 2em auto
+    max-width: 840px
+    @include breakpoint
+      max-width: 610px
 
   ul
     list-style: none
@@ -160,13 +168,12 @@ section
 
   &__list
     position: relative
-    max-width: 40em
-    min-width: 30em
-    height: 3.33em
+    width: 650px
+    height: 125px
     background: white
     margin: 0 auto
     border-radius: 5.25em
-    margin-bottom: 2em
+    margin-bottom: 34px
     cursor: pointer
     transition: 400ms all ease
     font-size: rem(30)
@@ -177,6 +184,7 @@ section
       padding-right: 0.5em
       text-align: left
       width: 85%
+      font-size: 0.9em
 
     &--letter
       color: white
@@ -189,11 +197,12 @@ section
       background: #669933
       border-radius: 50%
       position: relative
-      left: 2.2em
+      left: 0.8em
       display: flex
       justify-content: center
       align-items: center
       z-index: 55
+      font-size: 1.2em
 
 .questions__list:hover
   background: $green
@@ -222,11 +231,10 @@ section
   width: 90% // for smaller screens
   margin: 0 auto
   position: fixed
-  bottom: 3em
-  height: 0.75em
+  bottom: 45px // Initial value - actual value handled by JS resize function
+  height: 9px
   background: white
-  left: 0
-  right: 0
+  left: 50%
   display: none
 
   &-value
@@ -240,7 +248,7 @@ section
   font-size: rem(30)
 
 .correctAnswer
-  margin-top: 2em
+  margin-top: 1em
   background: $green
 
   .questions__list--circle
@@ -254,8 +262,11 @@ section
 
 .response
   font-size: rem(30)
-  max-width: 27em
-  margin: 2em auto 0 auto
+  max-width: 840px
+  margin: 1em auto 0 auto
+
+  @include breakpoint
+    max-width: 610px
 
 //section.questions a.button.next
 //  font-size: rem(44)
@@ -286,7 +297,7 @@ section
     border-radius: 50%
     position: relative
     background-size: cover
-    border: 3px solid white
+    border: 5px solid white
 
     &__container
       display: flex
@@ -298,17 +309,15 @@ section
       background: $green
       border-radius: 50%
       position: absolute
-      left: 1em
-      top: 1em
+      left: 0.3em
+      top: 0.5em
       color: white
       &--letter
         font-size: rem(25)
 
 .answerCircle
   border: solid 3px $green !important
-  transform: scale(1.2)
-  margin: 4em !important
-
+  margin-top: 50px
 #ResultsDesc
   margin: 2em 0
 
@@ -324,20 +333,20 @@ section
 
 .borderScore
   border-radius: 50%
-  width: 10em
-  height: 10em
+  width: 334px
+  height: 334px
   background-color: rgba(255, 255, 255, 0.5)
   margin: 0 auto
   display: flex
   justify-content: center
   align-items: center
-  padding: 15em
+  //padding: 15em
 
 .score
   background: white
-  width: 2em
-  height: 2em
-  padding: 12em
+  width: 284px
+  height: 284px
+  //padding: 12em
   border-radius: 50%
   display: flex
   justify-content: center
@@ -348,26 +357,10 @@ section
     color: $darkblue
     font-size: rem(30)
 
+.home
+  @include breakpoint
+    width: 500px
+    padding-bottom: 11% // Buffer to stop logo going below projector bg graphic at certain screen ratios
 
-@media only screen and (max-width: 529px)
-  #background #projector
-    background-size: 150% auto
-  .circleContainer
-    span
-      .questionsCircle
-        width: 0.25em
-        height: 0.25em
-        padding: 8em
-
-        &__container
-          left: -1em
-
-
-
-
-.tinyscreen #orientationWarning
-  position: absolute
-  background-color: #fc0
-  width: 100vw
-  height: 100vh
-  z-index: 99
\ No newline at end of file
+    h2
+      font-size: rem(50)
\ No newline at end of file