Пример #1
0
 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();
 }
Пример #2
0
 /**
  * breaks down the elements of a brazilian date
  *
  * @param  string $data date in the format dd/mm/yyyy
  * @return array
  */
 function brazilian_date_explode($data)
 {
     $parts = explode("/", brazilian_datetime($data));
     $saida = array('day' => $parts[0], 'month' => $parts[1], 'year' => $parts[2]);
     return $saida;
 }