title: Check if answer is correct MCQ
body: <p>Basically I am implementing a MCQ question. Everything is quite simple. Single form with all questions(pulled from DB) and options.</p>
  
  <p>I am stuck at the place where i need to check if the answers selected by the user are correct or not.</p>
  
  <p>There is a separate DB with the correct option corresponding with all questions
  like </p>
  
  <pre><code>array(q_1 =&gt; 3,
        q_2 =&gt; 2,
        q_3 =&gt; 4,
        ); //just an example
  </code></pre>
  
  <p>Code:</p>
  
  <p>This one is a failed attempt</p>
  
  <pre><code>public function checkAnswers($submition){
      //compare array with db right answers
          $correct = array();
      foreach ($submition as $attempt){
              $x = 0;
              if ($attempt == $this-&gt;_db-&gt;get('answers', array('q_id','=','1')){
                  $correct[$x] = "yes";
              }
  
      }
      return $correct;
      //$this-&gt;displayFinalScore()
  }
  </code></pre>
  
  <p>This is how i am getting the submittions</p>
  
  <pre><code>$score-&gt;checkAnswers(array(
                      'question1'     =&gt; Input::get('question1'),
                      'question2'     =&gt; Input::get('question2'),
                      'question3'     =&gt; Input::get('question3'),
                      'question4'     =&gt; Input::get('question4'),
                      'question5'     =&gt; Input::get('question5'),
                      'time'          =&gt; 300,
                  )));
  </code></pre>
  
  <p>Please tell me if you need more code for helping me before voting the question down.
  Thanks.</p>
  
  <p>Thanks for your help Andrew but i took a different approach and figured it out. Here is the answer:</p>
  
  <pre><code>    public function checkAnswers($submition){
      //compare array with db right answers
      $answers = $this-&gt;getAnswerKey();
      //$answer-&gt;q_id == question id &amp; $asnwer-&gt;option_id == correct answer
      //submittion for each question in loop is $submition[$question-&gt;q_id]
      foreach ($answers as $answer) {
  
          if($submition[$answer-&gt;q_id] == $answer-&gt;option_id){
              $this-&gt;score = $this-&gt;score + 4;
          }
      }
      $this-&gt;createEntry($this-&gt;score, $submition['user_id']);
  
  }
  </code></pre>
  
  <p>Hope this will help someone in need!</p>