public function index() { if ($this->input->post()) { $data['optional'] = $this->input->post('optional'); $quiz_session_id = $this->quiz_session->insert($data); foreach ($this->input->post('answers') as $question_id => $answer) { unset($data); $data['quiz_session_id'] = $quiz_session_id; $data['question_id'] = $question_id; if (isset($answer['answer'])) { // Dicertive $data['answer'] = $answer['answer']; $this->response->insert($data); } else { // Multichoice $data['choice_id'] = $answer['choice']; $this->response->insert($data); } } exit; } $questions = $this->question->get_all(); foreach ($questions as $key => $q) { $questions[$key]['choices'] = $this->choice->get_all('', array('question_id' => $q['id'])); //$questions[$key]['type'] = $this->config->item('questions_type')[$q['type']]; } $this->data['questions'] = $questions; $this->layout = $this->config->item('ci_my_admin_template_dir_quiz') . "includes/layout"; $this->view = $this->config->item('ci_my_admin_template_dir_quiz') . "quiz_index"; parent::page(); }
public function index() { $this->data['respostas'] = $this->quiz_session->get_all(); $this->data['questions'] = $this->question->get_all(); $this->view = $this->config->item('ci_my_admin_template_dir_admin') . "dashboard"; parent::page(); }
public function index() { $sessions = $this->quiz_session->get_all(); $header = array(); $header[] = 'Sessão'; $header_cache = array(); foreach ($sessions as $session) { $responses = $this->response->get_all('', array('quiz_session_id' => $session['id'])); $row = array(); $row[] = $session['id']; foreach ($responses as $response) { // Set table header if (!in_array($response['question_id'], $header_cache)) { $question = $this->question->get($response['question_id']); $header[] = $question->label; $header_cache[] = $response['question_id']; } if (!empty($response['answer'])) { // Dicertive $row[] = $response['answer']; } elseif ($response['choice_id'] != NULL) { // Multichoice $choice = $this->choice->get($response['choice_id']); $row[] = $choice->label; } } $row[] = brazilian_datetime($session['date_created']); $this->table->add_row($row); } $header[] = 'Data'; $this->table->set_heading($header); $tmpl = array('table_open' => '<table class="table table-striped table-bordered table-hover" id="dataTables-example">'); $this->table->set_template($tmpl); $table = $this->table->generate(); $this->data['data']['sessions'] = $sessions; $this->data['data']['table'] = $table; $this->view = $this->config->item('ci_my_admin_template_dir_admin') . "results_index"; parent::page(); }
function view($id = NULL) { $this->element->get_by_id($id); if (!$this->element->exists() || !$this->element->can_view()) { $this->msg_error(lang('no_permission')); redirect($this->ctrlr_name); } $this->_set_title($this->element->__toString()); $this->_add_menu('left', 'view', $id); parent::page(); }