diff --git a/app/templates/Pensum_cloze.html b/app/templates/Pensum_cloze.html
index 27954dd..c8f651e 100644
--- a/app/templates/Pensum_cloze.html
+++ b/app/templates/Pensum_cloze.html
@@ -45,11 +45,11 @@
return mapper[char];
}
- function input_to_nomacron(input) {
+ function to_nonmacron(input) {
return input.replace(/Ā|ā|Ē|ē|Ī|ī/, macron_to_nomacron);
}
- function input_to_macron(input) {
+ function to_macron(input) {
return input.replace(/(\w)\1/, nomacron_to_macron);
}
@@ -59,17 +59,19 @@
const inputs = pensum.querySelectorAll('input');
inputs.forEach((input) => {
- if (input.type=="text" && document.getElementById('vowel_length').checked == false) {
- is_macron_ok = (input.value == input_to_nomacron(input.dataset.expected));
- is_double_ok = false;
- } else {
- is_double_ok = (input_to_macron(input.value) == input.dataset.expected);
- is_macron_ok = (input.value == input.dataset.expected);
- }
- if (input.type=="text" && !(is_double_ok || is_macron_ok)) {
- input.setAttribute("class", "incorrect");
- } else if (input.type=="text") {
- input.setAttribute("class", "correct");
+ if (input.type == "text") {
+ is_nonmacron_ok = false;
+ is_macron_ok = false;
+ if (document.getElementById('vowel_length').checked == false) {
+ is_nonmacron_ok = (to_nonmacron(input.value) == to_nonmacron(input.dataset.expected));
+ } else {
+ is_macron_ok = (input.value == input.dataset.expected);
+ }
+ if (is_nonmacron_ok || is_macron_ok) {
+ input.setAttribute("class", "correct");
+ } else {
+ input.setAttribute("class", "incorrect");
+ }
}
});