title: Jquery Quiz using Json
body: <p>I've found a <a href="https://github.com/Matt-Webb/jquery-quiz-using-json" rel="nofollow">script</a> that converts json file into quiz using jquery.</p>
  
  <p>Unfortunately, this script has a bug which is also posted here: <a href="https://github.com/Matt-Webb/jquery-quiz-using-json/issues/1" rel="nofollow">When one infoMode is false the quiz calculation is incorrect. Fix required.</a></p>
  
  <p>Example JSON:</p>
  
  <pre><code>{
     "question": "How old is Madonna?",
              "includeInfo": true,
              "info": "Madonna Louise Ciccone is an American singer, songwriter, actress, and businesswoman.",
              "answers": [
                  {
                      "answer": "50",
                      "score": 0
                  },
                  {
                      "answer": "54",
                      "score": 0
                  },
                  {
                      "answer": "56",
                      "score": 5
                  }
              ]
  }
  </code></pre>
  
  <p>The problem with this script is if <strong>includeInfo</strong> is set in false, the scoring is not accurate (score is getting equal to zero)</p>
  
  <p>I have here my two JSON, same data but includeInfo is different:</p>
  
  <ul>
  <li><a href="https://jsfiddle.net/t4p8x02b/28/" rel="nofollow">[JSFiddle]</a> includeInfo is false: <a href="https://api.myjson.com/bins/3iz33" rel="nofollow">https://api.myjson.com/bins/3iz33</a></li>
  <li><a href="https://jsfiddle.net/t4p8x02b/29/" rel="nofollow">[JSFiddle]</a> includeInfo is true: <a href="https://api.myjson.com/bins/3lbyn" rel="nofollow">https://api.myjson.com/bins/3lbyn</a></li>
  </ul>
  
  <p>When includeInfo is enabled, the scoring are incrementing. When includeInfo is disabled, score gets only zero.</p>
  
  <blockquote>
    <p>Here is the main iteration routine for the quiz which establishes
    whether or not we are displaying a information box to the user after
    the question has been answered.</p>
  </blockquote>
  
  <pre><code> $(data).each(function(index, object) {
  
       $(object.questions).each(function(index, object) {
           if (infoMode) {
               if (currentQuestion === index) {
                   infoMode = false;
                   complete = false;
                   content = infoHTML(object.info);
               }
           } else {
               if (currentQuestion === index) {
                   complete = false;
                   content = questionHTML(object.question, object.answers);
                   if (object.includeInfo) infoMode = true;
               }
           }
       });
   });
  </code></pre>
  
  <p>Anyone who can fix this problem? Thank you!</p>