forked from chaosarium/lwt
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathstatistics.php
399 lines (357 loc) · 16.7 KB
/
statistics.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?php
/**
* Display statistics
*
* Call: statistics.php
*
* PHP version 8.1
*
* @category User_Interface
*/
namespace Lwt\Interface\Statistics;
require_once 'inc/session_utility.php';
pagestart('My Statistics', true);
?>
<h2>Learning Intensity</h2>
<p>Breakdown by Language and Term Status <wbr />(Click on numbers to see the list of terms)</p>
<table class="tab1" cellspacing="0" cellpadding="5">
<tr>
<th class="th1">Language</th>
<th class="th1">Total<br /></th>
<th class="th1">Active<br />(1..5)</th>
<th class="th1">Learning<br />(1..4)</th>
<th class="th1">Unknown<br />(1)</th>
<th class="th1">Learning<br />(2)</th>
<th class="th1">Learning<br />(3)</th>
<th class="th1">Learning<br />(4)</th>
<th class="th1">Learned<br />(5)</th>
<th class="th1">Well<br />Known<br />(99)</th>
<th class="th1">Known<br />(5+99)</th>
<th class="th1">Ign.<br />(98)</th>
</tr>
<?php
$sum1 = 0;
$sum2 = 0;
$sum3 = 0;
$sum4 = 0;
$sum5 = 0;
$sum98 = 0;
$sum99 = 0;
$sum14 = 0;
$sum15 = 0;
$sum599 = 0;
$sumall = 0;
$sql = 'SELECT WoLgID,WoStatus,count(*) AS value FROM ' . $tbpref . 'words GROUP BY WoLgID,WoStatus';
$res = do_mysqli_query($sql);
$term_stat = null;
while ($record = mysqli_fetch_assoc($res)) {
$term_stat[$record['WoLgID']][$record['WoStatus']]=$record['value'];
}
$sql = 'SELECT LgID, LgName FROM ' . $tbpref . 'languages where LgName<>"" ORDER BY LgName';
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$lang = $record['LgID'];
$s1 = isset($term_stat[$record['LgID']][1])?($term_stat[$record['LgID']][1]):0;
$s2 = isset($term_stat[$record['LgID']][2])?($term_stat[$record['LgID']][2]):0;
$s3 = isset($term_stat[$record['LgID']][3])?($term_stat[$record['LgID']][3]):0;
$s4 = isset($term_stat[$record['LgID']][4])?($term_stat[$record['LgID']][4]):0;
$s5 = isset($term_stat[$record['LgID']][5])?($term_stat[$record['LgID']][5]):0;
$s98 = isset($term_stat[$record['LgID']][98])?($term_stat[$record['LgID']][98]):0;
$s99 = isset($term_stat[$record['LgID']][99])?($term_stat[$record['LgID']][99]):0;
$s14 = $s1 + $s2 + $s3 + $s4;
$s15 = $s14 + $s5;
$s599 = $s5 + $s99;
$all = $s15 + $s98 + $s99;
$sum1 += $s1;
$sum2 += $s2;
$sum3 += $s3;
$sum4 += $s4;
$sum5 += $s5;
$sum98 += $s98;
$sum99 += $s99;
$sum14 += $s14;
$sum15 += $s15;
$sum599 += $s599;
$sumall += $all;
echo '<tr>';
echo '<td class="td1">' . tohtml($record['LgName']) . '</td>';
echo '<td class="td1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=&tag12=0&tag2=&tag1="><b>' . $all . '</b></a></td>';
echo '<td class="td1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=15&tag12=0&tag2=&tag1="><b>' . $s15 . '</b></a></td>';
echo '<td class="td1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=14&tag12=0&tag2=&tag1="><b>' . $s14 . '</b></a></td>';
echo '<td class="td1 center"><span class="status1"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=1&tag12=0&tag2=&tag1=">' . $s1 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status2"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=2&tag12=0&tag2=&tag1=">' . $s2 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status3"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=3&tag12=0&tag2=&tag1=">' . $s3 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status4"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=4&tag12=0&tag2=&tag1=">' . $s4 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status5"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=5&tag12=0&tag2=&tag1=">' . $s5 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status99"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=99&tag12=0&tag2=&tag1=">' . $s99 . '</a> </span></td>';
echo '<td class="td1 center"><span class="status5stat"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=599&tag12=0&tag2=&tag1="><b>' . $s599 . '</b></a> </span></td>';
echo '<td class="td1 center"><span class="status98"> <a href="edit_words.php?page=1&text=&query=&filterlang=' . $lang . '&status=98&tag12=0&tag2=&tag1="><b>' . $s98 . '</b></a> </span></td>';
echo '</tr>';
}
mysqli_free_result($res);
echo '<tr>';
echo '<th class="th1"><b>TOTAL</b></th>';
echo '<th class="th1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=&status=&tag12=0&tag2=&tag1="><b>' . $sumall . '</b></a></th>';
echo '<th class="th1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=&status=15&tag12=0&tag2=&tag1="><b>' . $sum15 . '</b></a></th>';
echo '<th class="th1 center"><a href="edit_words.php?page=1&text=&query=&filterlang=&status=14&tag12=0&tag2=&tag1="><b>' . $sum14 . '</b></a></th>';
echo '<th class="th1 center"><span class="status1"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=1&tag12=0&tag2=&tag1="><b>' . $sum1 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status2"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=2&tag12=0&tag2=&tag1="><b>' . $sum2 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status3"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=3&tag12=0&tag2=&tag1="><b>' . $sum3 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status4"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=4&tag12=0&tag2=&tag1="><b>' . $sum4 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status5"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=5&tag12=0&tag2=&tag1="><b>' . $sum5 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status99"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=99&tag12=0&tag2=&tag1="><b>' . $sum99 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status5stat"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=599&tag12=0&tag2=&tag1="><b>' . $sum599 . '</b></a> </span></th>';
echo '<th class="th1 center"><span class="status98"> <a href="edit_words.php?page=1&text=&query=&filterlang=&status=98&tag12=0&tag2=&tag1="><b>' . $sum98 . '</b></a> </span></th>';
echo '</tr>';
?>
</table>
<?php
$sumct = 0;
$sumat = 0;
$sumkt = 0;
$sumcy = 0;
$sumay = 0;
$sumky = 0;
$sumcw = 0;
$sumaw = 0;
$sumkw = 0;
$sumcm = 0;
$sumam = 0;
$sumkm = 0;
$sumca = 0;
$sumaa = 0;
$sumka = 0;
$sumcall = 0;
$sumaall = 0;
$sumkall = 0;
?>
<h2>Learning Frequency</h2>
<p>Breakdown by Language and Time Range <wbr />(Terms created (C), Terms changed status = Activity (A), Terms set to "Known" (K))</p>
<table class="tab1" cellspacing="0" cellpadding="5">
<tr>
<th class="th1" rowspan="2">Language</th>
<th class="th1" colspan="3">Today</th>
<th class="th1" colspan="3">Yesterday</th>
<th class="th1" colspan="3">Last 7 d</th>
<th class="th1" colspan="3">Last 30 d</th>
<th class="th1" colspan="3">Last 365 d</th>
<th class="th1" colspan="3">All Time</th>
</tr>
<tr>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
<th class="th1">C</th>
<th class="th1">A</th>
<th class="th1">K</th>
</tr>
<?php
$sql = 'select WoLgID,TO_DAYS(curdate())-TO_DAYS(cast(WoCreated as date)) Created,count(WoID) as value from ' . $tbpref . 'words where WoStatus in (1,2,3,4,5,99) GROUP BY WoLgID,Created';
$res = do_mysqli_query($sql);
$term_created = null;
while ($record = mysqli_fetch_assoc($res)) {
$term_created[$record['WoLgID']][$record['Created']]=$record['value'];
}
$sql = 'select WoLgID,WoStatus,TO_DAYS(curdate())-TO_DAYS(cast(WoStatusChanged as date)) Changed,count(WoID) as value from ' . $tbpref . 'words GROUP BY WoLgID,WoStatus,WoStatusChanged';
$res = do_mysqli_query($sql);
$term_active = null;
$term_known = null;
while ($record = mysqli_fetch_assoc($res)) {
if(!empty($record['WoStatus'])) {
switch($record['WoStatus']){
case ($record['WoStatus']==5 || $record['WoStatus']==99):
if(!isset($term_known[$record['WoLgID']][$record['Changed']])) {
$term_known[$record['WoLgID']][$record['Changed']]=0;
}
$term_known[$record['WoLgID']][$record['Changed']]+=$record['value'];
if(!isset($term_active[$record['WoLgID']][$record['Changed']])) {
$term_active[$record['WoLgID']][$record['Changed']]=0;
}
$term_active[$record['WoLgID']][$record['Changed']]+=$record['value'];
break;
case ($record['WoStatus']>0 and $record['WoStatus']<5):
if(!isset($term_active[$record['WoLgID']][$record['Changed']])) {
$term_active[$record['WoLgID']][$record['Changed']]=0;
}
$term_active[$record['WoLgID']][$record['Changed']]+=$record['value'];
break;
default:
break;
}
}
}
$sql = 'SELECT LgID, LgName FROM ' . $tbpref . 'languages where LgName<>"" ORDER BY LgName';
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$cw=0;
$cm=0;
$ca=0;
$call=0;
$aw=0;
$am=0;
$aa=0;
$aall=0;
$kw=0;
$km=0;
$ka=0;
$kall=0;
if(isset($term_created[$record['LgID']])) {
foreach($term_created[$record['LgID']] as $created => $val){
switch ($created){
case($created==='0'):
$cw+=$val;
break;
case ($created>364):
$call+=$val;
break;
case ($created>29):
$ca+=$val;
break;
case ($created>6):
$cm+=$val;
break;
default:
$cw+=$val;
break;
}
}
}
$ct=isset($term_created[$record['LgID']][0])?$term_created[$record['LgID']][0]:0;
$cy=isset($term_created[$record['LgID']][1])?$term_created[$record['LgID']][1]:0;
$cm+=$cw;
$ca+=$cm;
$call+=$ca;
if(isset($term_active[$record['LgID']])) {
foreach($term_active[$record['LgID']] as $active=>$val){
switch ($active){
case($active==='0'):
$aw+=$val;
break;
case ($active>364):
$aall+=$val;
break;
case ($active>29):
$aa+=$val;
break;
case ($active>6):
$am+=$val;
break;
default:
$aw+=$val;
break;
}
}
}
$at=isset($term_active[$record['LgID']][0])?$term_active[$record['LgID']][0]:0;
$ay=isset($term_active[$record['LgID']][1])?$term_active[$record['LgID']][1]:0;
$am+=$aw;
$aa+=$am;
$aall+=$aa;
if(isset($term_known[$record['LgID']])) {
foreach($term_known[$record['LgID']] as $known=>$val){
switch ($known){
case($known==='0'):
$kw+=$val;
break;
case ($known>364):
$kall+=$val;
break;
case ($known>29):
$ka+=$val;
break;
case ($known>6):
$km+=$val;
break;
default:
$kw+=$val;
break;
}
}
}
$kt=isset($term_known[$record['LgID']][0])?$term_known[$record['LgID']][0]:0;
$ky=isset($term_known[$record['LgID']][1])?$term_known[$record['LgID']][1]:0;
$km+=$kw;
$ka+=$km;
$kall+=$ka;
$sumct += $ct;
$sumat += $at;
$sumkt += $kt;
$sumcy += $cy;
$sumay += $ay;
$sumky += $ky;
$sumcw += $cw;
$sumaw += $aw;
$sumkw += $kw;
$sumcm += $cm;
$sumam += $am;
$sumkm += $km;
$sumca += $ca;
$sumaa += $aa;
$sumka += $ka;
$sumcall += $call;
$sumaall += $aall;
$sumkall += $kall;
echo '<tr>';
echo '<td class="td1">' . tohtml($record['LgName']) . '</td>';
echo '<td class="td1 center"><span class="status1"> ' . $ct . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $at . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $kt . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $cy . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $ay . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $ky . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $cw . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $aw . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $kw . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $cm . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $am . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $km . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $ca . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $aa . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $ka . ' </span></td>';
echo '<td class="td1 center"><span class="status1"> ' . $call . ' </span></td>';
echo '<td class="td1 center"><span class="status3"> ' . $aall . ' </span></td>';
echo '<td class="td1 center"><span class="status5stat"> ' . $kall . ' </span></td>';
echo '</tr>';
}
mysqli_free_result($res);
echo '<tr>';
echo '<th class="th1"><b>TOTAL</b></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumct . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumat . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkt . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcy . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumay . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumky . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcw . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumaw . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkw . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcm . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumam . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkm . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumca . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumaa . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumka . ' </span></th>';
echo '<th class="th1 center"><span class="status1"> ' . $sumcall . ' </span></th>';
echo '<th class="th1 center"><span class="status3"> ' . $sumaall . ' </span></th>';
echo '<th class="th1 center"><span class="status5stat"> ' . $sumkall . ' </span></th>';
echo '</tr>';
?>
</table>
<p>
<input type="button" value="<< Back" onclick="location.href='index.php';" />
</p>
<?php
pageend();
?>