-
Notifications
You must be signed in to change notification settings - Fork 0
/
testanswer.php
163 lines (78 loc) · 3.15 KB
/
testanswer.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
<?php include 'db_connect.php' ?>
<?php
$qry = $conn->query("SELECT * FROM survey_set where id = ".$_GET['id'])->fetch_array();
?>
<div class="col-lg-12">
<div class="row">
<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>
<form action="" id="manage-survey">
<input type="hidden" name="survey_id" value="<?php echo $id ?>">
<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">
<h5><?php echo $row['question'] ?></h5>
<div class="col-md-12">
<input type="hidden" name="qid[<?php echo $row['id'] ?>]" value="<?php echo $row['id'] ?>">
<input type="hidden" name="type[<?php echo $row['id'] ?>]" value="<?php echo $row['type'] ?>">
<?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 class="card-footer border-top border-success">
<div class="d-flex w-100 justify-content-center">
<button class="btn btn-sm btn-flat bg-gradient-primary mx-1" form="manage-survey" >Submit Answer</button>
<button class="btn btn-sm btn-flat bg-gradient-secondary mx-1" type="button" onclick="location.href = 'index.php?page=survey_widget'">Cancel</button>
</div>
</div>
</div>
</div>
</div>
<script>
$('#manage-survey').submit(function(e){
e.preventDefault()
start_load()
$.ajax({
url:'ajax.php?action=save_answer',
method:'POST',
data:$(this).serialize(),
success:function(resp){
if(resp == 1){
alert_toast("Thank You.",'success')
setTimeout(function(){
location.href = 'index.php?page=survey_widget'
},2000)
}
}
})
})
</script>