Exemple #1
0
 /**
  * Try and match a score to an answer
  *
  * @param \Jazzee\Entity\Answer
  */
 public function matchScore(\Jazzee\Entity\Answer $answer)
 {
     if ($answer->getPageStatus() == self::SKIPPED) {
         return;
     }
     if (!is_null($answer->getGREScore()) and !is_null($answer->getTOEFLScore())) {
         return;
         //we already have a match
     }
     $testType = $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_TYPE)->getJazzeeElement()->displayValue($answer);
     $registrationNumber = $this->_applicationPage->getPage()->getElementByFixedId(self::FID_REGISTRATION_NUMBER)->getJazzeeElement()->displayValue($answer);
     $testDate = $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_DATE)->getJazzeeElement()->formValue($answer);
     $testMonth = date('m', strtotime($testDate));
     $testYear = date('Y', strtotime($testDate));
     $parameters = array('registrationNumber' => $registrationNumber, 'testMonth' => $testMonth, 'testYear' => $testYear);
     switch ($testType) {
         case 'GRE/GRE Subject':
             $score = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\GREScore')->findOneBy($parameters);
             if ($score) {
                 $answer->setGreScore($score);
             }
             break;
         case 'TOEFL':
             $score = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\TOEFLScore')->findOneBy($parameters);
             if ($score) {
                 $answer->setTOEFLScore($score);
             }
             break;
         default:
             throw new \Jazzee\Exception("Unknown test type: {$testType} when trying to match a score");
     }
 }