public function getAverageResult($quizId) { $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper(); $result = $statisticRefMapper->fetchFrontAvg($quizId); if (isset($result['g_points']) && $result['g_points']) { return round(100 * $result['points'] / $result['g_points'], 2); } return 0; }
public function getAverageResult($quizId) { $statisticRefMapper = new WpProQuiz_Model_StatisticRefMapper(); // $quizMapper = new WpProQuiz_Model_QuizMapper(); // $r = $statisticRefMapper->fetchByQuiz($quizId); // $maxPoints = $quizMapper->sumQuestionPoints($quizId); // $sumQuestion = $quizMapper->countQuestion($quizId); // if($r['count'] > 0) { // return round((100 * $r['points'] / ($r['count'] * $maxPoints / $sumQuestion)), 2); // } $result = $statisticRefMapper->fetchFrontAvg($quizId); if (isset($result['g_points']) && $result['g_points']) { return round(100 * $result['points'] / $result['g_points'], 2); } return 0; }