-
Notifications
You must be signed in to change notification settings - Fork 3
/
predictName.php
305 lines (259 loc) · 16.1 KB
/
predictName.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<div class="row">
<!-- page header -->
<div class="col-lg-12">
<h1 class="page-header">Prediksi</h1>
</div>
<!-- end page header -->
</div>
<div class="row">
<div class="col-lg-12">
<!-- Advanced Tables -->
<div class="panel panel-primary">
<div class="panel-heading">
Prediksi Pengunduran Diri Mahasiswa
</div>
<div class="panel-body">
<br><br>
<?php
if(isset($_POST['search'])){
$name = $_POST['name']
?>
<script type="text/javascript">
window.location='index.php?page=predictName&&name=<?php echo $name; ?>';
</script>
<?php }
?>
<!-- Form Mahasiswa -->
<form id="mahasiswa" action="" method="POST">
<div class="col-lg-4">
<input type='text' name='name' id='auto' class="form-control" placeholder="--Cari Nama Mahasiswa--">
</div>
<button class="btn btn-primary" type="submit" name="search">
<i class="fa fa-search"></i> Cari
</button>
</form>
<div class="col-lg-4">
<a href="?page=predict">Cari Nim</a>
</div>
<br><br><br>
<?php
if(isset($_GET['name'])){
?>
<div class="table-responsive">
<?php
$name = $_GET['name'];
$sqlget = "SELECT * FROM datasets WHERE nama = '$name' ";
$query = mysqli_query($conn,$sqlget) or die(mysqli_error($conn));
$row = mysqli_fetch_array($query);
?>
<table>
<tr>
<td>NIM</td><td>:</td><td> <?php echo $row['nim']; ?></td>
</tr>
<tr>
<td>Nama Mahasiswa</td><td>:</td><td> <?php echo $row['nama']; ?></td>
</tr>
<tr>
<td><b><?php if($row['beasiswa']==1){
echo "Mendapat Beasiswa";
}else{
echo "Tidak Mendapat Beasiswa";
} ?></b></td>
</tr>
</table>
<br>
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<form id="form-predict">
<table class="table table-striped table-bordered table-hover table-responsive" id="predict">
<thead>
<tr class="odd gradeX">
<th>IPK Terakhir</th>
<th>Semester</th>
<th>Penghasilan Orang Tua</th>
<th>Jarak Menuju Kampus</th>
<th>Jenis Kelamin</th>
<th>Prediksi</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td><input type="text" id="ipk" name="ipk" class="form-control" size="10" value="<?php echo $row['ipk']; ?>"></td>
<input type="hidden" name="nim" value="<?php echo $row['nim'] ?>">
<input type="hidden" name="beasiswa" value="<?php echo $row['beasiswa'] ?>">
<td><input type="text" id="semester" name="semester" class="form-control" size="10" value="<?php echo $row['semester']; ?>"></td>
<td><input type="text" id="penghasilan" name="id_penghasilan" class="form-control" size="10" value="<?php echo $row['id_penghasilan']; ?>"></td>
<td><input type="text" id="jarak" name="jarak" class="form-control" size="10" value="<?php echo $row['jarak']; ?>"></td>
<td><input type="text" id="jenis_kelamin" name="jenis_kelamin" class="form-control" size="10" value="<?php
if($row['jenis_kelamin']=='L'){
echo "1";
}else{
echo "0";
} ?>"></td>
<input type="hidden" name="fakta" value="<?php echo $row['fakta']; ?>">
<input type="hidden" name="lulus" value="<?php echo $row['lulus']; ?>">
<td><input type="submit" class="btn btn-primary" value="Predict"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!--End Advanced Tables -->
<?php } ?>
</div>
</div>
<div class="row">
<!-- Modal -->
<div class="modal fade" id="modal-hasil" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<center><h4><strong>Prediksi Pengunduran Diri</strong></h4></center>
<h4 class="form-wording" id="myModalLabel"></h4>
</div>
<div class="modal-body">
<center><h5><b>Status: <span class="status"></span></b></h5></center>
<br>
<h5>Persentase Mengundurkan Diri: <b><span class="percentage_do"></span> %</b></h5>
<h5>Persentase Tidak Mengundurkan Diri: <b><span class="percentage_not_do"></span> %</b></h5>
<h5><b><span class="alasan"></span></b></h5>
<h5><b><span class="solusi"></span></b></h5>
<h5><b><span class="dampak"></span></b></h5>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<!-- End Modals-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
//autocomplete
$('#auto').autocomplete({
source: "searchName.php",
minLength: 1
});
});
$("#form-predict").submit(function(e) {
var url = "http://0.0.0.0:5000/api/v1.0/predict";
var data = $("#form-predict").serialize()
console.log("data", data)
$.ajax({
type: "POST",
url: url,
data: data, // serializes the form's elements.
success: function(data)
{
$('#modal-hasil').modal('show');
$('.percentage_do').html((data.response.percentage_do)*100);
$('.percentage_not_do').html((data.response.percentage_not_do)*100);
if (data.response.status == 1) {
var nim = data.response.nim;
var ipk = data.response.ipk;
var semester = data.response.semester;
var penghasilan = data.response.penghasilan;
var jarak = data.response.jarak;
var beasiswa = data.response.beasiswa;
var angkatan = nim.substring(0, 4);
if (angkatan == '2010') {
var pembagiSMT = 14;
} else if (angkatan == '2011') {
var pembagiSMT = 12;
} else if (angkatan == '2012') {
var pembagiSMT = 10;
} else if (angkatan == '2013') {
var pembagiSMT = 8;
} else if (angkatan == '2014') {
var pembagiSMT = 6;
} else if (angkatan == '2015') {
var pembagiSMT = 4;
}
normalizedIPK = ipk / 4;
normalizedPenghasilan = penghasilan / 8;
normalizedJarak = 1 - (jarak / 42);
normalizedSMT = semester / pembagiSMT;
if (normalizedIPK < normalizedSMT && normalizedIPK < normalizedPenghasilan && normalizedIPK < normalizedJarak) {
if(beasiswa == 1){
var alasan = 'IPK rendah';
var dampak = 'Beasiswa yang didapat akan dicabut';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.dampak').html("Dampak: " + dampak);
}else{
var alasan = 'IPK rendah';
var solusi = 'Untuk diberikan binaan agar IPK naik';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.solusi').html("Solusi: " + solusi);
}
} else if (normalizedPenghasilan < normalizedIPK && normalizedPenghasilan < normalizedJarak && normalizedPenghasilan < normalizedSMT) {
if(beasiswa == 1){
$('.status').html("Tidak Mengundurkan Diri");
}else{
var alasan = 'Penghasilan Orang Tua Rendah';
var solusi = 'Disarankan mengajukan beasiswa';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.solusi').html("Solusi: " + solusi);
}
} else if (normalizedJarak < normalizedIPK && normalizedJarak < normalizedPenghasilan && normalizedJarak < normalizedSMT) {
var alasan = 'Jarak menuju kampus jauh';
var solusi = 'Disarankan untuk sewa kos didekat kampus';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.solusi').html("Solusi: " + solusi);
}else if(normalizedSMT < normalizedIPK && normalizedSMT < normalizedPenghasilan && normalizedSMT < normalizedJarak){
if(beasiswa == 1){
var alasan = 'Semester yang ditempuh kurang';
var dampak = 'Beasiswa yang didapat akan dicabut';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.dampak').html("Dampak: " + dampak);
}else{
var alasan = 'Semester yang ditempuh kurang';
var solusi = 'Disarankan agar tidak mengajukan cuti akademik';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.solusi').html("Solusi: " + solusi);
}
}else{
if(beasiswa == 1){
var alasan = 'Semester yang ditempuh kurang';
var dampak = 'Beasiswa yang didapat akan dicabut';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.dampak').html("Dampak: " + dampak);
}else{
var alasan = 'Semester yang ditempuh kurang';
var solusi = 'Disarankan agar tidak mengajukan cuti akademik';
$('.status').html("<font color=red>Mengundurkan Diri</font>");
$('.alasan').html("Alasan: " + alasan);
$('.solusi').html("Solusi: " + solusi);
}
}
console.log("normalized ipk", normalizedIPK);
console.log("normalized semester", normalizedSMT);
console.log("normalized penghasilan", normalizedPenghasilan);
console.log("normalized jarak", normalizedJarak);
console.log("alasan", alasan);
}else{
$('.status').html("Tidak Mengundurkan Diri");
}
},
error: function (request, status, error) {
alert(request.responseText);
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
</script>