diff --git a/application/config/config.php b/application/config/config.php index 8dfc488..f168a7d 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = 'http://localhost/google_forms'; +$config['base_url'] = 'http://192.168.2.110/google_forms'; /* |-------------------------------------------------------------------------- diff --git a/application/config/routes.php b/application/config/routes.php index fc85526..559bf30 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -10,7 +10,6 @@ $route['default_controller'] = 'Form_controller/index_forms'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; $route['start'] = 'Form_controller/index_forms'; -// $route['new_form'] = 'home/create_form'; $route['title_desc'] = 'homepage/title'; $route['forms/delete/(:any)'] = 'Form_controller/delete/$1'; $route['home'] = 'Form_controller/index_forms'; @@ -26,4 +25,3 @@ $route['response_preview/(:num)'] = 'forms/response_preview/$1'; $route['title'] = 'homepage/title'; -// $route['designform'] = 'homepage/design_form'; diff --git a/application/controllers/Form_controller.php b/application/controllers/Form_controller.php index 8123384..b902a19 100644 --- a/application/controllers/Form_controller.php +++ b/application/controllers/Form_controller.php @@ -1,11 +1,12 @@ load->model('Frontend_model'); + $this->load->model('Frontend_model'); // Check if the user is logged in if (!$this->session->userdata('logged_in')) { // If not logged in, redirect to login page @@ -30,92 +31,91 @@ class Form_controller extends CI_Controller { $this->load->view('templates/footer'); } - public function delete($id) - { - if (!$this->session->userdata('logged_in')) { + public function delete($id) + { + if (!$this->session->userdata('logged_in')) { // If not logged in, redirect to login page redirect('users/login'); } -$this->load->model('Frontend_model'); -$this->Frontend_model->deleteForm($id); -$this->session->set_flashdata('status','Form data deleted successfully'); -redirect('home'); - } - public function __construct() { + $this->load->model('Frontend_model'); + $this->Frontend_model->deleteForm($id); + $this->session->set_flashdata('status', 'Form data deleted successfully'); + redirect('home'); + } + public function __construct() + { parent::__construct(); $this->load->model('Updation_model'); } // Load the form for editing - public function edit_form($form_id) { + public function edit_form($form_id) + { $data['form'] = $this->Updation_model->get_form($form_id); $data['questions'] = $this->Updation_model->get_questions($form_id); $data['options'] = $this->Updation_model->get_options(); - // $this->load->view('templates/header'); + // $this->load->view('templates/header'); $this->load->view('edit_form_view', $data); - // $this->load->view('templates/footer'); + // $this->load->view('templates/footer'); } // Save the edited form - public function update_form() { + public function update_form() + { $formData = $this->input->post('formData'); - + if (!$formData) { echo json_encode(['status' => 'error', 'message' => 'Form data is missing']); return; } - + $form_id = $formData['form_id']; $title = $formData['title']; $description = $formData['description']; $questions = $formData['questions']; - + $this->load->model('Updation_model'); $updateStatus = $this->Updation_model->update_form_data($form_id, $title, $description, $questions); - + if ($updateStatus) { echo json_encode(['status' => 'success', 'message' => 'Form updated successfully']); } else { echo json_encode(['status' => 'error', 'message' => 'Failed to update form data']); } } - - - - - - - public function index_forms_draft($form_id = null) { - $this->load->model('Frontend_model'); - - // Check if the user is logged in - if (!$this->session->userdata('logged_in')) { - // If not logged in, redirect to login page - redirect('users/login'); - } - - // Retrieve form title from the forms table using form_id - $form_title = 'Untitled Form'; // Default title - if ($form_id) { - $form = $this->Frontend_model->getFormById($form_id); - if ($form) { - $form_title = $form['title']; - } - } - - // Get the user_id from session - $user_id = $this->session->userdata('user_id'); - - // Load views and data if user is logged in - $this->load->view('templates/header'); - - // Get the forms created by the user - $data = $this->Frontend_model->getforms_draft($user_id); - $this->load->view('Tables/draft', ['forms' => $data, 'form_title' => $form_title]); - - $this->load->view('templates/footer'); - } - + + public function index_forms_draft($form_id = null) + { + $this->load->model('Frontend_model'); + + // Check if the user is logged in + if (!$this->session->userdata('logged_in')) { + // If not logged in, redirect to login page + redirect('users/login'); + } + + // Retrieve form title from the forms table using form_id + $form_title = 'Untitled Form'; // Default title + if ($form_id) { + $form = $this->Frontend_model->getFormById($form_id); + if ($form) { + $form_title = $form['title']; + } + } + + // Get the user_id from session + $user_id = $this->session->userdata('user_id'); + + // Load views and data if user is logged in + $this->load->view('templates/header'); + + // Get the forms created by the user + $data = $this->Frontend_model->getforms_draft($user_id); + $this->load->view('Tables/draft', ['forms' => $data, 'form_title' => $form_title]); + + $this->load->view('templates/footer'); + } + } \ No newline at end of file diff --git a/application/models/Frontend_model.php b/application/models/Frontend_model.php index 883a198..19ba99d 100644 --- a/application/models/Frontend_model.php +++ b/application/models/Frontend_model.php @@ -10,12 +10,12 @@ class Frontend_model extends CI_Model { // Ensure user_id is set if (!$user_id) { - return []; // Return an empty array if user_id is not available + return []; } // Filter forms by user_id and order by created_at in descending order - $this->db->where('user_id', $user_id); // Assuming 'user_id' is the column name in the 'forms' table - $this->db->order_by('created_at', 'DESC'); // Order by created_at column, most recent first + $this->db->where('user_id', $user_id); + $this->db->order_by('created_at', 'DESC'); $query = $this->db->get('forms'); return $query->result(); // Return the result as an array of objects @@ -30,9 +30,9 @@ class Frontend_model extends CI_Model { return $query->row_array(); } public function getforms_draft($user_id) { - $this->db->where('is_published', 0); // Filter by unpublished forms - $this->db->where('user_id', $user_id); // Filter by user_id - $this->db->order_by('created_at', 'DESC'); // Sort by creation date, newest first + $this->db->where('is_published', 0); + $this->db->where('user_id', $user_id); + $this->db->order_by('created_at', 'DESC'); $query = $this->db->get('forms'); return $query->result(); } diff --git a/application/models/New_form_model.php b/application/models/New_form_model.php index 2bf6235..1af773f 100644 --- a/application/models/New_form_model.php +++ b/application/models/New_form_model.php @@ -25,7 +25,7 @@ class New_form_model extends CI_Model { if (!empty($option)) { // Avoid inserting empty options $optionData = [ 'question_id' => $questionId, - 'option_text' => $option // Ensure column name matches database schema + 'option_text' => $option ]; // Insert option into options table $this->db->insert('options', $optionData); diff --git a/application/models/Response_model.php b/application/models/Response_model.php index 46aa549..22ff9e3 100644 --- a/application/models/Response_model.php +++ b/application/models/Response_model.php @@ -1,39 +1,45 @@ db->insert('responses', $data); return $this->db->insert_id(); } - public function insert_response_answer($data) { + public function insert_response_answer($data) + { $this->db->insert('response_answers', $data); } - public function get_form($form_id) { + public function get_form($form_id) + { $this->db->where('id', $form_id); $query = $this->db->get('forms'); return $query->row(); } -// 888888888888888888888 - public function get_questions($form_id) { + + public function get_questions($form_id) + { $this->db->where('form_id', $form_id); $query = $this->db->get('questions'); return $query->result(); } - public function get_options($question_id) { + public function get_options($question_id) + { $this->db->where('question_id', $question_id); $query = $this->db->get('options'); return $query->result(); } -// 888888888888888888888 - - public function get_responses_by_form($form_id) { + + public function get_responses_by_form($form_id) + { $this->db->select('responses.id as response_id, responses.submitted_at, users.username'); $this->db->from('responses'); $this->db->join('users', 'responses.user_id = users.id'); @@ -48,16 +54,17 @@ class Response_model extends CI_Model { return $responses; } - public function get_answers_by_response_id($response_id) { + public function get_answers_by_response_id($response_id) + { $this->db->select('response_answers.question_id, response_answers.answered_text'); $this->db->from('response_answers'); $this->db->where('response_answers.response_id', $response_id); $query = $this->db->get(); return $query->result(); } -// 888888888888888888888 - public function get_responses($form_id) { + public function get_responses($form_id) + { $this->db->where('form_id', $form_id); $query = $this->db->get('responses'); return $query->result(); @@ -65,7 +72,8 @@ class Response_model extends CI_Model { // Method to get response details - public function get_response($response_id) { + public function get_response($response_id) + { $this->db->select('responses.*, users.email'); $this->db->from('responses'); $this->db->join('users', 'responses.user_id = users.id'); // Assuming 'user_id' is the foreign key in 'responses' @@ -73,10 +81,11 @@ class Response_model extends CI_Model { $query = $this->db->get(); return $query->row(); } - + // Method to get questions and answers for a response - public function get_questions_and_answers($response_id) { + public function get_questions_and_answers($response_id) + { $this->db->select('questions.id AS question_id, questions.text AS question_text, response_answers.answered_text, users.email'); $this->db->from('questions'); $this->db->join('response_answers', 'questions.id = response_answers.question_id'); @@ -86,9 +95,10 @@ class Response_model extends CI_Model { $query = $this->db->get(); return $query->result(); } - - public function get_form_by_response($response_id) { + + public function get_form_by_response($response_id) + { $this->db->select('forms.title, forms.description'); $this->db->from('forms'); $this->db->join('responses', 'forms.id = responses.form_id'); diff --git a/application/models/Updation_model.php b/application/models/Updation_model.php index 320d441..610cad0 100644 --- a/application/models/Updation_model.php +++ b/application/models/Updation_model.php @@ -1,34 +1,39 @@ db->where('id', $form_id); $query = $this->db->get('forms'); return $query->row_array(); } - public function get_questions($form_id) { + public function get_questions($form_id) + { $this->db->where('form_id', $form_id); $this->db->order_by('id', 'ASC'); $query = $this->db->get('questions'); return $query->result_array(); } - public function get_options() { + public function get_options() + { $query = $this->db->get('options'); return $query->result_array(); } - public function update_form_data($form_id, $title, $description, $questions) { + public function update_form_data($form_id, $title, $description, $questions) + { $this->db->trans_start(); - + // Update form title and description $this->db->where('id', $form_id); $this->db->update('forms', ['title' => $title, 'description' => $description]); - + // Update questions $this->db->where('form_id', $form_id); $this->db->delete('questions'); - + foreach ($questions as $question) { $question_data = [ 'form_id' => $form_id, @@ -38,7 +43,7 @@ class Updation_model extends CI_Model { ]; $this->db->insert('questions', $question_data); $question_id = $this->db->insert_id(); - + if (isset($question['options'])) { foreach ($question['options'] as $option_text) { $option_data = [ @@ -49,25 +54,26 @@ class Updation_model extends CI_Model { } } } - + $this->db->trans_complete(); - + return $this->db->trans_status(); } - - - private function update_question_options($question_id, $options) { + + + private function update_question_options($question_id, $options) + { // Fetch existing options for this question $existing_options = $this->db->where('question_id', $question_id)->get('options')->result_array(); $existing_option_texts = array_column($existing_options, 'option_text'); - + // Insert or update options foreach ($options as $option_text) { if (in_array($option_text, $existing_option_texts)) { // Option already exists, no need to insert continue; } - + // Insert new option $option_data = [ 'question_id' => $question_id, @@ -75,7 +81,7 @@ class Updation_model extends CI_Model { ]; $this->db->insert('options', $option_data); } - + // Delete options that are no longer present $options_to_delete = array_diff($existing_option_texts, $options); if (!empty($options_to_delete)) { @@ -84,8 +90,8 @@ class Updation_model extends CI_Model { $this->db->delete('options'); } } - - - + + + } -?> +?> \ No newline at end of file diff --git a/application/views/Tables/draft.php b/application/views/Tables/draft.php index 19daee0..0a6222a 100644 --- a/application/views/Tables/draft.php +++ b/application/views/Tables/draft.php @@ -50,7 +50,7 @@ Drafts class="btn btn-danger btn-sm" style=" background-color: rgb(103, 58, 183); border-color: rgb(103, 58, 183); color: white;">Delete - + diff --git a/application/views/Tables/list_forms.php b/application/views/Tables/list_forms.php index ee98e4b..2b1da3d 100644 --- a/application/views/Tables/list_forms.php +++ b/application/views/Tables/list_forms.php @@ -42,7 +42,7 @@ Description Created On Status - Preview + Responses @@ -52,13 +52,13 @@ - title; ?> + title; ?> description; ?> created_at; ?> is_published ? 'Published' : 'Draft'); ?> - + diff --git a/application/views/edit_form_view.php b/application/views/edit_form_view.php index 9407a22..2adc2f1 100644 --- a/application/views/edit_form_view.php +++ b/application/views/edit_form_view.php @@ -1,5 +1,6 @@ + @@ -12,36 +13,38 @@ + + + +
@@ -65,22 +68,28 @@
- +
-
+
- +
- +
@@ -117,39 +127,39 @@ - + + \ No newline at end of file diff --git a/application/views/pages/about.php b/application/views/pages/about.php deleted file mode 100644 index e7b5546..0000000 --- a/application/views/pages/about.php +++ /dev/null @@ -1 +0,0 @@ -

This is about page

\ No newline at end of file diff --git a/application/views/pages/formspage.php b/application/views/pages/formspage.php deleted file mode 100644 index f89719a..0000000 --- a/application/views/pages/formspage.php +++ /dev/null @@ -1 +0,0 @@ -

Welcome to Google Forms !

\ No newline at end of file diff --git a/application/views/pages/homepage.php b/application/views/pages/homepage.php deleted file mode 100644 index 3efadb8..0000000 --- a/application/views/pages/homepage.php +++ /dev/null @@ -1 +0,0 @@ -

This is the home page

\ No newline at end of file diff --git a/application/views/publish_view.php b/application/views/publish_view.php index 3753352..2d30039 100644 --- a/application/views/publish_view.php +++ b/application/views/publish_view.php @@ -28,8 +28,8 @@ Responses Title - Status Response Link + Status Preview @@ -40,14 +40,14 @@ title; ?> - - - Unpublish - response_link; ?> + Unpublish + + + diff --git a/application/views/responses_list.php b/application/views/responses_list.php index cf214a0..e646e57 100644 --- a/application/views/responses_list.php +++ b/application/views/responses_list.php @@ -7,6 +7,11 @@ +
@@ -25,21 +30,22 @@ - + + + + - - diff --git a/application/views/templates/footer.php b/application/views/templates/footer.php index 31fdb4f..536bd61 100644 --- a/application/views/templates/footer.php +++ b/application/views/templates/footer.php @@ -1,10 +1,3 @@ - diff --git a/assets/css/header_new.css b/assets/css/header_new.css index 4e1acc1..0047392 100644 --- a/assets/css/header_new.css +++ b/assets/css/header_new.css @@ -1,35 +1,61 @@ + +.navbar-container { + max-width: 100%; + margin: 0 auto; + padding: 0 15px; +} + /* Navbar styles */ .navbar-custom { - background-color: rgb(103, 58, 183); ; /* Customize this color */ -} - -/* Button positioning for section addition */ -#add-section-btn { - position: absolute; - /* Ensure proper positioning */ -} - -.form-section { - margin-bottom: 15px; - padding: 15px; - border: 1px solid #ddd; - border-radius: 5px; -} - -.header-row { + background-color: rgb(103, 58, 183); + border-radius: 0; + height: 70px; display: flex; - align-items: center; + align-items: center; + padding: 0; } -.header-row textarea, -.header-row select { - margin-right: 10px; -} +/* Brand styling */ .navbar-custom .navbar-brand { - color: #fff; /* Customize brand color */ + color: #fff; + font-size: 19px; + margin-right: 20px; + padding: 15px 10px; +} + + +.navbar-custom .navbar-nav { + display: flex; + align-items: center; + margin-left: -17px; + padding: 0; + flex: 1; +} +.navbar-custom .navbar-nav li { + margin: 0 10px; } .navbar-custom .navbar-nav li a { - color: #fff; /* Customize link color */ + color: #fff; + background-color: transparent; + font-size: 15px; + height: 70px; + padding: 15px 10px; + transition: none; } +.navbar-custom .navbar-nav.navbar-right { + margin-left: auto; + display: flex; + align-items: center; +} + +.navbar-custom .navbar-nav.navbar-right li { + margin: 0 10px; +} + + +#add-section-btn { + position: absolute; + +} diff --git a/assets/css/header_styles.css b/assets/css/header_styles.css index fda9ce0..7f9c2d7 100644 --- a/assets/css/header_styles.css +++ b/assets/css/header_styles.css @@ -49,13 +49,16 @@ body { border-radius: 0; } -.navbar-custom .navbar-brand, -.navbar-custom .navbar-nav>li>a { +.navbar-custom .navbar-brand>li>a { color: white; font-size: 16px; transition: color 0.3s ease; } - +.navbar-custom .navbar-nav>li>a{ + color: white; + font-size: 16px; + transition: color 0.3s ease; +} .navbar-custom .navbar-brand:hover, .navbar-custom .navbar-nav>li>a:hover { color: white; /* Keep text color white on hover */ diff --git a/assets/css/styles.css b/assets/css/styles.css index d7f13e8..c4f1b6d 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -114,8 +114,21 @@ body { .custom-select { width: 220px; + height: 45px; + display: block; + /* width: 100%; */ + /* height: 45px; */ + padding: 10px 15px; + font-size: 15px; + line-height: 1.42857143; + /* color: #2c3e50; */ + background-color: #ffffff; + background-image: none; + border: 1px solid #dce4ec; + border-radius: 4px; } + .delete-section-icon { flex: 0.1; cursor: pointer; @@ -164,7 +177,7 @@ body { background-color: rgb(66, 133, 244); /* color: rgb(66, 133, 244); */ margin-top: 11px; - font-size: 0.9em; + font-size: 0.8em; } @@ -177,8 +190,7 @@ body { width: 56%; margin-left: 240px; } -/* Toggle Switch CSS */ -/* Toggle Switch CSS */ + .toggle-switch { position: relative; display: inline-block; diff --git a/assets/js/scripts.js b/assets/js/scripts.js index a7cb623..a56fdeb 100644 --- a/assets/js/scripts.js +++ b/assets/js/scripts.js @@ -30,8 +30,7 @@ function addOption(type, container) {
${index === 1 ? '
' : ''} - - '; + previewContent += '
' + $(this).find('.untitled-question').val() + '
'; previewContent += '
'; let type = $(this).find('.custom-select').val(); let optionsContainer = $(this).find('.options-container'); @@ -189,7 +188,6 @@ function addOption(type, container) { previewContent += '
'; }); previewContent += ` -
Response ID Username Submitted AtView
username; ?>submitted_at; ?> - response_id; ?> + username; ?>submitted_at; ?>