~baltix/gcompris-qt/0.97.1

« back to all changes in this revision

Viewing changes to src/activities/braille_alphabets/braille_alphabets.js

  • Committer: Mantas Kriaučiūnas
  • Date: 2020-07-06 18:07:11 UTC
  • Revision ID: baltix@gmail.com-20200706180711-g254osu02cn8bc8p
GCompris-QT 0.97.1 with Lithuanian translation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GCompris - braille_alphabets.js
 
2
 *
 
3
 * Copyright (C) 2014 Arkit Vora <arkitvora123@gmail.com>
 
4
 *
 
5
 * Authors:
 
6
 *   Srishti Sethi <srishakatux@gmail.com> (GTK+ version)
 
7
 *   Arkit Vora <arkitvora123@gmail.com> (Qt Quick port)
 
8
 *
 
9
 *   This program is free software; you can redistribute it and/or modify
 
10
 *   it under the terms of the GNU General Public License as published by
 
11
 *   the Free Software Foundation; either version 3 of the License, or
 
12
 *   (at your option) any later version.
 
13
 *
 
14
 *   This program is distributed in the hope that it will be useful,
 
15
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 *   GNU General Public License for more details.
 
18
 *
 
19
 *   You should have received a copy of the GNU General Public License
 
20
 *   along with this program; if not, see <https://www.gnu.org/licenses/>.
 
21
 */
 
22
.pragma library
 
23
.import QtQuick 2.6 as Quick
 
24
.import "qrc:/gcompris/src/core/core.js" as Core
 
25
 
 
26
var url = "qrc:/gcompris/src/activities/braille_alphabets/resource/"
 
27
 
 
28
var currentLevel
 
29
var numberOfLevel
 
30
var items
 
31
var dataset
 
32
var currentQuestion
 
33
var currentDataSet
 
34
 
 
35
function start(items_, dataset_) {
 
36
    items = items_
 
37
    dataset = dataset_.get()
 
38
    currentLevel = 0
 
39
    numberOfLevel = dataset.length * 2
 
40
    initLevel()
 
41
}
 
42
 
 
43
function stop() {
 
44
}
 
45
 
 
46
function initLevel() {
 
47
    items.bar.level = currentLevel + 1
 
48
    items.containerModel.clear()
 
49
    currentQuestion = 0
 
50
 
 
51
    switch(currentLevel) {
 
52
        case 0:
 
53
            items.instructions = ""
 
54
            items.brailleCodeSeen = true
 
55
            currentDataSet = dataset[0]
 
56
            break
 
57
        case 1:
 
58
            items.instructions = qsTr("Now it's a little bit harder without the braille map.")
 
59
            items.brailleCodeSeen = false
 
60
            currentDataSet = dataset[0]
 
61
            break
 
62
        case 2:
 
63
            items.instructions = qsTr("Look at the Braille character map and observe how similar the first and second line are.")
 
64
            items.brailleCodeSeen = true
 
65
            currentDataSet = dataset[1]
 
66
            break
 
67
        case 3:
 
68
            items.instructions = qsTr("Now it's a little bit harder without the braille map.")
 
69
            items.brailleCodeSeen = false
 
70
            currentDataSet = dataset[1]
 
71
            break
 
72
        case 4:
 
73
            items.instructions = qsTr("Again, similar as the first line but take care, the 'W' letter was added afterwards.")
 
74
            items.brailleCodeSeen = true
 
75
            currentDataSet = dataset[2]
 
76
            break
 
77
        case 5:
 
78
            items.instructions = qsTr("Now it's a little bit harder without the braille map.")
 
79
            items.brailleCodeSeen = false
 
80
            currentDataSet = dataset[2]
 
81
            break
 
82
        case 6:
 
83
            items.instructions = qsTr("This is easy, numbers are the same as letters from A to J.")
 
84
            items.brailleCodeSeen = true
 
85
            currentDataSet = dataset[3]
 
86
            break
 
87
        case 7:
 
88
            items.instructions = qsTr("Now it's a little bit harder without the braille map.")
 
89
            items.brailleCodeSeen = false
 
90
            currentDataSet = dataset[3]
 
91
            break
 
92
        case 8:
 
93
            items.instructions = ""
 
94
            items.brailleCodeSeen = true
 
95
            currentDataSet = dataset[4]
 
96
            break
 
97
        case 9:
 
98
            items.instructions = qsTr("Now it's a little bit harder without the braille map.")
 
99
            items.brailleCodeSeen = false
 
100
            currentDataSet = dataset[4]
 
101
            break
 
102
    }
 
103
 
 
104
    for(var i = 0;  i < currentDataSet.length; ++i) {
 
105
        items.containerModel.append(currentDataSet[i])
 
106
    }
 
107
 
 
108
    // Shuffle not to ask the question in the model order
 
109
    currentDataSet = Core.shuffle(currentDataSet)
 
110
 
 
111
    items.score.numberOfSubLevels = currentDataSet.length;
 
112
    items.score.currentSubLevel = 0;
 
113
 
 
114
    items.playableChar.isLetter = currentDataSet[0].letter >= "A" && currentDataSet[0].letter <= "Z"
 
115
    // Trig the next question
 
116
    items.questionItem.opacity = 0.1
 
117
    items.questionItem.opacity = 0
 
118
}
 
119
 
 
120
function nextLevel() {
 
121
    if(numberOfLevel <= ++currentLevel) {
 
122
        currentLevel = 0
 
123
    }
 
124
    initLevel();
 
125
}
 
126
 
 
127
function previousLevel() {
 
128
    if(--currentLevel < 0) {
 
129
        currentLevel = numberOfLevel - 1
 
130
    }
 
131
    initLevel();
 
132
}
 
133
 
 
134
function nextQuestion() {
 
135
    if(currentDataSet.length <= ++currentQuestion) {
 
136
        items.bonus.good("flower")
 
137
    } else {
 
138
        // Let's not change the question immediately to let the
 
139
        // children see his answer.
 
140
        // We just set the opacity to 0, the questionItem will then grab
 
141
        // the new question by itself
 
142
        items.questionItem.opacity = 0.1
 
143
        items.questionItem.opacity = 0
 
144
        items.score.currentSubLevel ++
 
145
    }
 
146
}
 
147
 
 
148
function getCurrentTextQuestion() {
 
149
    return currentDataSet[currentQuestion].text.arg(getCurrentLetter())
 
150
}
 
151
 
 
152
function getCurrentLetter() {
 
153
    return currentDataSet[currentQuestion].letter
 
154
}
 
155