/** * Trigger when player finishes a Trivia Quiz * Can be used using the local parameters instead of ajax $_POST * @return [type] [description] */ public static function getTrueFalseAppreciation($quizId = NULL, $score = NULL) { $local = false; if (!isset($_POST['score']) || !is_numeric($_POST['score']) || (!isset($_POST['quizId']) || !is_numeric($_POST['quizId']))) { if (!$quizId || !$score) { die; } else { $_POST['score'] = $score; $_POST['quizId'] = $quizId; $local = true; } } // Debug mode : generate virtual lag // sleep(2); $score = intval($_POST['score']); $quizId = intval($_POST['quizId']); $appreciation = WPVQAppreciation::getAppreciationByScore($quizId, $score); if ($appreciation == NULL) { return 0; // no appreciation set } $result = array('scoreCondition' => $appreciation->getScoreCondition(), 'appreciationContent' => do_shortcode(htmlspecialchars_decode(stripslashes($appreciation->getContent())))); if ($local) { return json_encode($result); } else { print json_encode($result); die; } }