commit
This commit is contained in:
parent
5163666799
commit
fe5ee0596c
|
@ -27,5 +27,29 @@ class Forms extends CI_Controller
|
||||||
// redirect('home/preview_forms');
|
// redirect('home/preview_forms');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public function response_preview($form_id)
|
||||||
|
{
|
||||||
|
// Load the model that handles the form data
|
||||||
|
$this->load->model('preview_model');
|
||||||
|
|
||||||
|
// Fetch the form details
|
||||||
|
$form = $this->preview_model->get_form($form_id);
|
||||||
|
|
||||||
|
// Fetch the questions for the form
|
||||||
|
$questions = $this->preview_model->get_questions($form_id);
|
||||||
|
|
||||||
|
// Fetch the options for each question
|
||||||
|
foreach ($questions as &$question) {
|
||||||
|
$question->options = $this->preview_model->get_options($question->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass the data to the view
|
||||||
|
$data['form'] = $form;
|
||||||
|
$data['questions'] = $questions;
|
||||||
|
|
||||||
|
$this->load->view('response_submit', $data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,6 @@ defined('BASEPATH') or exit('No direct script access allowed');
|
||||||
class Home extends CI_Controller
|
class Home extends CI_Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
$this->load->view('templates/header');
|
|
||||||
$this->load->view('templates/footer');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index1()
|
public function index1()
|
||||||
{
|
{
|
||||||
$this->load->view('templates/header');
|
$this->load->view('templates/header');
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Publish_controller extends CI_Controller {
|
||||||
// Method to publish a form
|
// Method to publish a form
|
||||||
public function publish_form($form_id) {
|
public function publish_form($form_id) {
|
||||||
// Generate a unique link
|
// Generate a unique link
|
||||||
$response_link = base_url("forms/preview/" . $form_id);
|
$response_link = base_url("forms/response_preview/" . $form_id);
|
||||||
$this->load->model('Publish_model');
|
$this->load->model('Publish_model');
|
||||||
// Update is_published to 1 and set the response link
|
// Update is_published to 1 and set the response link
|
||||||
$this->Publish_model->update_form($form_id, [
|
$this->Publish_model->update_form($form_id, [
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
class Response_submit extends CI_Controller {
|
||||||
|
|
||||||
|
public function view($form_id) {
|
||||||
|
$this->load->model('Response_model');
|
||||||
|
|
||||||
|
$data['form'] = $this->Response_model->get_form($form_id);
|
||||||
|
$questions = $this->Response_model->get_questions($form_id);
|
||||||
|
|
||||||
|
foreach ($questions as $question) {
|
||||||
|
$question->options = $this->Response_model->get_options($question->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['questions'] = $questions;
|
||||||
|
|
||||||
|
// Redirect to the view_responses function in the Response_submit controller
|
||||||
|
redirect('Response_submit/view_responses/' . $form_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view_responses($form_id) {
|
||||||
|
$this->load->model('Response_model');
|
||||||
|
|
||||||
|
$data['form'] = $this->Response_model->get_form($form_id);
|
||||||
|
$data['responses'] = $this->Response_model->get_responses_by_form($form_id);
|
||||||
|
|
||||||
|
$this->load->view('templates/header');
|
||||||
|
$this->load->view('responses_list', $data);
|
||||||
|
$this->load->view('templates/footer');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit_form() {
|
||||||
|
$this->load->model('Response_model');
|
||||||
|
$responses = $this->input->post('responses');
|
||||||
|
$user_id = $this->session->userdata('user_id'); // Assuming user_id is stored in session
|
||||||
|
|
||||||
|
foreach ($responses as $response) {
|
||||||
|
$answered_text = '';
|
||||||
|
|
||||||
|
if (isset($response['options'])) {
|
||||||
|
if (is_array($response['options'])) {
|
||||||
|
$answered_text = implode(', ', $response['options']);
|
||||||
|
} else {
|
||||||
|
$answered_text = $response['options'];
|
||||||
|
}
|
||||||
|
} else if (isset($response['answered_text'])) {
|
||||||
|
$answered_text = $response['answered_text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the max response_id for the given form_id
|
||||||
|
$this->db->select_max('response_id');
|
||||||
|
$this->db->where('form_id', $response['form_id']);
|
||||||
|
$max_response_id = $this->db->get('responses')->row()->response_id;
|
||||||
|
|
||||||
|
// Increment the response_id by 1
|
||||||
|
$new_response_id = $max_response_id + 1;
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'form_id' => $response['form_id'],
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'question_id' => $response['question_id'],
|
||||||
|
'answered_text' => $answered_text,
|
||||||
|
'response_id' => $new_response_id,
|
||||||
|
'submitted_at' => date('Y-m-d H:i:s')
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->Response_model->insert_response($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect('Response_submit/view_responses/' . $response['form_id']);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
class Response_model extends CI_Model {
|
||||||
|
|
||||||
|
public function insert_response($data) {
|
||||||
|
$this->db->insert('responses', $data);
|
||||||
|
return $this->db->insert_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_form($form_id) {
|
||||||
|
$this->db->where('id', $form_id);
|
||||||
|
$query = $this->db->get('forms');
|
||||||
|
return $query->row();
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
$this->db->where('question_id', $question_id);
|
||||||
|
$query = $this->db->get('options');
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_responses_by_form($form_id) {
|
||||||
|
$this->db->select('responses.response_id, MAX(responses.submitted_at) as submitted_at, users.username');
|
||||||
|
$this->db->from('responses');
|
||||||
|
$this->db->join('users', 'responses.user_id = users.id');
|
||||||
|
$this->db->where('responses.form_id', $form_id);
|
||||||
|
$this->db->group_by('responses.response_id, users.username');
|
||||||
|
$query = $this->db->get();
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@
|
||||||
<!-- <li><a href="<?php echo base_url(); ?>home/index3">Home</a></li> -->
|
<!-- <li><a href="<?php echo base_url(); ?>home/index3">Home</a></li> -->
|
||||||
<li><a href="<?php echo base_url(); ?>home/index1">About</a></li>
|
<li><a href="<?php echo base_url(); ?>home/index1">About</a></li>
|
||||||
<li><a href="<?php echo base_url(); ?>Publish_controller/list_user_published_forms">Published Forms</a></li>
|
<li><a href="<?php echo base_url(); ?>Publish_controller/list_user_published_forms">Published Forms</a></li>
|
||||||
<li><a href="">Responses</a></li>
|
<li><a href="<?php echo base_url(); ?>Response_submit/submit_form">Responses</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
body { background-color: rgb(240, 235, 248); }
|
body { background-color: rgb(240, 235, 248); }
|
||||||
.container { margin-top: 30px; }
|
.container { margin-top: 30px; }
|
||||||
.form-section { background-color: white; width: 56%; margin-bottom: 30px; margin-left: 240px; padding: 20px; position: relative; align-items: center; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }
|
.form-section { background-color: white; width: 56%; margin-bottom: 30px; margin-left: 240px; padding: 20px; position: relative; align-items: center; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }
|
||||||
.form-header { background-color: white; padding: 20px; margin-bottom: 10px; margin-left: 240px; border-radius: 10px 10px 0 0; display: flex; justify-content: space-between; align-items: center; position: relative; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-top: 10px solid rgb(103, 58, 183); width: 56%; }
|
.form-header { background-color: white; padding: 20px; margin-bottom: 10px; margin-left: 240px; border-radius: 10px 10px 0 0; display:flex ;flex-direction: column; justify-content: space-between; align-items: left; position: relative; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-top: 10px solid rgb(103, 58, 183); width: 56%; }
|
||||||
.form-section h2 { text-align: center; margin-bottom: 30px; }
|
.form-section h2 { text-align: center; margin-bottom: 30px; }
|
||||||
.form-section .question-section { margin-bottom: 20px; }
|
.form-section .question-section { margin-bottom: 20px; }
|
||||||
</style>
|
</style>
|
||||||
|
@ -66,7 +66,10 @@
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="form-header">
|
<div class="form-header">
|
||||||
<h2>Form Preview: <?php echo $form->title; ?></h2>
|
<h2><?php echo $form->title; ?></h2>
|
||||||
|
|
||||||
|
<h4><?php echo $form->description; ?></h4>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
<?php foreach ($questions as $question): ?>
|
<?php foreach ($questions as $question): ?>
|
||||||
|
@ -99,8 +102,9 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<a href="<?php echo base_url('Publish_controller/publish_form/' . $form->id); ?>" class="btn btn-success" style="margin-top: 20px">Publish</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
<a href="<?php echo base_url('Publish_controller/publish_form/' . $form->id); ?>" class="btn btn-success" style="margin-top: 20px; position: relative; left: 240px;">Publish</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
|
<script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Form Preview - Google Forms</title>
|
||||||
|
<link rel="stylesheet" href="https://bootswatch.com/3/flatly/bootstrap.min.css">
|
||||||
|
<style>
|
||||||
|
body { background-color: rgb(240, 235, 248); }
|
||||||
|
.container { margin-top: 30px; }
|
||||||
|
.form-section { background-color: white; width: 56%; margin-bottom: 30px; margin-left: 240px; padding: 20px; position: relative; align-items: center; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }
|
||||||
|
.form-header { background-color: white; padding: 20px; margin-bottom: 10px; margin-left: 240px; border-radius: 10px 10px 0 0; display:flex ;flex-direction: column; justify-content: space-between; align-items: left; position: relative; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-top: 10px solid rgb(103, 58, 183); width: 56%; }
|
||||||
|
.form-section h2 { text-align: center; margin-bottom: 30px; }
|
||||||
|
.form-section .question-section { margin-bottom: 20px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="form-header">
|
||||||
|
<h2><?php echo $form->title; ?></h2>
|
||||||
|
<h4><?php echo $form->description; ?></h4>
|
||||||
|
</div>
|
||||||
|
<form action="<?php echo base_url('response_submit/submit_form'); ?>" method="post">
|
||||||
|
<input type="hidden" name="form_id" value="<?php echo $form->id; ?>">
|
||||||
|
<div class="form-section">
|
||||||
|
<?php foreach ($questions as $question): ?>
|
||||||
|
<div class="question-section">
|
||||||
|
<input type="hidden" name="responses[<?php echo $question->id; ?>][question_id]" value="<?php echo $question->id; ?>">
|
||||||
|
<input type="hidden" name="responses[<?php echo $question->id; ?>][form_id]" value="<?php echo $form->id; ?>">
|
||||||
|
<label><?php echo $question->text; ?></label>
|
||||||
|
<?php if ($question->type == 'multiple-choice'): ?>
|
||||||
|
<?php foreach ($question->options as $option): ?>
|
||||||
|
<div class="option">
|
||||||
|
<input type="radio" name="responses[<?php echo $question->id; ?>][options][]" value="<?php echo $option->option_text; ?>">
|
||||||
|
<label><?php echo $option->option_text; ?></label>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php elseif ($question->type == 'checkbox'): ?>
|
||||||
|
<?php foreach ($question->options as $option): ?>
|
||||||
|
<div class="option">
|
||||||
|
<input type="checkbox" name="responses[<?php echo $question->id; ?>][options][]" value="<?php echo $option->option_text; ?>">
|
||||||
|
<label><?php echo $option->option_text; ?></label>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php elseif ($question->type == 'short-answer'): ?>
|
||||||
|
<input type="text" class="form-control" name="responses[<?php echo $question->id; ?>][answered_text]" placeholder="Short answer text">
|
||||||
|
<?php elseif ($question->type == 'paragraph'): ?>
|
||||||
|
<textarea class="form-control" name="responses[<?php echo $question->id; ?>][answered_text]" placeholder="Paragraph text"></textarea>
|
||||||
|
<?php elseif ($question->type == 'dropdown'): ?>
|
||||||
|
<select class="form-control" name="responses[<?php echo $question->id; ?>][answered_text]">
|
||||||
|
<?php foreach ($question->options as $option): ?>
|
||||||
|
<option value="<?php echo $option->option_text; ?>"><?php echo $option->option_text; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success" style="margin-top: 20px; position: relative; left: 240px;">Submit</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Responses List</title>
|
||||||
|
<link rel="stylesheet" href="https://bootswatch.com/3/flatly/bootstrap.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 mt-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<?php if ($this->session->flashdata('status')): ?>
|
||||||
|
<div class="alert alert-success">
|
||||||
|
<?= $this->session->flashdata('status'); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<h3>
|
||||||
|
Responses for "<?php echo $form->title; ?>"
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<table id="basetable1" class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Response ID</th>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Submitted At</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($responses as $response): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $response->response_id; ?></td>
|
||||||
|
<td><?php echo $response->username; ?></td>
|
||||||
|
<td><?php echo $response->submitted_at; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -11,7 +11,7 @@
|
||||||
<script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
|
<script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body style = "background-color: rgb(240,235,248);" >
|
<body class = "body_header_bg" >
|
||||||
<nav class="navbar navbar-inverse" style="background-color: rgb(103, 58, 183);" >
|
<nav class="navbar navbar-inverse" style="background-color: rgb(103, 58, 183);" >
|
||||||
<div class="container" style="background-color: rgb(103, 58, 183);">
|
<div class="container" style="background-color: rgb(103, 58, 183);">
|
||||||
<?php if ($this->session->userdata('logged_in')): ?>
|
<?php if ($this->session->userdata('logged_in')): ?>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<li><a href="<?php echo base_url(); ?>home/index1">About</a></li>
|
<li><a href="<?php echo base_url(); ?>home/index1">About</a></li>
|
||||||
<?php if ($this->session->userdata('logged_in')): ?>
|
<?php if ($this->session->userdata('logged_in')): ?>
|
||||||
<li><a href="<?php echo base_url(); ?>Publish_controller/list_user_published_forms">Published Forms</a></li>
|
<li><a href="<?php echo base_url(); ?>Publish_controller/list_user_published_forms">Published Forms</a></li>
|
||||||
<li><a href="">Responses</a></li>
|
<li><a href="<?php echo base_url(); ?>Response_submit/submit_form">Responses</a></li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -213,3 +213,6 @@ input:checked + .slider {
|
||||||
input:checked + .slider:before {
|
input:checked + .slider:before {
|
||||||
transform: translateX(14px);
|
transform: translateX(14px);
|
||||||
}
|
}
|
||||||
|
.body_header_bg{
|
||||||
|
background-color: rgb(240,235,248);
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
let index = 1;
|
let index = 1;
|
||||||
let activeSection = null;
|
let activeSection = null;
|
||||||
|
// Add option function
|
||||||
// Add option function
|
|
||||||
function addOption(type, container) {
|
function addOption(type, container) {
|
||||||
let optionIndex = container.children().length + 1;
|
let optionIndex = container.children().length + 1;
|
||||||
let optionHtml;
|
let optionHtml;
|
||||||
|
@ -24,8 +23,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
container.append(optionHtml);
|
container.append(optionHtml);
|
||||||
}
|
}
|
||||||
|
//Form section function
|
||||||
// Form section function
|
|
||||||
function createFormSection() {
|
function createFormSection() {
|
||||||
let newSection = `
|
let newSection = `
|
||||||
<div class="form-section" data-index="${index}">
|
<div class="form-section" data-index="${index}">
|
||||||
|
@ -66,10 +64,10 @@ $(document).ready(function() {
|
||||||
top: position.top + activeSection.height() / 2 - buttonHeight / 2 + 'px'
|
top: position.top + activeSection.height() / 2 - buttonHeight / 2 + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Event handler is triggered
|
}
|
||||||
// creates a new form section;sets it as active;repositions the add section button
|
//Event handler is triggered
|
||||||
|
// creates a new form section;sets it as active;respositions the add section button
|
||||||
$('#add-section-btn').on('click', function() {
|
$('#add-section-btn').on('click', function() {
|
||||||
createFormSection();
|
createFormSection();
|
||||||
$('.form-section').removeClass('active');
|
$('.form-section').removeClass('active');
|
||||||
|
@ -77,8 +75,7 @@ $(document).ready(function() {
|
||||||
activeSection.addClass('active');
|
activeSection.addClass('active');
|
||||||
positionAddSectionButton();
|
positionAddSectionButton();
|
||||||
});
|
});
|
||||||
|
// It updates the options container based on the selected type, adding the necessary input fields or buttons.
|
||||||
// It updates the options container based on the selected type, adding the necessary input fields or buttons.
|
|
||||||
$(document).on('change', '.custom-select', function() {
|
$(document).on('change', '.custom-select', function() {
|
||||||
let type = $(this).val();
|
let type = $(this).val();
|
||||||
let container = $(this).closest('.form-section').find('.options-container');
|
let container = $(this).closest('.form-section').find('.options-container');
|
||||||
|
@ -95,17 +92,15 @@ $(document).ready(function() {
|
||||||
$(this).closest('.form-section').append('<button class="btn btn-secondary add-option-btn">Add Option</button>');
|
$(this).closest('.form-section').append('<button class="btn btn-secondary add-option-btn">Add Option</button>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// add option event handler
|
||||||
// add option event handler
|
// adds a new option to the options container and updates the option numbers
|
||||||
// adds a new option to the options container and updates the option numbers
|
|
||||||
$(document).on('click', '.add-option-btn', function() {
|
$(document).on('click', '.add-option-btn', function() {
|
||||||
let type = $(this).closest('.form-section').find('.custom-select').val();
|
let type = $(this).closest('.form-section').find('.custom-select').val();
|
||||||
let container = $(this).closest('.form-section').find('.options-container');
|
let container = $(this).closest('.form-section').find('.options-container');
|
||||||
addOption(type, container);
|
addOption(type, container);
|
||||||
// refreshOptionNumbers(container);
|
|
||||||
});
|
|
||||||
|
|
||||||
// removes the section;updates the active section;repositions add section button
|
});
|
||||||
|
// removes the section;updates the active section;repositions add section button
|
||||||
$(document).on('click', '.delete-section-icon', function() {
|
$(document).on('click', '.delete-section-icon', function() {
|
||||||
let section = $(this).closest('.form-section');
|
let section = $(this).closest('.form-section');
|
||||||
let prevSection = section.prev('.form-section');
|
let prevSection = section.prev('.form-section');
|
||||||
|
@ -116,8 +111,9 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
if (prevSection.length > 0) {
|
if (prevSection.length > 0) {
|
||||||
prevSection.find('.delete-section-icon').appendTo(prevSection.find('.form-section'));
|
prevSection.find('.delete-section-icon').appendTo(prevSection.find('.form-section'));
|
||||||
activeSection = prevSection;
|
activeSection = prevSection;row
|
||||||
} else if (nextSection.length > 0) {
|
}
|
||||||
|
else if (nextSection.length > 0) {
|
||||||
nextSection.find('.delete-section-icon').appendTo(nextSection.find('.form-header'));
|
nextSection.find('.delete-section-icon').appendTo(nextSection.find('.form-header'));
|
||||||
activeSection = nextSection;
|
activeSection = nextSection;
|
||||||
}
|
}
|
||||||
|
@ -125,17 +121,21 @@ $(document).ready(function() {
|
||||||
positionAddSectionButton();
|
positionAddSectionButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
// delete option
|
// delele option
|
||||||
$(document).on('click', '.delete-option-icon', function() {
|
$(document).on('click', '.delete-option-icon', function() {
|
||||||
let option = $(this).closest('.option');
|
let option = $(this).closest('.option');
|
||||||
let container = option.closest('.options-container');
|
let container = option.closest('.options-container');
|
||||||
option.remove();
|
option.remove();
|
||||||
K });
|
|
||||||
|
|
||||||
|
});
|
||||||
// Event handler for required toggle button
|
// Event handler for required toggle button
|
||||||
$(document).on('click', '.required-toggle', function() {
|
$(document).on('click', '.required-toggle', function() {
|
||||||
$(this).closest('.form-section').toggleClass('required');
|
$(this).closest('.form-section').toggleClass('required');
|
||||||
});
|
});
|
||||||
|
$(document).on('click', '.required-toggle', function() {
|
||||||
|
$(this).closest('.form-section').toggleClass('required');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Preview button functionality
|
// Preview button functionality
|
||||||
$('#preview-btn').on('click', function() {
|
$('#preview-btn').on('click', function() {
|
||||||
|
|
Loading…
Reference in New Issue