function testdetail($testid = 0) { save_url(); $user = check_login12(1, 2); if ($this->input->post('submit_rs')) { redirect(base_url()); } $data = array('user' => $user, 'meta_title' => 'Test Detail'); $test = $this->mtest->get_test_detail($testid); if (!$test) { $data['error'] = 'Không có đề thi trong hệ thống'; $data['template'] = 'home/notify'; $this->load->view('home/frontend/layouts/home', isset($data) ? $data : NULL); return; } $data['test'] = $test; $data['test_info'] = $this->mtest->get_test_info($testid); if ($this->input->post('submit')) { $result['answer'] = $this->input->post('answer'); $result['test'] = $data['test']; $responses = array("userid" => $user['id'], "testid" => $testid); $this->result($result, $responses); return; } else { $data['template'] = 'home/testdetail'; $this->load->view('home/frontend/layouts/home', isset($data) ? $data : NULL); } }
function edit() { save_url(); // Luu current_url vao session $user = check_login12(1, 2); $data = array('user' => $user, 'meta_title' => 'Manage Profile', 'template' => 'home/edit'); $user_info = $this->mprofile->search_user($user['id']); if (!$user_info) { $data['error'] = 'User not found in database.'; $data['template'] = 'home/notify'; $this->load->view('home/frontend/layouts/home', isset($data) ? $data : NULL); return; } $data['user_info'] = $user_info; if ($this->input->post('submit')) { profile(); if ($this->form_validation->run() == TRUE) { $u_info = info_user(); $u_info['id'] = $user['id']; $this->mprofile->updateuser($u_info); $data['success'] = 'Cập nhật thông tin tài khoản thành công'; $data['template'] = 'home/notify'; $this->load->view('home/frontend/layouts/home', isset($data) ? $data : NULL); return; } } $this->load->view('home/frontend/layouts/home', isset($data) ? $data : NULL); }