-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_survey.php
139 lines (136 loc) · 4.95 KB
/
view_survey.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php include 'db_connect.php' ?>
<?php
$qry = $conn->query("SELECT * FROM survey_set where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
if($k == 'title')
$k = 'stitle';
$$k = $v;
}
$answers = $conn->query("SELECT distinct(user_id) from answers where survey_id ={$id}")->num_rows;
?>
<div class="col-lg-12">
<div class="row">
<div class="col-md-4">
<div class="card card-outline card-primary">
<div class="card-header">
<h3 class="card-title">Survey Details</h3>
</div>
<div class="card-body p-0 py-2">
<div class="container-fluid">
<p>Title: <b><?php echo $stitle ?></b></p>
<p class="mb-0">Description:</p>
<small><?php echo $description; ?></small>
<p>Start: <b><?php echo date("M d, Y",strtotime($start_date)) ?></b></p>
<p>End: <b><?php echo date("M d, Y",strtotime($end_date)) ?></b></p>
<p>Have Taken: <b><?php echo number_format($answers) ?></b></p>
</div>
<hr class="border-primary">
</div>
</div>
</div>
<div class="col-md-8">
<div class="card card-outline card-success">
<div class="card-header">
<h3 class="card-title"><b>Survey Questionaire</b></h3>
<div class="card-tools">
<button class="btn btn-block btn-sm btn-default btn-flat border-success new_question" type="button"><i class="fa fa-plus"></i> Add New Question</button>
</div>
</div>
<form action="" id="manage-sort">
<div class="card-body ui-sortable">
<?php
$question = $conn->query("SELECT * FROM questions where survey_id = $id order by abs(order_by) asc,abs(id) asc");
while($row=$question->fetch_assoc()):
?>
<div class="callout callout-info">
<div class="row">
<div class="col-md-12">
<span class="dropleft float-right">
<a class="fa fa-ellipsis-v text-dark" href="javascript:void(0)" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></a>
<div class="dropdown-menu" style="">
<a class="dropdown-item edit_question text-dark" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>">Edit</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item delete_question text-dark" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>">Delete</a>
</div>
</span>
</div>
</div>
<h5><?php echo $row['question'] ?></h5>
<div class="col-md-12">
<input type="hidden" name="qid[]" value="<?php echo $row['id'] ?>">
<?php
if($row['type'] == 'radio_opt'):
foreach(json_decode($row['frm_option']) as $k => $v):
?>
<div class="icheck-primary">
<input type="radio" id="option_<?php echo $k ?>" name="answer[<?php echo $row['id'] ?>]" value="<?php echo $k ?>" checked="">
<label for="option_<?php echo $k ?>"><?php echo $v ?></label>
</div>
<?php endforeach; ?>
<?php elseif($row['type'] == 'check_opt'):
foreach(json_decode($row['frm_option']) as $k => $v):
?>
<div class="icheck-primary">
<input type="checkbox" id="option_<?php echo $k ?>" name="answer[<?php echo $row['id'] ?>][]" value="<?php echo $k ?>" >
<label for="option_<?php echo $k ?>"><?php echo $v ?></label>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="form-group">
<textarea name="answer[<?php echo $row['id'] ?>]" id="" cols="30" rows="4" class="form-control" placeholder="Write Something Here..."></textarea>
</div>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('.ui-sortable').sortable({
placeholder: "ui-state-highlight",
update: function( ) {
alert_toast("Saving question sort order.","info")
$.ajax({
url:"ajax.php?action=action_update_qsort",
method:'POST',
data:$('#manage-sort').serialize(),
success:function(resp){
if(resp == 1){
alert_toast("Question order sort successfully saved.","success")
}
}
})
}
})
})
$('.new_question').click(function(){
uni_modal("New Question","manage_question.php?sid=<?php echo $id ?>","large")
})
$('.edit_question').click(function(){
uni_modal("New Question","manage_question.php?sid=<?php echo $id ?>&id="+$(this).attr('data-id'),"large")
})
$('.delete_question').click(function(){
_conf("Are you sure to delete this question?","delete_question",[$(this).attr('data-id')])
})
function delete_question($id){
start_load()
$.ajax({
url:'ajax.php?action=delete_question',
method:'POST',
data:{id:$id},
success:function(resp){
if(resp==1){
alert_toast("Data successfully deleted",'success')
setTimeout(function(){
location.reload()
},1500)
}
}
})
}
</script>