debugged issues
This commit is contained in:
parent
8572bbf644
commit
a64c675132
|
@ -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);
|
||||
|
||||
|
|
|
@ -44,8 +44,10 @@
|
|||
<input id = "option-text" type="text" placeholder="Option1" class="question-box_option-block_option-text">
|
||||
</div>
|
||||
<br>
|
||||
<!-- New options should be appended here -->
|
||||
<div id="new-options"></div>
|
||||
|
||||
<div id="new-options">
|
||||
<!-- New options should be appended here -->
|
||||
</div>
|
||||
<!-- To Add a new option -->
|
||||
<div class="question-box_add-option">
|
||||
<button id="add-option" style="color:#1a73e8;font-weight: 500;">Add Option</button>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<div class="page_layout">
|
||||
<div style="margin: 0 10%;">
|
||||
<h1>Responses for: <?= htmlspecialchars($form->title, ENT_QUOTES, 'UTF-8') ?></h1>
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -22,4 +23,5 @@
|
|||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
<div style="margin: 0 10%;">
|
||||
<h1>My Drafts</h1>
|
||||
<h1>My Drafts</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Draft Title</th>
|
||||
<th>Created At</th>
|
||||
<th> </th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($forms)) : ?>
|
||||
<?php foreach ($forms as $form) : ?>
|
||||
<tr>
|
||||
<td><a href="<?= base_url() ?>forms/view_form/<?=$form->form_id?> "><?= htmlspecialchars($form->title, ENT_QUOTES, 'UTF-8') ?></a></td>
|
||||
<td><?php echo date('Y-m-d H:i:s', strtotime($form->created_at)); ?></td>
|
||||
<td><a href="<?= base_url()?>forms/delete/<?=$form->form_id?>" onclick="return confirm('Are you sure you want to delete this form?');">Delete</a></td>
|
||||
</tr>
|
||||
<?php if ($form->is_published == 0) : ?>
|
||||
<tr>
|
||||
<td><a href="<?= base_url() ?>forms/view_form/<?= $form->form_id ?>"><?= htmlspecialchars($form->title, ENT_QUOTES, 'UTF-8') ?></a></td>
|
||||
<td><?php echo date('Y-m-d H:i:s', strtotime($form->created_at)); ?></td>
|
||||
<td><a href="<?= base_url() ?>forms/delete/<?= $form->form_id ?>" onclick="return confirm('Are you sure you want to delete this form?');">Delete</a></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<tr>
|
||||
<td colspan="2">No Drafts found.</td>
|
||||
<td colspan="3">No Drafts found.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -11,13 +11,17 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($forms)) : ?>
|
||||
<?php foreach ($forms as $form) : ?>
|
||||
<tr>
|
||||
|
||||
<?php foreach ($forms as $form) : ?>
|
||||
<?php if ($form->is_published == 1) : ?>
|
||||
<tr>
|
||||
<td><a href="<?= base_url() ?>forms/list_form_responses/<?=$form->form_id?>"><?= htmlspecialchars($form->title, ENT_QUOTES, 'UTF-8') ?></a></td>
|
||||
<td><?= date('Y-m-d H:i:s', strtotime($form->created_at)) ?></td>
|
||||
<td><a href="<?= $form->response_link ?>"><?= $form->response_link ?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php else : ?>
|
||||
<tr>
|
||||
<td colspan="3">No forms found.</td>
|
||||
|
|
|
@ -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('<button class="question-box_option-block_option-close"><img src="'+base_url+'assets/images/close.png" alt="close option"></button>');
|
||||
}
|
||||
|
||||
questionBox.find('#new-options').append(newOption).append('<br>');
|
||||
});
|
||||
|
||||
|
||||
});
|
Loading…
Reference in New Issue