]> _ Git - bonaquiz.git/commitdiff
WIP #2647 @7:00
authornael <nael@cubedesigners.com>
Mon, 8 Apr 2019 16:13:00 +0000 (18:13 +0200)
committernael <nael@cubedesigners.com>
Mon, 8 Apr 2019 16:13:00 +0000 (18:13 +0200)
index.php
js/bonaquiz.js
style/style.sass

index 4e3dee029164662c2d73ab6e088b872fdc9b26e7..107b27f5a05717f0df11a1591e0b0c7d3b35c0bc 100644 (file)
--- a/index.php
+++ b/index.php
@@ -145,7 +145,6 @@ $question = [
         'correct' => 2,
         'explaination' => 'The Bona product range expanded to include solutions for surfaces other than wood in 2018.',
     ],
-
 ];
 ?>
 <!DOCTYPE html>
@@ -159,12 +158,12 @@ $question = [
 
 </head>
 <body>
-<div id="container" data-section="home">
+<div id="container" data-section="home" >
     <div id="background"  >
         <div id="projector">
         </div>
 
-        <div class="active section">
+        <div class="active section " data-page="1">
             <section class="home">
                 <h1>The Bona 100&#8209;year</h1>
                 <h2>anniversary quiz</h2>
@@ -188,13 +187,13 @@ $question = [
                         $number = $e;
                         $num = $number + 65;
                     echo '
-                        <a class="btn-next ok" href="#">
+                        <a class="btn-next value" href="#" data-correct="'.$question[$i]['correct'].'">
                         <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">'.$question[$i]['choices'][$e] .'</span>
+                                <span class="questions__list--text" >'.$question[$i]['choices'][$e] .'</span>
                             </div>
                         </li>
                         </a>';
@@ -213,7 +212,7 @@ $question = [
                     <h4 id="questionNumber">Question '.$question[$i]['id'].'/'.count($question).'</h4>
                     <h4 id="questionAsk">'.$question[$i]['label'].'</h4>
                     <span class="correctInfo">Correct answer : </span>
-                    <ul>
+                    <ul style="display: block">
                         <li class="questions__list correctAnswer">
                             <div class="questions__contain">
                                 <div class="questions__list--circle">
@@ -235,7 +234,7 @@ $question = [
             else{
                 echo '   
             <div class=" section">
-                <section class="home questions">
+                <section class="home questions data"  data-section="home" data-question="'.$question[$i]['id'].'">
                     <h4 id="questionNumber">Question '.$question[$i]['id'].'/'.count($question).'</h4>
         
                     <h4 id="questionAsk">'.$question[$i]['label'].'</h4>
@@ -284,7 +283,7 @@ $question = [
     
                     <span class="correctInfo">Correct answer : </span>
     
-                    <ul class="circleContainer">
+                    <ul class="circleContainer" style="display: block">
                         <span>
                             <li class="questionsCircle answerCircle" style="background-image: url(\'images/4-min.jpg\')">
                                 <div class="questionsCircle__container">
@@ -294,15 +293,13 @@ $question = [
                         </span>
                     </ul>
                     <a href="#" class="btn-next button next">Next</a>
-                    <!--<div class="progressbar"></div>-->
                 </section>
         </div>';
             }
         }
-        //        var_dump(count($question));
         ?>
 
-        <div class="section">
+        <div class="section" data-page="1">
             <section class=" questions">
                 <h2 id="Results">Congrats</h2>
 
@@ -319,7 +316,10 @@ $question = [
                 <a href="#" class="button btn-next next">Try again</a>
             </section>
         </div>
-        <div class="progressbar"></div>
+
+        <div class="progressbar">
+            <div class="progressbar-value"></div>
+        </div>
     </div>
 </div>
 
index e13ad36c89290be555d4412a959dae2b27471901..a7f149efd0a0dec67f0c79a4b0d7c27148f848f8 100644 (file)
@@ -13,6 +13,7 @@ $('.start').on('click', function() {
     TweenMax.to('#background[data-section="home"]',3,{backgroundImage: 'linear-gradient(to bottom, rgba(0, 0, 0, 0) 100%, #000000 100%)' });
     TweenMax.to('#projector',0.5,{bottom: 0});
 });
+displayProgress();
 
 $('.btn-next').on('click', function() {
     const delay = 0.5;
@@ -21,8 +22,30 @@ $('.btn-next').on('click', function() {
     $(this).closest('div.section').delay(delay*1000).queue(function () {
         $(this).closest('div.section').removeClass('active')
     });
-    TweenMax.from($(this).closest('div.section').next(),delay,{x: '+=350px',opacity:0, delay:delay});
+    TweenMax.from($(this).closest('div.section').next(),delay,{x: '+=350px',opacity:0, delay:delay,
+        onComplete: displayProgress});
     $(this).closest('div.section').next().addClass('active');
+
+    let width = ($('.section:visible').attr("data-question") / 21) * 100;
+    $('.progressbar-value').css('width', width +'%');
+
+});
+
+function displayProgress() {
+    if ($('.section:visible').data("page") === 1) {
+        console.log($(this).attr('data-page'));
+        $('.progressbar').css('display', 'none');
+    }
+    else {
+        $('.progressbar').css('display', 'block');
+    }
+}
+
+// on recupere la valeur du click
+
+$('.value').on('click',function () {
+    alert($(this).data('correct'));
+
 });
 
 function resize() {
@@ -68,17 +91,4 @@ function resizeBar(){
         let scale = windowWidth / windowHeight;
         $(".progressbar").css('font-size', 10 * scale);
     }
-}
-
-
-
-$('#container .data').each(function (index) {
-    // let questionID= $(this).attr("data-question");
-
-    $(this).on('click', function() {
-        alert($(this).data("question"));
-    });
-    // console.log($('#container .data').eq(index).attr('data-question'));
-
-    // console.log(questionID);
-});
\ No newline at end of file
+}
\ No newline at end of file
index 5b41a76673348312140f3fb9e9fc5615971f3893..c908c1ffd7c594cb1b1e267ba0af3a5c178a5c6f 100644 (file)
@@ -114,6 +114,7 @@ section
     max-width: 31em
   ul
     list-style: none
+    display: inline-block
   &__list
     position: relative
     max-width: 40em
@@ -126,9 +127,9 @@ section
     cursor: pointer
     transition: 400ms all ease
     &--text
-      font-size: 2em
+      font-size: 1.9em
       color: $darkblue
-      padding-left: 1.2em
+      padding-left: 1.6em
       padding-right: 0.5em
       text-align: left
       width: 85%
@@ -142,7 +143,7 @@ section
       background: #669933
       border-radius: 50%
       position: relative
-      left: 1.2em
+      left: 2.2em
       display: flex
       justify-content: center
       align-items: center
@@ -173,10 +174,10 @@ section
   background: white
   left: 0
   right: 0
-  &::before
-    content: ''
+  display: none
+  &-value
     position: absolute
-    width: 10%
+    width: 0
     height: 100%
     background: $green
     left: 0