-
Notifications
You must be signed in to change notification settings - Fork 3
/
NounInstrumentalSingular.html
169 lines (134 loc) · 8.08 KB
/
NounInstrumentalSingular.html
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html>
<head>
<title>
LT Exercise -- Instrumental Singular Noun
</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/ToC.css">
<link rel="stylesheet" href="css/pageStructure.css">
<script type="text/javascript" src="js/Common.js"> </script>
<script type="text/javascript">
ButtonNext_OnPageLoad();
SetupArrayFunctions();
var samplesAsJson = '[{"Starter":"Aš važiuoju","NounToChange":"automobilis","Ending":"is","En":"car","Group":"1","Answer":"Aš važiuoju automobiliu"},{"Starter":"Aš važiuoju","NounToChange":"dviratis","Ending":"is","En":"bicycle","Group":"1","Answer":"Aš važiuoju dviračiu"},{"Starter":"Aš važiuoju","NounToChange":"paspirtukas","Ending":"as","En":"scooter","Group":"1","Answer":"Aš važiuoju paspirtuku"},{"Starter":"Aš važiuoju","NounToChange":"autobusas","Ending":"as","En":"bus","Group":"1","Answer":"Aš važiuoju autobusu"},{"Starter":"Aš važiuoju","NounToChange":"traukinys","Ending":"ys","En":"train","Group":"1","Answer":"Aš važiuoju traukiniu"},{"Starter":"Aš skrendu","NounToChange":"lėktuvas","Ending":"as","En":"airplane","Group":"1","Answer":"Aš skrendu lėktuvu"},{"Starter":"Aš važiuoju","NounToChange":"troleibusas","Ending":"as","En":"trolleybus","Group":"1","Answer":"Aš važiuoju troleibusu"},{"Starter":"Aš plaukiu","NounToChange":"laivas","Ending":"as","En":"ship","Group":"1","Answer":"Aš plaukiu laivu"},{"Starter":"Aš skrendu","NounToChange":"sraigtasparnis","Ending":"is","En":"helicopter","Group":"1","Answer":"Aš skrendu sraigtasparniu"},{"Starter":"Aš skrendu","NounToChange":"oro balionas","Ending":"as","En":"air balloon","Group":"1","Answer":"Aš skrendu oro balionu"},{"Starter":"Aš skrendu","NounToChange":"raketa","Ending":"a","En":"rocket","Group":"1","Answer":"Aš skrendu raketa"},{"Starter":"Aš važiuoju","NounToChange":"tramvajus","Ending":"us","En":"tram","Group":"1","Answer":"Aš važiuoju tramvajumi"},{"Starter":"Po","NounToChange":"šaldytuvas","Ending":"as","En":"fridge","Group":"2","Answer":"Po šaldytuvu"},{"Starter":"Po","NounToChange":"orkaitė","Ending":"ė","En":"oven","Group":"2","Answer":"Po orkaite"},{"Starter":"Po","NounToChange":"viryklė","Ending":"ė","En":"stove","Group":"2","Answer":"Po virykle"},{"Starter":"Po","NounToChange":"indaplovė","Ending":"ė","En":"dishwasher","Group":"2","Answer":"Po indaplove"},{"Starter":"Po","NounToChange":"skalbyklė","Ending":"ė","En":"washing machine","Group":"2","Answer":"Po skalbykle"},{"Starter":"Po","NounToChange":"džiovyklė","Ending":"ė","En":"dryer machine","Group":"2","Answer":"Po džiovykle"},{"Starter":"Po","NounToChange":"virdulys","Ending":"ys","En":"kettle","Group":"2","Answer":"Po virduliu"},{"Starter":"Po","NounToChange":"kavos aparatas","Ending":"as","En":"coffee machine","Group":"2","Answer":"Po kavos aparatu"},{"Starter":"Po","NounToChange":"dulkių siurblys","Ending":"ys","En":"vacuum cleaner","Group":"2","Answer":"Po dulkių siurbliu"},{"Starter":"Po","NounToChange":"lygintuvas","Ending":"as","En":"iron","Group":"2","Answer":"Po lygintuvu"},{"Starter":"Po","NounToChange":"lempa","Ending":"a","En":"lamp","Group":"3","Answer":"Po lempa"},{"Starter":"Po","NounToChange":"televizorius","Ending":"us","En":"TV","Group":"3","Answer":"Po televizoriumi"},{"Starter":"Po","NounToChange":"langas","Ending":"as","En":"window","Group":"3","Answer":"Po langu"},{"Starter":"Po","NounToChange":"radiatorius","Ending":"us","En":"heater","Group":"3","Answer":"Po radiatoriumi"},{"Starter":"Po","NounToChange":"lentyna","Ending":"a","En":"shelf","Group":"3","Answer":"Po lentyna"},{"Starter":"Po","NounToChange":"laikrodis","Ending":"is","En":"clock","Group":"3","Answer":"Po laikrodžiu"}]';
// Parse samples
var samples = JSON.parse(samplesAsJson);
// Group up samples for levelling
var samples1 = samples.filter(sample => sample.Group == 1).map(elem => ({...elem, Level:1}));
var samples2 = samples.filter(sample => sample.Group == 2).map(elem => ({...elem, Level:2}));
var samples3 = samples.filter(sample => sample.Group == 3).map(elem => ({...elem, Level:3}));
var samples4 = [...samples1, ...samples2, ...samples3]
.GroupBy((elem) => (elem.Ending), "Ending")
.map(elem => ({...elem, Level:4}));
var finalSamples = [...samples1, ...samples2, ...samples3, ...samples4];
// Build leveller
var leveller = CreateLevelledArray(
finalSamples,
elem => elem.Level
);
var content = leveller.GetContent();
var fullButtonsElementHtml = leveller.RegenerateButtons();
// Init state
var currentSample = content[0];
var notification = {};
function onNextActionButtonClick(){
// Check if it's answer request or next sample request
var isAnswerRequest = false;
var button = document.getElementById('NextActionButton');
if(button.innerText == 'Check answer') {isAnswerRequest = true;}
else {isAnswerRequest = false;}
// Call the respective function based on the request type
if(isAnswerRequest){
onAnswerRequest();
}
else { onNextSampleRequest(); }
}
// Returns a string containing HTML like <div> Infinitive, Present, Past</div>
function BuildAnswer(sample){
return sample.Answer;
}
// Returns a string containing HTML like <div> Verb in Ennglish </div>
function BuildQuestion(sample){
return sample.Starter + " " + sample.NounToChange;
}
function onAnswerRequest(){
// Show answer
var answerDiv = document.getElementById('Answer');
answerDiv.innerHTML = BuildAnswer(currentSample);
// Amend button text
var button = document.getElementById('NextActionButton');
button.innerText = 'Next';
// Amend notification
notification.Answer = answerDiv.innerHTML;
}
function onNextSampleRequest(){
// Clean up answer
var answerDiv = document.getElementById('Answer');
answerDiv.innerHTML = '';
// Amend button text
var button = document.getElementById('NextActionButton');
button.innerText = 'Check answer';
// Setup new sample
if(leveller.CurrentLevel < 4){
var randomSample = content.notRepeatingRandom(currentSample);
currentSample = randomSample;
}
else{
var randomSample = content
.notRepeatingRandom(currentSample.Ending, (group) => (group.Ending))
.values
.random();
currentSample = randomSample;
}
// Setup question div
var divToAmend = document.getElementById('Question');
divToAmend.innerHTML = BuildQuestion(currentSample);
// Amend notification
notification.Answer = null;
notification.Question = divToAmend.innerHTML;
}
function OnLevelButtonClick(button){
// Setup level
leveller.SetupLevel(button.value);
// Update innerHtml for level buttons div
let newHtml = leveller.RegenerateButtons("OnLevelButtonClick");
var buttonsElement = document.getElementById("levelButtonsDiv");
buttonsElement.innerHTML = newHtml;
// Update content
content = leveller.GetContent()
.filter(elem => elem.Level == leveller.CurrentLevel);
}
</script>
</head>
<body>
<div id='pageStructure' class="pageStructure">
<div id='ToC' class='ToC'></div>
<script type="text/javascript" src="js/ToC.js"> </script>
<script> uploadToC(); </script>
<div id="exercise" class="exercise">
<div id='table' class='content'>
<div id='Question'> Aš važiuoju automobilis </div>
<div id='Answer'> Aš važiuoju automobiliu </div>
<div id='Button'>
<button id='NextActionButton'
onclick="onNextActionButtonClick()">
Next
</button>
</div>
</div>
<div id="levelButtonsDiv" class="levelButtonsDiv"></div>
<script>
var buttonsElement = document.getElementById("levelButtonsDiv");
buttonsElement.innerHTML = leveller.RegenerateButtons("OnLevelButtonClick");
</script>
<div class="issueNotificationDiv">
<button id='notifyButton'
onclick="notify(notification.Question, notification.Answer)">
Tell about an error
</button>
</div>
</div>
</div>
</body>
</html>