forked from andreask7/lwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_test_table.php
235 lines (201 loc) · 9.46 KB
/
do_test_table.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
<?php
/**************************************************************
"Learning with Texts" (LWT) is free and unencumbered software
released into the PUBLIC DOMAIN.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a
compiled binary, for any purpose, commercial or non-commercial,
and by any means.
In jurisdictions that recognize copyright laws, the author or
authors of this software dedicate any and all copyright
interest in the software to the public domain. We make this
dedication for the benefit of the public at large and to the
detriment of our heirs and successors. We intend this
dedication to be an overt act of relinquishment in perpetuity
of all present and future rights to this software under
copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
For more information, please refer to [http://unlicense.org/].
***************************************************************/
/**************************************************************
Call: do_test_table.php?lang=[langid]
Call: do_test_test.php?text=[textid]
Call: do_test_test.php?&selection=1
(SQL via $_SESSION['testsql'])
Show test frame with vocab table
***************************************************************/
require_once( 'settings.inc.php' );
require_once( 'connect.inc.php' );
require_once( 'dbutils.inc.php' );
require_once( 'utilities.inc.php' );
$p = '';
if (isset($_REQUEST['selection']) && isset($_SESSION['testsql'])) {
$testsql = $_SESSION['testsql'];
}
elseif (isset($_REQUEST['lang'])) {
$testsql = ' ' . $tbpref . 'words where WoLgID = ' . $_REQUEST['lang'] . ' ';
}
elseif (isset($_REQUEST['text'])) {
$testsql = ' ' . $tbpref . 'words, ' . $tbpref . 'textitems2 where Ti2LgID = WoLgID and Ti2WoID = WoID and Ti2TxID = ' . $_REQUEST['text'] . ' ';
}
else my_die("do_test_table.php called with wrong parameters");
pagestart_nobody('','html, body { margin:3px; padding:0; }');
$cntlang = get_first_value('select count(distinct WoLgID) as value from ' . $testsql);
if ($cntlang > 1) {
echo '<p>Sorry - The selected terms are in ' . $cntlang . ' languages, but tests are only possible in one language at a time.</p>';
pageend();
exit();
}
$lang = get_first_value('select WoLgID as value from ' . $testsql . ' limit 1');
if (! isset($lang)) {
echo '<p class="center"> <br />Sorry - No terms to display or to test at this time.</p>';
pageend();
exit();
}
$sql = 'select LgTextSize, LgRegexpWordCharacters, LgRightToLeft from ' . $tbpref . 'languages where LgID = ' . $lang;
$res = do_mysqli_query($sql);
$record = mysqli_fetch_assoc($res);
$textsize = round(($record['LgTextSize']-100)/2,0)+100;
$regexword = $record['LgRegexpWordCharacters'];
$rtlScript = $record['LgRightToLeft'];
mysqli_free_result($res);
$span1 = ($rtlScript ? '<span dir="rtl">' : '');
$span2 = ($rtlScript ? '</span>' : '');
$currenttabletestsetting1 = getSettingZeroOrOne('currenttabletestsetting1',1);
$currenttabletestsetting2 = getSettingZeroOrOne('currenttabletestsetting2',1);
$currenttabletestsetting3 = getSettingZeroOrOne('currenttabletestsetting3',0);
$currenttabletestsetting4 = getSettingZeroOrOne('currenttabletestsetting4',1);
$currenttabletestsetting5 = getSettingZeroOrOne('currenttabletestsetting5',0);
$currenttabletestsetting6 = getSettingZeroOrOne('currenttabletestsetting6',1);
?>
<script type="text/javascript">
//<![CDATA[
$(document).ready( function() {
$('#cbEdit').change(function() {
if($('#cbEdit').is(':checked')) {
$('td:nth-child(1),th:nth-child(1)').show();
do_ajax_save_setting('currenttabletestsetting1','1');
} else {
$('td:nth-child(1),th:nth-child(1)').hide();
do_ajax_save_setting('currenttabletestsetting1','0');
}
$('th,td').css('border-top-left-radius','').css('border-bottom-left-radius','');
$('th:visible').eq(0).css('border-top-left-radius','inherit').css('border-bottom-left-radius','0px');
$('tr:last-child>td:visible').eq(0).css('border-bottom-left-radius','inherit');
});
$('#cbStatus').change(function() {
if($('#cbStatus').is(':checked')) {
$('td:nth-child(2),th:nth-child(2)').show();
do_ajax_save_setting('currenttabletestsetting2','1');
} else {
$('td:nth-child(2),th:nth-child(2)').hide();
do_ajax_save_setting('currenttabletestsetting2','0');
}
$('th,td').css('border-top-left-radius','').css('border-bottom-left-radius','');
$('th:visible').eq(0).css('border-top-left-radius','inherit').css('border-bottom-left-radius','0px');
$('tr:last-child>td:visible').eq(0).css('border-bottom-left-radius','inherit');
});
$('#cbTerm').change(function() {
if($('#cbTerm').is(':checked')) {
$('td:nth-child(3)').css('color', 'black').css('cursor', 'auto');
do_ajax_save_setting('currenttabletestsetting3','1');
} else {
$('td:nth-child(3)').css('color', 'white').css('cursor', 'pointer');
do_ajax_save_setting('currenttabletestsetting3','0');
}
});
$('#cbTrans').change(function() {
if($('#cbTrans').is(':checked')) {
$('td:nth-child(4)').css('color', 'black').css('cursor', 'auto');
do_ajax_save_setting('currenttabletestsetting4','1');
} else {
$('td:nth-child(4)').css('color', 'white').css('cursor', 'pointer');
do_ajax_save_setting('currenttabletestsetting4','0');
}
});
$('#cbRom').change(function() {
if($('#cbRom').is(':checked')) {
$('td:nth-child(5),th:nth-child(5)').show();
do_ajax_save_setting('currenttabletestsetting5','1');
} else {
$('td:nth-child(5),th:nth-child(5)').hide();
do_ajax_save_setting('currenttabletestsetting5','0');
}
$('th,td').css('border-top-right-radius','').css('border-bottom-right-radius','');
$('th:visible:last').css('border-top-right-radius','inherit');
$('tr:last-child>td:visible:last').css('border-bottom-right-radius','inherit');
});
$('#cbSentence').change(function() {
if($('#cbSentence').is(':checked')) {
$('td:nth-child(6),th:nth-child(6)').show();
do_ajax_save_setting('currenttabletestsetting6','1');
} else {
$('td:nth-child(6),th:nth-child(6)').hide();
do_ajax_save_setting('currenttabletestsetting6','0');
}
$('th,td').css('border-top-right-radius','').css('border-bottom-right-radius','');
$('th:visible:last').css('border-top-right-radius','inherit');
$('tr:last-child>td:visible:last').css('border-bottom-right-radius','inherit');
});
$('td').click(function() {
$(this).css('color', 'black').css('cursor', 'auto');
});
$('td').css('background-color', 'white');
$('#cbEdit').change();
$('#cbStatus').change();
$('#cbTerm').change();
$('#cbTrans').change();
$('#cbRom').change();
$('#cbSentence').change();
});
//]]>
</script>
<p>
<input type="checkbox" id="cbEdit" <?php echo get_checked($currenttabletestsetting1); ?> /> Edit
<input type="checkbox" id="cbStatus" <?php echo get_checked($currenttabletestsetting2); ?> /> Status
<input type="checkbox" id="cbTerm" <?php echo get_checked($currenttabletestsetting3); ?> /> Term
<input type="checkbox" id="cbTrans" <?php echo get_checked($currenttabletestsetting4); ?> /> Translation
<input type="checkbox" id="cbRom" <?php echo get_checked($currenttabletestsetting5); ?> /> Romanization
<input type="checkbox" id="cbSentence" <?php echo get_checked($currenttabletestsetting6); ?> /> Sentence
</p>
<table class="sortable tab1" style="width:auto;" cellspacing="0" cellpadding="5">
<tr>
<th class="th1">Ed</th>
<th class="th1 clickable">Status</th>
<th class="th1 clickable">Term</th>
<th class="th1 clickable">Translation</th>
<th class="th1 clickable">Romanization</th>
<th class="th1 clickable">Sentence</th>
</tr>
<?php
$sql = 'SELECT DISTINCT WoID, WoText, WoTranslation, WoRomanization, WoSentence, WoStatus, WoTodayScore As Score FROM ' . $testsql . ' AND WoStatus BETWEEN 1 AND 5 AND WoTranslation != \'\' AND WoTranslation != \'*\' order by WoTodayScore, WoRandom*RAND()';
if ($debug) echo $sql;
$res = do_mysqli_query($sql);
while ($record = mysqli_fetch_assoc($res)) {
$sent = tohtml(repl_tab_nl($record["WoSentence"]));
$sent1 = str_replace("{", ' <b>[', str_replace("}", ']</b> ',
mask_term_in_sentence($sent,$regexword)));
?>
<tr>
<td class="td1 center" nowrap="nowrap"><a href="edit_tword.php?wid=<?php echo $record['WoID']; ?>" target="ro"><img src="icn/sticky-note--pencil.png" title="Edit Term" alt="Edit Term" /></a></td>
<td class="td1 center" nowrap="nowrap"><span id="STAT<?php echo $record['WoID']; ?>"><?php echo make_status_controls_test_table($record['Score'], $record['WoStatus'], $record['WoID']); ?></span></td>
<td class="td1 center" style="font-size:<?php echo $textsize; ?>%;"><?php echo $span1; ?><span id="TERM<?php echo $record['WoID']; ?>"><?php echo tohtml($record['WoText']); ?></span><?php echo $span2; ?></td>
<td class="td1 center"><span id="TRAN<?php echo $record['WoID']; ?>"><?php echo tohtml($record['WoTranslation']); ?></span></td>
<td class="td1 center"><span id="ROMA<?php echo $record['WoID']; ?>"><?php echo tohtml($record['WoRomanization']); ?></span></td>
<td class="td1 center" style="color:#000;"><?php echo $span1; ?><span id="SENT<?php echo $record['WoID']; ?>"><?php echo $sent1; ?></span><?php echo $span2; ?></td>
</tr>
<?php
}
mysqli_free_result($res);
?>
</table>
<?php
pageend();
?>