/** * prepare survey entry */ public function prepareSurveyEntry($survey_id, $answers, $customer_id) { if (!is_numeric($survey_id)) { return false; } if (!is_array($answers)) { msg("Answers isn't array", 'error'); return false; } $survey_entry = array(); $survey_entry['survey_id'] = $survey_id; $survey_entry['customer_id'] = $customer_id; //if GET params provided, use as relation_subject, othewise leave null (undefined) if ($relation_subject = $this->getRelationSubject()) { $survey_entry['relation_subject'] = $relation_subject; } $survey_entry['answers'] = array(); require_once 'models/education/education_survey_question.php'; $Question = new education_survey_question(); foreach ($answers as $question_id => $answer_value) { if ($question_detail = $Question->getDetail($question_id)) { $answer = array(); $answer['question_id'] = $question_id; /** * for text, range and file type save as value */ if ($question_detail['type'] == 'text' || $question_detail['type'] == 'file' || $question_detail['type'] == 'range') { $answer['value'] = $answer_value; } else { $answer['question_answer_id'] = $answer_value; } $survey_entry['answers'][] = $answer; } } return $survey_entry; }
/** * list questions */ public function getFullQuestionsList($survey_id) { if (!is_numeric($survey_id)) { msg("Survey ID is not numeric", 'error'); return false; } require_once 'models/education/education_survey_question.php'; $SurveyQuestion = new education_survey_question(); $question_list = $SurveyQuestion->listQuestions($survey_id); return $question_list; }