public static function ajaxAddInToplist($data)
 {
     // workaround ...
     $_POST = $_POST['data'];
     $ctn = new WpProQuiz_Controller_Toplist();
     $quizId = isset($data['quizId']) ? $data['quizId'] : 0;
     $prefix = !empty($data['prefix']) ? trim($data['prefix']) : '';
     $quizMapper = new WpProQuiz_Model_QuizMapper();
     $quiz = $quizMapper->fetch($quizId);
     $r = $ctn->handleAddInToplist($quiz);
     if ($quiz->isToplistActivated() && $quiz->isToplistDataCaptcha() && get_current_user_id() == 0) {
         $captcha = WpProQuiz_Helper_Captcha::getInstance();
         if ($captcha->isSupported()) {
             $captcha->remove($prefix);
             $captcha->cleanup();
             if ($r !== true) {
                 $r['captcha']['img'] = WPPROQUIZ_CAPTCHA_URL . '/' . $captcha->createImage();
                 $r['captcha']['code'] = $captcha->getPrefix();
             }
         }
     }
     if ($r === true) {
         $r = array('text' => __('You signed up successfully.', 'wp-pro-quiz'), 'clear' => true);
     }
     return json_encode($r);
 }
 public static function ajaxLoadQuizData($data)
 {
     $quizId = (int) $data['quizId'];
     $quizMapper = new WpProQuiz_Model_QuizMapper();
     $toplistController = new WpProQuiz_Controller_Toplist();
     $statisticController = new WpProQuiz_Controller_Statistics();
     $quiz = $quizMapper->fetch($quizId);
     $data = array();
     if ($quiz === null || $quiz->getId() <= 0) {
         return json_encode(array());
     }
     $data['toplist'] = $toplistController->getAddToplist($quiz);
     $data['averageResult'] = $statisticController->getAverageResult($quizId);
     return json_encode($data);
 }
 public function addInToplist()
 {
     $t = new WpProQuiz_Controller_Toplist();
     $t->addInToplist();
     exit;
 }
 public function loadQuizData()
 {
     $quizId = (int) $_POST['quizId'];
     $userId = get_current_user_id();
     $quizMapper = new WpProQuiz_Model_QuizMapper();
     $toplistController = new WpProQuiz_Controller_Toplist();
     $statisticController = new WpProQuiz_Controller_Statistics();
     $quiz = $quizMapper->fetch($quizId);
     $data = array();
     if ($quiz === null || $quiz->getId() <= 0) {
         return array();
     }
     $data['toplist'] = $toplistController->getAddToplist($quiz);
     $data['averageResult'] = $statisticController->getAverageResult($quizId);
     return $data;
 }