-
Notifications
You must be signed in to change notification settings - Fork 3
/
CaseQuestions.html
98 lines (82 loc) · 2.88 KB
/
CaseQuestions.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
<!DOCTYPE html>
<html>
<head>
<title>
LT Exercise -- Case Questions
</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 dataSource = '[{"Question":"kas?", "Case":"nominative"},{"Question":"ko?", "Case":"genitive"},{"Question":"kam?", "Case":"dative"},{"Question":"ką?", "Case":"accusative"},{"Question":"su kuo?", "Case":"instrumental"},{"Question":"kur?", "Case":"locative"}]';
var cases = JSON.parse(dataSource);
var currentCase = cases.random();
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(); }
}
function onAnswerRequest(){
// Show answer
var answerDiv = document.getElementById('Answer');
var answer = currentCase.Case;
answerDiv.innerHTML = answer;
// Amend button text
var button = document.getElementById('NextActionButton');
button.innerText = 'Next';
// Amend notification
notification.Answer = answer;
}
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
currentCase = cases.notRepeatingRandom(currentCase);
// Setup question div
var divToAmend = document.getElementById('Question');
divToAmend.innerHTML = currentCase.Question;
// Amend notification
notification.Question = currentCase.Question;
notification.Answer = null;
}
</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='table' class='content'>
<div id='Question'> kas? </div>
<div id='Answer'> nominative </div>
<div id='Button'>
<button id='NextActionButton'
onclick="onNextActionButtonClick()">
Next
</button>
</div>
<div class="issueNotificationDiv">
<button id='notifyButton'
onclick="notify(notification.Question, notification.Answer)">
Tell about an error
</button>
</div>
</div>
</div>
</body>
</html>