diff --git a/application/config/database.php b/application/config/database.php index de9475a..e8ab51e 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -76,8 +76,8 @@ $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', - 'username' => 'root', - 'password' => '', + 'username' => 'jostheta', + 'password' => 'Pa$$w0rd', 'database' => 'gforms', 'dbdriver' => 'mysqli', 'dbprefix' => '', diff --git a/application/config/routes.php b/application/config/routes.php index b3586a2..543b883 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -16,6 +16,7 @@ $route['responses/index/(:num)'] = 'Responses/index/$1'; //Routes of the pages controller +$route['hero'] = 'Pages/hero'; $route['default_controller'] = 'Pages/view'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/controllers/Forms.php b/application/controllers/Forms.php index 1e7c8b9..a4f4037 100644 --- a/application/controllers/Forms.php +++ b/application/controllers/Forms.php @@ -20,20 +20,20 @@ class Forms extends CI_Controller } - public function submit_form() { - $formData = $this->input->post('formData'); - $decodedData = json_decode($formData, true); - + public function submit_form() { + $formData = $this->input->post('formData'); + $decodedData = json_decode($formData, true); + // Process the form data here // Example: Save the form data to the database - + $this->load->model('Form_model'); - $this->Form_model->save_form_data($decodedData); - - echo json_encode(['status' => 'success', 'message' => 'Form data submitted successfully']); - } - + $this->Form_model->save_form_data($decodedData); + + echo json_encode(['status' => 'success', 'message' => 'Form data submitted successfully']); + } + public function my_forms() { $this->load->model('Form_model'); diff --git a/application/controllers/Pages.php b/application/controllers/Pages.php index 599489e..126adfb 100644 --- a/application/controllers/Pages.php +++ b/application/controllers/Pages.php @@ -12,10 +12,19 @@ class Pages extends CI_Controller { //storing the title of the page $data['title'] = ucfirst($page); - $this->load->view('templates/header'); + $this->load->view('templates/header_home'); $this->load->view('pages/'.$page, $data); $this->load->view('templates/footer'); } + public function hero() + { + //storing the title of the page + + $this->load->view('pages/hero'); + + } + + } diff --git a/application/models/Form_model.php b/application/models/Form_model.php index f9e0ed4..f6d0dc3 100644 --- a/application/models/Form_model.php +++ b/application/models/Form_model.php @@ -7,35 +7,35 @@ class Form_model extends CI_Model { public function save_form_data($formData) { $user_id = $this->session->userdata('user_id'); - - // Save the form data to the database + + // Save the form data to the database $this->db->insert('forms', [ - 'title' => $formData['title'], - 'description' => $formData['description'], - 'user_id' => $user_id - ]); + 'title' => $formData['title'], + 'description' => $formData['description'], + 'user_id' => $user_id + ]); $formId = $this->db->insert_id(); - + foreach ($formData['questions'] as $question) { - $this->db->insert('questions', [ - 'form_id' => $formId, - 'question_text' => $question['question'], - 'question_type' => $question['type'] - ]); - $questionId = $this->db->insert_id(); - - if ($question['type'] !== 'paragraph') { - foreach ($question['options'] as $option) { - $this->db->insert('options', [ - 'question_id' => $questionId, - 'option_text' => $option - ]); + $this->db->insert('questions', [ + 'form_id' => $formId, + 'question_text' => $question['question'], + 'question_type' => $question['type'] + ]); + $questionId = $this->db->insert_id(); + + if ($question['type'] !== 'paragraph') { + foreach ($question['options'] as $option) { + $this->db->insert('options', [ + 'question_id' => $questionId, + 'option_text' => $option + ]); + } } } - } -} - + } + public function get_all_user_forms() { $user_id = $this->session->userdata('user_id'); $this->db->where('user_id', $user_id); @@ -143,27 +143,27 @@ class Form_model extends CI_Model { $response_id = $this->db->insert_id(); // Insert each answer - foreach ($responses as $question_id => $answer) { - if (is_array($answer)) { - foreach ($answer as $answer_text) { + foreach ($responses as $question_id => $answer) { + if (is_array($answer)) { + foreach ($answer as $answer_text) { + $answer_data = [ + 'response_id' => $response_id, + 'question_id' => $question_id, + 'answer_text' => $answer_text, + 'created_at' => date('Y-m-d H:i:s'), + ]; + $this->db->insert('response_answers', $answer_data); + } + } else { $answer_data = [ 'response_id' => $response_id, 'question_id' => $question_id, - 'answer_text' => $answer_text, + 'answer_text' => $answer, 'created_at' => date('Y-m-d H:i:s'), ]; $this->db->insert('response_answers', $answer_data); } - } else { - $answer_data = [ - 'response_id' => $response_id, - 'question_id' => $question_id, - 'answer_text' => $answer, - 'created_at' => date('Y-m-d H:i:s'), - ]; - $this->db->insert('response_answers', $answer_data); } - } $this->db->trans_complete(); diff --git a/application/views/forms/mydrafts.php b/application/views/forms/mydrafts.php index 941734a..fdfb4fd 100644 --- a/application/views/forms/mydrafts.php +++ b/application/views/forms/mydrafts.php @@ -15,7 +15,7 @@ is_published == 0) : ?> - + title ? $form->title : $form->form_id, ENT_QUOTES, 'UTF-8') ?> diff --git a/application/views/forms/view_form.php b/application/views/forms/view_form.php index 89ee89a..e40f879 100644 --- a/application/views/forms/view_form.php +++ b/application/views/forms/view_form.php @@ -66,9 +66,9 @@ - + diff --git a/application/views/pages/hero.php b/application/views/pages/hero.php new file mode 100644 index 0000000..5ccb449 --- /dev/null +++ b/application/views/pages/hero.php @@ -0,0 +1,61 @@ + + + + + + Hero Page + + + + + + + + +
+
+

+
Simple yet Functional
+
Google Forms
+

+

Start creating your forms with Google Forms clone,create,edit and publish your forms today!

+
+ + +
+
+ + pie charts + +
+ + + + + diff --git a/application/views/pages/home.php b/application/views/pages/home.php index 58dbaad..9896d5b 100644 --- a/application/views/pages/home.php +++ b/application/views/pages/home.php @@ -1,4 +1,114 @@ -
-

-

Welcome to the Gforms Application

-
\ No newline at end of file + +
+ +
+
+
Total Forms Created
+
50
+
+
+
Total Forms Published
+
35
+
+
+
Total Responses Received
+
1500
+
+
+ + +
+ +
+
Top 5 Most Active Forms
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Form TitleResponses
Form A500
Form B400
Form C300
Form D200
Form E100
+
+ + +
+
Recent Forms
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Form TitleDate CreatedStatus
Form X2024-07-10Draft
Form Y2024-07-09Published
Form Z2024-07-08Published
+
+
+ + +
+ +
+
Response Trends
+
+
+ + +
+
Average Responses per Form
+
30
+
+
+ + +
+
+
Active Users
+
100
+
+
+
New Users
+
20
+
+
+
\ No newline at end of file diff --git a/application/views/templates/header.php b/application/views/templates/header.php index d4d2b85..d4c1199 100644 --- a/application/views/templates/header.php +++ b/application/views/templates/header.php @@ -4,6 +4,7 @@ Gforms + @@ -11,12 +12,12 @@