public function quizAction($params) { if(isset($params['start']) && $params['start'] == 'quiz'){ $this->createParticipant(); } if(!parent::checkToken($_SESSION['quiz'])) parent::redirect('', 'session_expire'); $displayContent = true; if(!empty($params['choice']) && parent::isAjax()){//data posted if(!$this->processStep($params, $_SESSION['quiz'])) parent::redirect('', 'session_expire'); //Increment page $_SESSION['quiz']['page'] += 1; //If end => check if there is need for extra question if($_SESSION['quiz']['page'] > 10){ $displayContent = false; if($this->goToExtraQuestion($_SESSION['quiz'])){ //Allow going to extra page $_SESSION['quiz']['extraPage'] = true; $link = 'extra'; }else{ //Allow going to form page $_SESSION['quiz']['formPage'] = true; $link = 'form'; } parent::set('link', $link); } } //Get question $question = $this->db->getQuestion($_SESSION['quiz']); parent::set('displayContent', $displayContent); parent::set('question', $question); parent::set('answers', $this->db->getAnswers($question['id'])); parent::set('page', $_SESSION['quiz']['page']); parent::set('token', $_SESSION['quiz']['token']); }