public static function exec() { //get score data from db $scDAO = new StudentScoreDAO(); $studentScoreList = $scDAO->getStudentScoreAll(); //var_dump($studentScoreList); //count weighted grade $scoreFactory = ScoreFactory::getStudentScoreFactory(); $result = $scoreFactory->countIndividualWeightedSum($studentScoreList); //count individual sum var_dump($result); }
/** * @param Array $studentScoreList : class no. * @return Array */ public function countIndividualWeightedScore(&$studentScoreList) { $currentWeightFactory = null; foreach ($studentScoreList as $index => &$row) { $currentWeightFactory = ScoreFactory::getWeightFactory($row['cno']); $row['weightedGrade'] = $currentWeightFactory->countWeightedScore((int) $row['grade']); } return $studentScoreList; }