-
Notifications
You must be signed in to change notification settings - Fork 87
/
do_test_header.php
97 lines (77 loc) · 4.4 KB
/
do_test_header.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
<?php
/**************************************************************
"Learning with Texts" (LWT) is released into the Public Domain.
This applies worldwide.
In case this is not legally possible, any entity is granted the
right to use this work for any purpose, without any conditions,
unless such conditions are required by law.
Developed by J. Pierre in 2011.
***************************************************************/
/**************************************************************
Call: do_test_header.php?lang=[langid]
Call: do_test_header.php?text=[textid]
Call: do_test_header.php?selection=1
(SQL via $_SESSION['testsql'])
Show test header frame
***************************************************************/
include "connect.inc.php";
include "settings.inc.php";
include "utilities.inc.php";
$p = '';
$message = '';
if (isset($_REQUEST['selection']) && isset($_SESSION['testsql'])) {
$p = "selection=" . $_REQUEST['selection'];
$testsql = $_SESSION['testsql'];
$totalcount = get_first_value('select count(distinct WoID) as value from ' . $testsql);
$title = 'Selected ' . $totalcount . ' Term' . ($totalcount==1 ? '' : 's');
$cntlang = get_first_value('select count(distinct WoLgID) as value from ' . $testsql);
if ($cntlang > 1)
$message = 'Error: The selected terms are in ' . $cntlang . ' languages, but tests are only possible in one language at a time.';
else
$title .= ' in ' . get_first_value('select LgName as value from languages, ' . $testsql . ' and LgID = WoLgID limit 1');
}
if (isset($_REQUEST['lang'])) {
$langid = getreq('lang');
$p = "lang=" . $langid;
$title = "All Terms in " . get_first_value('select LgName as value from languages where LgID = ' . $langid);
$testsql = ' words where WoLgID = ' . $langid . ' ';
}
if (isset($_REQUEST['text'])) {
$textid = getreq('text');
$p = "text=" . $textid;
$title = get_first_value('select TxTitle as value from texts where TxID = ' . $textid);
saveSetting('currenttext',$_REQUEST['text']);
$testsql = ' words, textitems where TiLgID = WoLgID and TiTextLC = WoTextLC and TiTxID = ' . $textid . ' ';
}
if ($p == '') die("Called with wrong parameters");
$totalcountdue = get_first_value('SELECT count(distinct WoID) as value FROM ' . $testsql . ' AND WoStatus BETWEEN 1 AND 5 AND WoTranslation != \'\' AND WoTranslation != \'*\' AND WoTodayScore < 0');
pagestart_nobody(tohtml($title));
echo '<h4>';
echo '<a href="edit_texts.php" target="_top">';
echo '<img src="img/lwt_icon.png" class="lwtlogo" alt="Logo" />Learning with Texts';
echo '</a> | ';
quickMenu();
if (substr($p,0,4) == 'text') {
echo ' | <a href="do_text.php?start=' . $textid . '" target="_top"><img src="icn/book-open-bookmark.png" title="Read" alt="Read" /></a> <a href="print_text.php?text=' . $textid . '" target="_top"><img src="icn/printer.png" title="Print" alt="Print" /></a>';
}
echo '</h4><table><tr><td><h3>TEST ▶</h3></td><td class="width99pc"><h3>' . tohtml($title) . ' (Due: ' . $totalcountdue . ')</h3></td></tr><tr><td colspan="2">';
$_SESSION['teststart'] = gmmktime() + 2;
$_SESSION['testcorrect'] = 0;
$_SESSION['testwrong'] = 0;
$_SESSION['testtotal'] = $totalcountdue;
if ($message != '') {
echo error_message_with_hide($message,1);
}
else { // OK
?>
<p><b>Choose:</b>
<input type="button" value="..[L2].." onclick="{parent.frames['ro'].location.href='empty.htm'; parent.frames['ru'].location.href='empty.htm'; parent.frames['l'].location.href='do_test_test.php?type=1&<?php echo $p; ?>';}" />
<input type="button" value="..[L1].." onclick="{parent.frames['ro'].location.href='empty.htm'; parent.frames['ru'].location.href='empty.htm'; parent.frames['l'].location.href='do_test_test.php?type=2&<?php echo $p; ?>';}" />
<input type="button" value="..[••].." onclick="{parent.frames['ro'].location.href='empty.htm'; parent.frames['ru'].location.href='empty.htm'; parent.frames['l'].location.href='do_test_test.php?type=3&<?php echo $p; ?>';}" /> |
<input type="button" value="[L2]" onclick="{parent.frames['ro'].location.href='empty.htm'; parent.frames['ru'].location.href='empty.htm'; parent.frames['l'].location.href='do_test_test.php?type=4&<?php echo $p; ?>';}" />
<input type="button" value="[L1]" onclick="{parent.frames['ro'].location.href='empty.htm'; parent.frames['ru'].location.href='empty.htm'; parent.frames['l'].location.href='do_test_test.php?type=5&<?php echo $p; ?>';}" />
</p></td></tr></table>
<?php
}
pageend();
?>