mirror of
https://github.com/ZetaKebab/japanese-conjugation-drill.git
synced 2025-01-14 22:08:44 +00:00
Changed questions and answer format.
This commit is contained in:
parent
57746de3e8
commit
21a4323191
@ -83,7 +83,7 @@ function kanaForm(words) {
|
|||||||
words = [words];
|
words = [words];
|
||||||
}
|
}
|
||||||
|
|
||||||
return words.map(function (word) { return word.split(/.\[([^\]]*)\]/).join(""); } );
|
return words.map(function (word) { return word.split(/.\[([^\]]*)\]/).join(""); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function kanjiForm(words) {
|
function kanjiForm(words) {
|
||||||
@ -92,7 +92,7 @@ function kanjiForm(words) {
|
|||||||
words = [words];
|
words = [words];
|
||||||
}
|
}
|
||||||
|
|
||||||
return words.map(function (word) { return word.split(/(.)\[[^\]]*\]/).join(""); } );
|
return words.map(function (word) { return word.split(/(.)\[[^\]]*\]/).join(""); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVerbForms(entry) {
|
function getVerbForms(entry) {
|
||||||
@ -271,28 +271,28 @@ function validQuestion(entry, forms, transformation, options) {
|
|||||||
function generateQuestion() {
|
function generateQuestion() {
|
||||||
|
|
||||||
var questionText = {
|
var questionText = {
|
||||||
"affirmative": "What is the affirmative form of",
|
"affirmative": "<span class='first'>make</span> the following <span class='emphasis'>affirmative</span>",
|
||||||
"negative": "What is the negative form of",
|
"negative": "<span class='first'>make</span> the following <span class='emphasis'>negative</span>",
|
||||||
"present": "What is the present form of",
|
"present": "<span class='first'>convert</span> the following to the <span class='emphasis'>present tense</span>",
|
||||||
"past": "What is the past form of",
|
"past": "<span class='first'>convert</span> the following to the <span class='emphasis'>past tense</span>",
|
||||||
"plain": "What is the plain form of",
|
"plain": "<span class='first'>make</span> the following <span class='emphasis'>informal</span>",
|
||||||
"polite": "What is the polite form of",
|
"polite": "<span class='first'>make</span> the following <span class='emphasis'>polite</span>",
|
||||||
"て": "What is the て form of",
|
"て": "<span class='emphasis first'>add</span> the <span class='emphasis'>て pattern</span> to the following",
|
||||||
"non-て": "What is the non-て form of",
|
"non-て": "<span class='emphasis first'>remove</span> the <span class='emphasis'>て pattern</span> from the following",
|
||||||
"potential": "What is the potential form of",
|
"potential": "<span class='first'>make</span> the following <span class='emphasis'>potential</span>",
|
||||||
"non-potential": "What is the non-potential form of",
|
"non-potential": "<span class='first'>make</span> the following <span class='emphasis'>non-potential</span>",
|
||||||
"imperative": "What is the imperative form of",
|
"imperative": "<span class='first'>make</span> the following <span class='emphasis'>imperative</span>",
|
||||||
"non-imperative": "What is the non-imperative form of",
|
"non-imperative": "<span class='first'>make</span> the following <span class='emphasis'>non-imperative</span>",
|
||||||
"causative": "What is the causative form of",
|
"causative": "<span class='first'>make</span> the following <span class='emphasis'>causative</span>",
|
||||||
"non-causative": "What is the non-causative form of",
|
"non-causative": "<span class='first'>make</span> the following <span class='emphasis'>non-causative</span>",
|
||||||
"passive": "What is the passive form of",
|
"passive": "<span class='first'>make</span> the following <span class='emphasis'>passive</span>",
|
||||||
"active": "What is the active form of",
|
"active": "<span class='first'>make</span> the following <span class='emphasis'>active</span>",
|
||||||
"progressive": "What is the progressive form of",
|
"progressive": "<span class='first'>make</span> the following <span class='emphasis'>progressive</span>",
|
||||||
"non-progressive": "What is the non-progressive form of",
|
"non-progressive": "<span class='first'>make</span> the following <span class='emphasis'>non-progressive</span>",
|
||||||
"'desire'": "What is the 'desire' form of",
|
"'desire'": "<span class='first'>convert</span> the following to the <span class='emphasis'>'desire'</span> form",
|
||||||
"'non-desire'": "What is the 'non-desire' form of",
|
"'non-desire'": "<span class='first'>convert</span> the following to the <span class='emphasis'>'non-desire'</span> form",
|
||||||
"volitional": "What is the volitional form of",
|
"volitional": "<span class='first'>make</span> the following <span class='emphasis'>volitional</span>",
|
||||||
"non-volitional": "What is the non-volitional form of"
|
"non-volitional": "<span class='first'>make</span> the following <span class='emphasis'>non-volitional</span>"
|
||||||
};
|
};
|
||||||
|
|
||||||
var entry;
|
var entry;
|
||||||
@ -349,10 +349,14 @@ function generateQuestion() {
|
|||||||
givenWord = wordWithFurigana(furiganaForms[from_form]).randomElement();
|
givenWord = wordWithFurigana(furiganaForms[from_form]).randomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
var questionFirstHalf = questionText[transformation.phrase];
|
var thisQuestionText = questionText[transformation.phrase];
|
||||||
var questionSecondHalf = givenWord + "?";
|
|
||||||
|
|
||||||
var question = questionFirstHalf + questionSecondHalf;
|
// thisQuestionText = thisQuestionText[0].toUpperCase() + thisQuestionText.substring(1);
|
||||||
|
|
||||||
|
var questionFirstHalf = thisQuestionText;
|
||||||
|
var questionSecondHalf = givenWord;
|
||||||
|
|
||||||
|
var question = questionFirstHalf.replace("the following", questionSecondHalf);
|
||||||
|
|
||||||
var answer = kanjiForms[to_form];
|
var answer = kanjiForms[to_form];
|
||||||
var answer2 = kanaForms[to_form];
|
var answer2 = kanaForms[to_form];
|
||||||
@ -367,13 +371,13 @@ function generateQuestion() {
|
|||||||
$('#questionSecondHalf').html(questionSecondHalf);
|
$('#questionSecondHalf').html(questionSecondHalf);
|
||||||
|
|
||||||
window.questionData = {
|
window.questionData = {
|
||||||
entry: entry,
|
entry: entry,
|
||||||
transformation: transformation,
|
transformation: transformation,
|
||||||
question: question,
|
question: question,
|
||||||
answer: answer,
|
answer: answer,
|
||||||
answer2: answer2,
|
answer2: answer2,
|
||||||
answerWithFurigana: answerWithFurigana,
|
answerWithFurigana: answerWithFurigana,
|
||||||
givenWord: givenWord,
|
givenWord: givenWord,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Construct the explanation page.
|
// Construct the explanation page.
|
||||||
@ -381,14 +385,14 @@ function generateQuestion() {
|
|||||||
var data = window.questionData;
|
var data = window.questionData;
|
||||||
|
|
||||||
var groupLabels = {
|
var groupLabels = {
|
||||||
"godan" : "godan verb",
|
"godan": "godan verb",
|
||||||
"ichidan" : "ichidan verb",
|
"ichidan": "ichidan verb",
|
||||||
"iku" : "godan verb",
|
"iku": "godan verb",
|
||||||
"suru" : "suru verb",
|
"suru": "suru verb",
|
||||||
"kuru" : "special verb",
|
"kuru": "special verb",
|
||||||
"i-adjective" : "い adjective",
|
"i-adjective": "い-adjective",
|
||||||
"ii" : "i-adjective",
|
"ii": "い-adjective",
|
||||||
"na-adjective" : "な adjective",
|
"na-adjective": "な-adjective",
|
||||||
};
|
};
|
||||||
|
|
||||||
var dictionary = words[data.entry].conjugations["dictionary"].forms;
|
var dictionary = words[data.entry].conjugations["dictionary"].forms;
|
||||||
@ -461,7 +465,7 @@ function processAnswer() {
|
|||||||
|
|
||||||
if (response == "")
|
if (response == "")
|
||||||
shake = true;
|
shake = true;
|
||||||
|
|
||||||
if (!response.match(japaneseTextPattern))
|
if (!response.match(japaneseTextPattern))
|
||||||
shake = true;
|
shake = true;
|
||||||
|
|
||||||
@ -507,7 +511,7 @@ function shakeInputArea() {
|
|||||||
var shakeClass = "shake";
|
var shakeClass = "shake";
|
||||||
|
|
||||||
inputArea.addClass(shakeClass);
|
inputArea.addClass(shakeClass);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
inputArea.removeClass(shakeClass)
|
inputArea.removeClass(shakeClass)
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@ -520,15 +524,7 @@ function updateHistoryView(log) {
|
|||||||
var total = 0;
|
var total = 0;
|
||||||
var correct = 0;
|
var correct = 0;
|
||||||
|
|
||||||
var header_tr = $('<div class="row d-none d-md-flex">');
|
log.history.forEach(function (entry, index) {
|
||||||
|
|
||||||
header_tr.append($('<div class="col-md-6">Question</div>'));
|
|
||||||
header_tr.append($('<div class="col-md-3">Answer</div>'));
|
|
||||||
header_tr.append($('<div class="col-md-3">Response</div>'));
|
|
||||||
|
|
||||||
review.append(header_tr);
|
|
||||||
|
|
||||||
log.history.forEach(function (entry) {
|
|
||||||
|
|
||||||
total++;
|
total++;
|
||||||
|
|
||||||
@ -536,25 +532,37 @@ function updateHistoryView(log) {
|
|||||||
correct++;
|
correct++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tr = $('<div class="row">');
|
var tr = $('<div class="row mt-4">');
|
||||||
|
|
||||||
var td1 = $('<div class="col-md-6">');
|
var td1 = $('<div class="col-md-6 mb-2">');
|
||||||
var td2 = $('<div class="col-md-3">');
|
var td2 = $('<div class="col-md-3 ml-4 ml-md-0">');
|
||||||
var td3 = $('<div class="col-md-3">');
|
|
||||||
|
|
||||||
td1.html(entry.question);
|
td1.html((index + 1) + ". " + entry.question + ".");
|
||||||
td2.html(commaList(entry.answer, "or"));
|
|
||||||
td3.text(entry.response);
|
var responseDiv = $('<div>');
|
||||||
|
responseDiv.text(entry.response);
|
||||||
|
|
||||||
|
if (entry.correct) {
|
||||||
|
responseDiv.append("<span class='answer-correct'> 〇</span>");
|
||||||
|
} else {
|
||||||
|
responseDiv.append("<span class='answer-wrong'> ×</span>");
|
||||||
|
}
|
||||||
|
|
||||||
|
td2.append(responseDiv);
|
||||||
|
|
||||||
|
if (!entry.correct) {
|
||||||
|
|
||||||
|
var correctDiv = $('<div>');
|
||||||
|
|
||||||
|
correctDiv.html(commaList(entry.answer, "or"));
|
||||||
|
correctDiv.append("<span class='answer-correct'> 〇</span>");
|
||||||
|
|
||||||
|
td2.append(correctDiv);
|
||||||
|
}
|
||||||
|
|
||||||
tr.append(td1);
|
tr.append(td1);
|
||||||
tr.append(td2);
|
tr.append(td2);
|
||||||
tr.append(td3);
|
|
||||||
|
|
||||||
if (entry.correct) {
|
|
||||||
td3.append("<span class='answer-correct'> 〇</span>");
|
|
||||||
} else {
|
|
||||||
td3.append("<span class='answer-wrong'> ×</span>");
|
|
||||||
}
|
|
||||||
review.append(tr);
|
review.append(tr);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -563,12 +571,15 @@ function updateHistoryView(log) {
|
|||||||
var resultString;
|
var resultString;
|
||||||
|
|
||||||
if (correct == total) {
|
if (correct == total) {
|
||||||
resultString = "All correct";
|
resultString = "All correct!";
|
||||||
|
} else if (correct == 0) {
|
||||||
|
resultString = "All incorrect!";
|
||||||
} else {
|
} else {
|
||||||
resultString = correct + " of " + total + " correct";
|
resultString = correct + " of " + total + " correct.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#scoreSectionTitle').html("<h1>Result: " + resultString + "</h1>");
|
$('#scoreSectionTitleNarrow').text(resultString);
|
||||||
|
$('#scoreSectionTitleWide').text(resultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
function proceed() {
|
function proceed() {
|
||||||
@ -653,7 +664,7 @@ function calculateTransitions() {
|
|||||||
|
|
||||||
var allTags = {};
|
var allTags = {};
|
||||||
|
|
||||||
Object.keys(words).forEach(function(word) {
|
Object.keys(words).forEach(function (word) {
|
||||||
|
|
||||||
Object.keys(words[word].conjugations).forEach(function (conjugation) {
|
Object.keys(words[word].conjugations).forEach(function (conjugation) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user