/
verbs.php
118 lines (108 loc) · 3.65 KB
/
verbs.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
<? include 'build.php' ?>
<?
$part = $_POST["part"];
$start = $_POST["start"];
$end = $_POST["end"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Latin Vocab</title>
<script type="text/javascript">
function checkAnswer(num, conj) {
var check = document.getElementById(num);
var result = document.getElementById("result" + num);
var conjstr = conj.length ? " (" + conj + ")" : '';
if (check.name == check.value) {
result.innerHTML = "<font color=\"green\">Correct!</font> " + check.name + conjstr;
} else {
result.innerHTML = "<font color=\"red\">Incorrect!</font> " + check.name + conjstr;
}
return false;
}
</script>
</head>
<body>
<p><b>Please input your answers and press "Enter" to check them.</b></p>
<p><hr /></p>
<table>
<?
$count = 10;
$num = 0;
for ($i = 0; $i < sizeof($vocab); $i++) {
if ($start || $end) {
if ($end < $start) $end = $start;
if ($vocab[$i]['CHAPTER'] < $start)
continue;
if ($vocab[$i]['CHAPTER'] > $end)
continue;
}
if (strcasecmp($vocab[$i]['TYPE'], "verb"))
continue;
if (isset($vocab[$i]['CONJUGATION']))
$conj[$num] = $vocab[$i]['CONJUGATION'];
else
$conj[$num] = '';
$list[$num++] = preg_split("/, /", $vocab[$i]['LATIN']);
}
if ($start == $end)
$count = sizeof($list);
if (!sizeof($list)) {
print "<tr><td>There aren't any verbs to quiz you on!</td></tr>";
} else while ($count && sizeof($list)) {
$i = rand(0, sizeof($list) - 1);
if (!$part) {
// I like to focus on the last two parts
$j = rand(0, 6);
if ($j > 3) $j -= 2;
if ($j > 3) $j -= 2;
} else {
$j = $part - 1;
}
if (strcasecmp($list[$i][$j], "-")) {
print "<form onsubmit=\"return checkAnswer($count, '$conj[$i]')\"><tr><td>";
for ($k = 0; $k < 4; $k++) {
if ($j == $k) {
$answer = $list[$i][$j];
print "<input name=\"$answer\" id=\"$count\" />";
} else {
print $list[$i][$k];
}
if ($k != 3)
print ", ";
}
print "</td><td><label id=\"result$count\" /></td></tr></form>\n";
$count--;
}
array_splice($list, $i, 1);
}
?>
</table>
<hr />
<p><form action="verbs.php" method="post">
Quiz
<select name="part">
<option value="0"<? if ($part == 0) { print " selected=\"selected\""; } ?>>all</option>
<option value="1"<? if ($part == 1) { print " selected=\"selected\""; } ?>>first</option>
<option value="2"<? if ($part == 2) { print " selected=\"selected\""; } ?>>second</option>
<option value="3"<? if ($part == 3) { print " selected=\"selected\""; } ?>>third</option>
<option value="4"<? if ($part == 4) { print " selected=\"selected\""; } ?>>fourth</option>
</select>
principal parts for verbs from Chapter
<select name="start">
<? for ($i = 1; $i <= 40; $i++): ?>
<option value="<? echo $i; if ($i == $start) echo "\" selected=\"selected" ?>"><? echo $i ?></option>
<? endfor ?>
</select>
to Chapter
<select name="end">
<? for ($i = 1; $i <= 40; $i++): ?>
<option value="<? echo $i; if ($i == $end) echo "\" selected=\"selected" ?>"><? echo $i ?></option>
<? endfor ?>
</select>
<input type="submit" value="Quiz" />
</form></p>
<p><a href="index.php">Return to Main Page</a></p>
</body>
</html>