/** * This transform function performs the actual save (if any) of the transformer data and is called after * the saving of the data in the source model. * * @param \MUtil_Model_ModelAbstract $model The parent model * @param array $row Array containing row * @return array Row array containing (optionally) transformed data */ public function transformRowAfterSave(\MUtil_Model_ModelAbstract $model, array $row) { $token = $this->source->getToken($row['gto_id_token']); $answers = $row; $surveyId = $this->survey->getSurveyId(); if ($this->source->setRawTokenAnswers($token, $answers, $surveyId)) { $this->changed++; } // No changes return $row; }
/** * Get a name for the view * * @param \Gems_Tracker_Survey $survey * @return string */ protected function getViewName(\Gems_Tracker_Survey $survey) { return 'T' . $survey->getSurveyId(); }
/** * Returns a model for the survey answers * * @param \Gems_Tracker_Survey $survey * @param string $language Optional (ISO) language string * @param string $sourceSurveyId Optional Survey Id used by source * @return \MUtil_Model_ModelAbstract */ public function getSurveyAnswerModel(\Gems_Tracker_Survey $survey, $language = null, $sourceSurveyId = null) { if (null === $sourceSurveyId) { $sourceSurveyId = $this->_getSid($survey->getSurveyId()); } $surveyModel = $this->getSurvey($survey->getSurveyId(), $sourceSurveyId)->getModel(); $model = new \OpenRosa_Tracker_Source_OpenRosa_Model($survey, $this); $questionsList = $this->getQuestionList($language, $survey->getSurveyId(), $sourceSurveyId); foreach ($questionsList as $item => $question) { $allOptions = $surveyModel->get($item); $allowed = array_fill_keys(array('storageFormat', 'dateFormat', 'label', 'multiOptions', 'maxlength', 'type', 'itemDisplay', 'formatFunction'), 1); $options = array_intersect_key($allOptions, $allowed); $options['label'] = strip_tags($question); $options['survey_question'] = true; //Should also do something to get the better titles... $model->set($item, $options); } return $model; }