Exemplo n.º 1
0
 public function survey_get($sm_id)
 {
     $this->load->model('tb_all_question');
     $this->load->model('tb_all_answer');
     $this->load->model('tb_survey_mapping');
     $this->load->model('tb_answer_style');
     $survey = $this->tb_survey_mapping->get($sm_id);
     $sm_order_column = explode(",", $survey->sm_order_column);
     if ($survey == NULL) {
         $this->response(array('Error' => 'Survey not found.'));
     }
     $questions = $this->tb_all_question->fetch_by_multiple_id($survey->sm_order_column);
     foreach ($questions as $question) {
         $question->answers = $this->tb_all_answer->get($question->aq_id);
         foreach ($question->answers as $answer) {
             $style = $this->tb_answer_style->get($answer->type);
             $answer->style = $style;
             $answerStyle = AnswerStyle::get($answer->style->as_identifier, $answer->aa_description, $answer->style->as_text_color);
             $answer->style->html = $answerStyle->html;
         }
     }
     ///SOERTING
     $sorted = array();
     foreach ($sm_order_column as $column) {
         foreach ($questions as $question) {
             if ($question->aq_id == $column) {
                 array_push($sorted, $question);
                 break;
             }
         }
     }
     $this->response($sorted);
 }
Exemplo n.º 2
0
 public function answers_get($aq_id_ref)
 {
     $this->load->model('tb_all_answer');
     $this->load->model('tb_answer_style');
     $result = $this->tb_all_answer->get($aq_id_ref);
     foreach ($result as $answer) {
         $answer->style = $this->tb_answer_style->get($answer->type);
         $answerStyle = AnswerStyle::get($answer->style->as_identifier, $answer->aa_description, $answer->style->as_text_color);
         $answer->style->html = $answerStyle->html;
     }
     $this->response($result, REST_Controller::HTTP_OK);
 }