-
Notifications
You must be signed in to change notification settings - Fork 1
/
declquiz.php
111 lines (103 loc) · 3.86 KB
/
declquiz.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
<? include 'build.php' ?>
<?
$decl = $_POST["decl"];
$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" src="decline.js"></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'], "noun"))
continue;
if (!$vocab[$i]['DECLENSION'])
continue;
if ($decl) {
if ($vocab[$i]['DECLENSION'] != $decl)
continue;
}
$list[$num++] = array($vocab[$i]['PLURAL'], $vocab[$i]['LATIN'],
$vocab[$i]['DECLENSION'], $vocab[$i]['GENDER']);
}
if ($start == $end)
$count = sizeof($list);
if (!sizeof($list)) {
print "<tr><td>There aren't any nouns to quiz you on!</td></tr>";
} else while ($count && sizeof($list)) {
$i = rand(0, sizeof($list) - 1);
$parts = preg_split("/, /", $list[$i][1]);
$types = array("Nom", "Gen", "Dat", "Acc", "Abl", "Voc");
// try to do Voc less often
$j = rand(0, 10);
if ($j > 5) $j -= 6;
$type = $types[$j];
$n = $list[$i][0] ? 2 : rand(1, 2);
?>
<tr>
<td><? print $type . ". " . ($n == 1 ? "Sg" : "Pl") . ". of " . $parts[0] ?></td>
<td>
<form onsubmit="return checkAnswer(<? print $count ?>,
'<? print $type ?>',
<? print $n ?>,
'<? print $list[$i][1] ?>',
'<? print $list[$i][2] ?>',
'<? print $list[$i][3] ?>',
true)">
<input id="<? print $n . $type . $count ?>" />
</form>
</td>
<td><label id="result<? print $n . $type . $count ?>"></td>
</tr>
<?
$count--;
array_splice($list, $i, 1);
}
?>
</table>
<hr />
<p><form action="declquiz.php" method="post">
Quiz
<select name="decl">
<option value="0"<? if ($decl == 0) { print " selected=\"selected\""; } ?>>all</option>
<option value="1"<? if ($decl == 1) { print " selected=\"selected\""; } ?>>first</option>
<option value="2"<? if ($decl == 2) { print " selected=\"selected\""; } ?>>second</option>
<option value="3"<? if ($decl == 3) { print " selected=\"selected\""; } ?>>third</option>
<option value="3i"<? if ($decl == "3i") { print " selected=\"selected\""; } ?>>third, i-stem</option>
<option value="4"<? if ($decl == 4) { print " selected=\"selected\""; } ?>>fourth</option>
<option value="5"<? if ($decl == 5) { print " selected=\"selected\""; } ?>>fifth</option>
</select>
declensions for nouns (random cases) 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>