diff --git a/application/controllers/Forms.php b/application/controllers/Forms.php index 37dde2e..c82eea5 100644 --- a/application/controllers/Forms.php +++ b/application/controllers/Forms.php @@ -51,6 +51,7 @@ class Forms extends CI_Controller $this->load->view('templates/header'); $this->load->view('forms/mydrafts', $data); $this->load->view('templates/footer'); + //footer omitted on purpose } @@ -198,6 +199,7 @@ class Forms extends CI_Controller // List all responses for a particular form public function list_form_responses($form_id) { + $user_id = $this->session->userdata('user_id'); $data['responses'] = $this->Form_model->get_responses_by_form($form_id); $data['form'] = $this->Form_model->get_form($form_id); diff --git a/application/views/forms/create.php b/application/views/forms/create.php index f42901f..de51332 100644 --- a/application/views/forms/create.php +++ b/application/views/forms/create.php @@ -44,8 +44,10 @@
- -
+ +
+ +
diff --git a/application/views/forms/form_responses.php b/application/views/forms/form_responses.php index e9de128..4b5d232 100644 --- a/application/views/forms/form_responses.php +++ b/application/views/forms/form_responses.php @@ -1,4 +1,5 @@
+

Responses for: title, ENT_QUOTES, 'UTF-8') ?>

@@ -22,4 +23,5 @@
+
diff --git a/application/views/forms/mydrafts.php b/application/views/forms/mydrafts.php index 5e407fd..e13ce47 100644 --- a/application/views/forms/mydrafts.php +++ b/application/views/forms/mydrafts.php @@ -1,29 +1,30 @@
-

My Drafts

+

My Drafts

- + - - - - - + is_published == 0) : ?> + + + + + + - +
Draft Title Created At Actions
title, ENT_QUOTES, 'UTF-8') ?>created_at)); ?>Delete
title, ENT_QUOTES, 'UTF-8') ?>created_at)); ?>Delete
No Drafts found.No Drafts found.
-
- \ No newline at end of file +
diff --git a/application/views/forms/user_forms.php b/application/views/forms/user_forms.php index 4cd2c30..8793540 100644 --- a/application/views/forms/user_forms.php +++ b/application/views/forms/user_forms.php @@ -11,13 +11,17 @@ - - + + + is_published == 1) : ?> + title, ENT_QUOTES, 'UTF-8') ?> created_at)) ?> response_link ?> - - + + + + No forms found. @@ -25,4 +29,4 @@ - + \ No newline at end of file diff --git a/assets/js/edit.js b/assets/js/edit.js new file mode 100644 index 0000000..c5b3a46 --- /dev/null +++ b/assets/js/edit.js @@ -0,0 +1,46 @@ +$(document).ready(function() { + console.log('jQuery is ready'); + let questionCount = 0; + + // Add new question + $('#add-question').click(function() { + questionCount++; + + // Clone the question template + var newQuestion = $('#question-template').clone(); + newQuestion.removeAttr('id'); + newQuestion.attr('data-question-type', 'multiple-choice'); // Set default question type + newQuestion.find('.question-box_header_question').attr('placeholder', 'Question ' + questionCount); + newQuestion.find('.question-box_option-block_option-text').attr('placeholder', 'Option 1'); + newQuestion.show(); // Ensure the cloned template is visible + + // Append the cloned question to the form container + $('#question-template').parent().append(newQuestion); + }); + + // Add new option to a question + $(document).on('click', '#add-option', function() { + const questionBox = $(this).closest('.question-box'); + const currentQuestionType = questionBox.attr('data-question-type'); + let optionCount = questionBox.find('.question-box_option-block').length + 1; + + var newOption = $('#option-template').clone(); + newOption.removeAttr('id'); + newOption.find('input').val(''); + newOption.find('input').attr('placeholder', 'Option ' + optionCount); + + if (currentQuestionType === 'multiple-choice') { + newOption.find('img').attr('src', base_url+'assets/images/circle.png'); + } else if (currentQuestionType === 'checkbox') { + newOption.find('img').attr('src', base_url+'assets/images/square.png'); + } + + if (optionCount > 1) { + newOption.append(''); + } + + questionBox.find('#new-options').append(newOption).append('
'); + }); + + +});