Пример #1
0
 public function getRelevantDataQuestions($gender, $age, $location)
 {
     $this->_rawGender = $gender;
     $this->_rawAge = $age;
     $this->_rawLocation = $location;
     $this->_state = $location->getState();
     $this->_stateCode = $this->getStateCode($this->_state);
     $this->_ageRange = $this->getAgeRange($this->_rawAge);
     if ($this->_stateCode && $this->_ageRange) {
         // Make sure we get some data
         if ($this->retrieveData()) {
             $correctAnswer = $this->getCorrectAnswer();
             if ($correctAnswer) {
                 $didYouKnowDataByAge = $this->getDidYouKnowDataByAge();
                 $question = new DynamicQuizQuestion($this->_questionIds[0]);
                 $question->setNumberFormattingPrefix("\$");
                 $question->setDescription("In 2013-14, what was the average salary for " . lcfirst($gender) . "s aged " . $this->_ageRange . " in " . $this->_state . "?");
                 $question->setCorrectAnswer($correctAnswer);
                 $question->setWrongAnswers($this->generateRandomWrongAnswersForNumber($correctAnswer, 40));
                 // Find the biggest earning group
                 $didYouKnowDataByAgeCopy = $didYouKnowDataByAge;
                 arsort($didYouKnowDataByAgeCopy);
                 $keys = array_keys($didYouKnowDataByAgeCopy);
                 $question->setDidYouKnowHtml("<p><strong>" . ucfirst($gender) . "s aged " . $keys[0] . " were the highest earning " . lcfirst($gender) . "s in " . $this->_state . " in 2013-14, earning an average of \$" . number_format($didYouKnowDataByAge[$keys[0]]) . " per taxable person.</strong></p>" . $question->generateBarChartHtml($didYouKnowDataByAge) . "<p>It's always a good time to take control of your Superannuation!</p>");
                 return array($question);
             }
         }
     }
     return array();
 }
Пример #2
0
 public function getRelevantDataQuestions($gender, $age, $location)
 {
     $this->_rawGender = $gender;
     $this->_rawAge = $age;
     // Make sure we get some data
     if ($this->retrieveData()) {
         $correctAnswer = $this->getCorrectAnswer();
         $didYouKnowData = $this->getDidYouKnowData();
         $question = new DynamicQuizQuestion($this->_questionIds[0]);
         $question->setDescription("How many " . lcfirst($gender) . "s aged " . $this->getAgeReadable($age) . " died of cancer in 2011?");
         $question->setCorrectAnswer($correctAnswer);
         $question->setWrongAnswers($this->generateRandomWrongAnswersForNumber($correctAnswer));
         $dataKeys = array_keys($this->_data);
         $dataValues = array_values($this->_data);
         $question->setDidYouKnowHtml("<p><strong>" . $dataKeys[0] . " is the biggest killer amongst " . lcfirst($gender) . "s aged " . $this->getAgeReadable($age) . ", killing " . number_format($dataValues[0]) . " " . lcfirst($gender) . "s in 2011.</strong></p>" . $question->generateBarChartHtml($didYouKnowData));
         return array($question);
     }
     return array();
 }
Пример #3
0
 public function getRelevantDataQuestions($gender, $age, $location)
 {
     $this->_rawGender = $gender;
     $this->_rawAge = $age;
     $this->_rawLocation = $location;
     $this->_genderId = AbsStatConstants::getGenderId($gender);
     $this->_ageId = AbsStatConstants::getAgeGroupId($age);
     $this->_ageRange = AbsStatConstants::getAgeRangeFromId($this->_ageId);
     $this->_stateId = AbsStatConstants::getStateId($location->getState());
     if ($this->retrieveData()) {
         $correctAnswer = $this->getCorrectAnswer();
         $didYouKnowData = $this->getDidYouKnowData();
         $question = new DynamicQuizQuestion($this->_questionIds[0]);
         $question->setDescription("How many " . lcfirst($gender) . "s aged " . $this->_ageRange . " are there in " . $location->getState() . "?");
         $question->setCorrectAnswer($correctAnswer);
         $question->setWrongAnswers($this->generateRandomWrongAnswersForNumber($correctAnswer));
         $totalMalePopulation = array_sum(array_values($didYouKnowData));
         $percentage = round($correctAnswer / $totalMalePopulation * 100, 1);
         $question->setDidYouKnowHtml("<p><strong>The " . $this->_ageRange . " age bracket makes up " . $percentage . "% of " . lcfirst($gender) . "s in " . $location->getState() . ".</strong></p>" . $question->generateBarChartHtml($didYouKnowData));
         return array($question);
     }
     return array();
 }