Exemplo n.º 1
0
 /**
  *
  * @param $questionId
  * @param $userId
  * @param $text
  * @return QUESTIONS_BOL_Answer
  */
 public function addAnswer($userId, $optionId)
 {
     $answer = $this->answerDao->findAnswer($userId, $optionId);
     if ($answer !== null) {
         return $answer;
     }
     $answer = new QUESTIONS_BOL_Answer();
     $answer->optionId = (int) $optionId;
     $answer->userId = (int) $userId;
     $answer->timeStamp = time();
     $this->answerDao->save($answer);
     OW::getEventManager()->trigger(new OW_Event(self::EVENT_ANSWER_ADDED, array('optionId' => $optionId, 'userId' => $userId, 'id' => $answer->id)));
     return $answer;
 }