Implemented conjugation type options.

This commit is contained in:
doncr 2016-12-25 15:30:53 +00:00
parent 8d4c49ab71
commit fbaff068ea
3 changed files with 137 additions and 96 deletions

View File

@ -139,6 +139,22 @@ div#history table th {
text-align: left;
}
div.options > * {
display: inline-block;
vertical-align: top;
margin: 20px;
}
div#splash > * {
margin-left: auto;
margin-right: auto;
display: table;
}
input#numQuestions {
width: 60px;
}
/* Tooltip from http://jsfiddle.net/AndreaLigios/jtLbpy62/ */
[tooltip]:before {

View File

@ -10,45 +10,44 @@
<body>
<div id="splash">
<h1>Don's Japanese Conjugation Drill</h1>
<div>
<span>Number of Questions</span>
<input id="numQuestions" value="10">
<button id="go">Go</button>
</div>
<div>
<h2>Conjugation types</h2>
<ul>
<li><label><input type="checkbox" id="polite" checked="true"> Polite</label></li>
<li><label><input type="checkbox" id="negative" checked="true"> Negative</label></li>
<li><label><input type="checkbox" id="te-form"> て form</label></li>
<!--
<li><label><input type="checkbox" id="potential"> Potential</label></li>
<li><label><input type="checkbox" id="imperative"> Imperative</label></li>
<li><label><input type="checkbox" id="passive"> Passive</label></li>
<li><label><input type="checkbox" id="causative"> Causative</label></li>
-->
</ul>
<div class="options">
<div>
<h2>Conjugation types</h2>
<ul>
<li><label><input type="checkbox" id="polite" checked> Polite</label></li>
<li><label><input type="checkbox" id="negative" checked> Negative</label></li>
<li><label><input type="checkbox" id="past" checked> Past</label></li>
<li><label><input type="checkbox" id="te-form" checked> て form</label></li>
<li><label><input type="checkbox" id="potential"> Potential</label></li>
<li><label><input type="checkbox" id="imperative"> Imperative</label></li>
<li><label><input type="checkbox" id="passive"> Passive</label></li>
<li><label><input type="checkbox" id="causative"> Causative</label></li>
</ul>
</div>
<div>
<h2>Verb classes</h2>
<ul>
<li><label><input type="checkbox" id="godan" checked> Group 1 verbs</label></li>
<li><label><input type="checkbox" id="ichidan" checked> Group 2 verbs</label></li>
<li><label><input type="checkbox" id="iku" checked> いく verb</label></li>
<li><label><input type="checkbox" id="kuru" checked> くる verb</label></li>
<li><label><input type="checkbox" id="suru" checked> する verbs</label></li>
</ul>
</div>
</div>
<div>
<h2>Verb classes</h2>
<ul>
<li><label><input type="checkbox" id="godan" checked="true"> Godan verbs</label></li>
<li><label><input type="checkbox" id="godan-mu" checked="true"> Godan verbs with a mu ending</label></li>
<li><label><input type="checkbox" id="godan-ru" checked="true"> Godan verbs with a ru ending</label></li>
<li><label><input type="checkbox" id="godan-u" checked="true"> Godan verbs with an u ending</label></li>
<li><label><input type="checkbox" id="ichidan" checked="true"> Ichidan verbs</label></li>
<li><label><input type="checkbox" id="kuru" checked="true"> Kuru verb</label></li>
<li><label><input type="checkbox" id="iku" checked="true"> Iku verb</label></li>
<li><label><input type="checkbox" id="suru" checked="true"> Suru verbs</label></li>
</ul>
</div>
<button id="go">Go</button>
<div><small>
The quiz refers to negative て forms. In this test, they are assumed to be ~なくて and not ~ないで .
When the test refers to negative て forms, they are assumed to be ~なくて and not ~ないで .
</small></div>
</div>

View File

@ -470,6 +470,8 @@ var conjugations = {
},
};
var log;
Array.prototype.randomElement = function () {
@ -649,71 +651,71 @@ var verb_relative_form = {
"negative" : "て",
},
// "potential" : {
//
// "plain" : "potential",
// "potential negative" : "affirmative",
// },
//
// "potential negative" : {
//
// "potential" : "negative",
// "negative" : "potential",
// },
//
// "imperative" : {
//
// "plain" : "imperative",
// "imperative negative" : "affirmative",
// },
//
// "imperative negative" : {
//
// "imperative" : "negative",
// "negative" : "imperative",
// },
//
// "causative" : {
//
// "plain" : "causative",
// "causative negative" : "affirmative",
// "causative passive" : "active",
// },
//
// "causative negative" : {
//
// "causative" : "negative",
// "negative" : "causative",
// "causative passive negative" : "active",
// },
//
// "passive" : {
//
// "plain" : "passive",
// "passive negative" : "affirmative",
// "causative passive" : "non-causative",
// },
//
// "passive negative" : {
//
// "passive" : "negative",
// "negative" : "passive",
// "causative passive negative" : "non-causative"
// },
//
// "causative passive" : {
//
// "causative" : "passive",
// "passive" : "causative",
// "causative passive negative" : "affirmative",
// },
//
// "causative passive negative" : {
//
// "causative negative" : "passive",
// "passive negative" : "causative",
// "causative passive" : "negative",
// },
"potential" : {
"plain" : "potential",
"potential negative" : "affirmative",
},
"potential negative" : {
"potential" : "negative",
"negative" : "potential",
},
"imperative" : {
"plain" : "imperative",
"imperative negative" : "affirmative",
},
"imperative negative" : {
"imperative" : "negative",
"negative" : "imperative",
},
"causative" : {
"plain" : "causative",
"causative negative" : "affirmative",
"causative passive" : "active",
},
"causative negative" : {
"causative" : "negative",
"negative" : "causative",
"causative passive negative" : "active",
},
"passive" : {
"plain" : "passive",
"passive negative" : "affirmative",
"causative passive" : "non-causative",
},
"passive negative" : {
"passive" : "negative",
"negative" : "passive",
"causative passive negative" : "non-causative"
},
"causative passive" : {
"causative" : "passive",
"passive" : "causative",
"causative passive negative" : "affirmative",
},
"causative passive negative" : {
"causative negative" : "passive",
"passive negative" : "causative",
"causative passive" : "negative",
},
};
function wordWithFurigana(word) {
@ -861,15 +863,39 @@ function generateVerbQuestion() {
var from_form;
var forms;
var count = 0;
while (true) {
if (count++ == 100) {
showSplash();
return;
}
entry = Object.keys(conjugations).randomElement();
to_form = Object.keys(verb_relative_form).randomElement();
from_form = Object.keys(verb_relative_form[to_form]).randomElement();
forms = getVerbForms(entry);
if ((forms["furigana"][from_form]) && (forms["furigana"][to_form])) {
var valid = true;
var types = from_form.split(" ").concat(to_form.split(" "));
types.forEach(function (type) {
if (type != 'plain') {
if ($('#' + type).is(':checked') == false) {
valid = false;
}
}
});
if (!forms["furigana"][from_form])
valid = false;
if (!forms["furigana"][to_form])
valid = false;
if (valid) {
break;
}
}