public function checkSex(RM_Anketa_Result_Object $obResult) { $obRespondent = $obResult->getRespondent(); return $obRespondent->sex == 2 ? TRUE : FALSE; }
/** * Creates (not save) anketa result answer object * * @param array post * @param RM_Anketa_Result_Object obResult * @param RM_Anketa_Entity_Answer obAnswer * @param RM_Anketa_Entity_Subanswer|NULL obSubanswer * @return RM_Anketa_Result_Answer **/ public function createResultAnswer($post, RM_Anketa_Result_Object $obResult, RM_Anketa_Entity_Answer $obAnswer, RM_Anketa_Entity_Subanswer $obSubanswer = NULL) { if ($obResult->getAnketa()->id() !== $obAnswer->getQuestion()->getAnketa()->id()) { throw new RM_Base_Exception_BadUsage(__METHOD__ . "(): Result and Answer objects belong to the different forms (anketa)."); } if (!is_null($obSubanswer) && $obAnswer->getQuestion()->id() !== $obSubanswer->getQuestion()->id()) { throw new RM_Base_Exception_BadUsage(__METHOD__ . "(): SubAnswer doesn't belong to the specified Question."); } $data = $this->_filterIncomingData('resultanswer', $post); $data['anketa_id'] = $obResult->getAnketa()->id(); $data['result_id'] = $obResult->id(); $data['respondent_id'] = $obResult->getRespondent()->getRespondentId(); $data['respondent_type'] = $obResult->getRespondent()->getRespondentType(); $data['question_id'] = $obAnswer->getQuestion()->id(); $data['answer_id'] = $obAnswer->id(); $data['subanswer_id'] = !is_null($obSubanswer) ? $obSubanswer->id() : NULL; $data['tag'] = $obAnswer->getQuestion()->generateTag(); return $this->_storages['resultanswer']->createObject($data); }