diff --git a/src/activities/enumerate/ActivityInfo.qml b/src/activities/enumerate/ActivityInfo.qml --- a/src/activities/enumerate/ActivityInfo.qml +++ b/src/activities/enumerate/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "math numeration" createdInVersion: 0 + levels: "1,2,3,4" } diff --git a/src/activities/enumerate/Enumerate.qml b/src/activities/enumerate/Enumerate.qml --- a/src/activities/enumerate/Enumerate.qml +++ b/src/activities/enumerate/Enumerate.qml @@ -43,12 +43,58 @@ sourceSize.width: Math.max(parent.width, parent.height) Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } onStart: { Activity.start(items); keyboard.populate(); } onStop: { Activity.stop() } + //instruction rectangle + Rectangle { + id: instruction + anchors { + top: parent.top + topMargin: 5 + horizontalCenter: parent.horizontalCenter + } + height: instructionTxt.contentHeight * 1.1 + width: Math.max(Math.min(parent.width * 0.8, instructionTxt.text.length * 10), parent.width * 0.3) + opacity: 0.8 + visible: items.levels + radius: 10 + border.width: 2 + z: 10 + border.color: "#DDD" + color: "#373737" + + Behavior on opacity { PropertyAnimation { duration: 200 } } + + //shows/hides the Instruction + MouseArea { + anchors.fill: parent + onClicked: instruction.opacity = instruction.opacity == 0 ? 0.8 : 0 + } + + GCText { + id: instructionTxt + anchors { + top: parent.top + topMargin: 5 + horizontalCenter: parent.horizontalCenter + } + opacity: instruction.opacity + z: instruction.z + fontSize: smallSize + color: "white" + text: items.instructionText + horizontalAlignment: Text.AlignHCenter + width: parent.width * 0.8 + wrapMode: TextEdit.WordWrap + } + } + + Keys.onDownPressed: { if(++answerColumn.currentIndex >= answerColumn.count) answerColumn.currentIndex = 0 @@ -67,6 +113,8 @@ property alias bonus: bonus property alias answerColumnModel: answerColumn.model property alias itemListModel: itemList.model + property string instructionText: "" + property var levels: activity.datasetLoader.data.length !== 0 ? activity.datasetLoader.data : null } DropArea { @@ -157,21 +205,62 @@ onError: console.log("VirtualKeyboard error: " + msg); } + + DialogChooseLevel { + id: dialogActivityConfig + currentActivity: activity.activityInfo + onSaveData: { + levelFolder = dialogActivityConfig.chosenLevels + currentActivity.currentLevels = dialogActivityConfig.chosenLevels + ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) + activity.focus = true + background.stop() + background.start() + } + onLoadData: { + if(activityData) { + Activity.initLevel() + } + } + onClose: { + home() + } + onStartActivity: { + background.start() + } + } + DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar anchors.bottom: keyboard.top - content: BarEnumContent { value: help | home | level } + content: BarEnumContent { value: help | home | level | activityConfig } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() + onActivityConfigClicked: { + displayDialog(dialogActivityConfig) + } + } + + BarButton { + id: okButton + anchors { + bottom: bar.top + right: parent.right + rightMargin: 9 * ApplicationInfo.ratio + bottomMargin: 9 * ApplicationInfo.ratio + } + source: "qrc:/gcompris/src/core/resource/bar_ok.svg" + sourceSize.width: 80 * ApplicationInfo.ratio + onClicked: Activity.checkAnswers() } Bonus { diff --git a/src/activities/enumerate/enumerate.js b/src/activities/enumerate/enumerate.js --- a/src/activities/enumerate/enumerate.js +++ b/src/activities/enumerate/enumerate.js @@ -26,8 +26,9 @@ var url = "qrc:/gcompris/src/activities/enumerate/resource/" var url2 = "qrc:/gcompris/src/activities/algorithm/resource/" var items -var currentLevel = 0 -var numberOfLevel = 9 +var dataset +var currentLevel +var numberOfLevel var itemIcons = [ url2 + "apple.svg", url2 + "banana.svg", @@ -61,55 +62,16 @@ } function initLevel() { + if(items.levels) + items.instructionText = items.levels[currentLevel].objective items.bar.level = currentLevel + 1 + dataset = items.levels + numberOfLevel = dataset.length cleanUp() - var numberOfItemType var numberOfItemMax - - switch(currentLevel) - { - case 0: - numberOfItemType = 1; - numberOfItemMax = 5; - break; - case 1: - numberOfItemType = 2; - numberOfItemMax = 5; - break; - case 2: - numberOfItemType = 3; - numberOfItemMax = 4; - break; - case 3: - numberOfItemType = 3; - numberOfItemMax = 5; - break; - case 4: - numberOfItemType = 4; - numberOfItemMax = 5; - break; - case 5: - numberOfItemType = 4; - numberOfItemMax = 6; - break; - case 6: - numberOfItemType = 5; - numberOfItemMax = 5; - break; - case 7: - numberOfItemType = 4; - numberOfItemMax = 6; - break; - case 8: - numberOfItemType = 3; - numberOfItemMax = 8; - break; - default: - numberOfItemType = 2; - numberOfItemMax = 9; - } - + numberOfItemType = dataset[currentLevel].numberOfItemType + numberOfItemMax = dataset[currentLevel].numberOfItemMax itemIcons = Core.shuffle(itemIcons) var enumItems = new Array() var types = new Array() @@ -147,14 +109,13 @@ function setUserAnswer(imgPath, userValue) { userAnswers[imgPath] = userValue - checkAnswers() return userAnswers[imgPath] === answerToFind[imgPath] } function checkAnswers() { for (var key in answerToFind) { if(userAnswers[key] !== answerToFind[key]) { - return; + return items.bonus.bad("smiley") } } items.bonus.good("smiley") diff --git a/src/activities/enumerate/resource/1/Data.qml b/src/activities/enumerate/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/enumerate/resource/1/Data.qml @@ -0,0 +1,48 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import "../../../../core" + +Dataset { + objective: qsTr("Enumarate up to 4 fruits") + difficulty: 1 + data: [ + { + "objective": qsTr("Enumarate 1 fruit"), + "numberOfItemType" : 1, + "numberOfItemMax" : 1 + }, + { + "objective": qsTr("Enumarate up to 2 fruits"), + "numberOfItemType" : 1, + "numberOfItemMax" : 2 + }, + { + "objective": qsTr("Enumarate up to 3 fruits"), + "numberOfItemType" : 1, + "numberOfItemMax" : 3 + }, + { + "objective": qsTr("Enumarate up to 4 fruits"), + "numberOfItemType" : 1, + "numberOfItemMax" : 4 + } + ] +} diff --git a/src/activities/enumerate/resource/2/Data.qml b/src/activities/enumerate/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/enumerate/resource/2/Data.qml @@ -0,0 +1,52 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import "../../../../core" + +Dataset { + objective: qsTr("Group 2 types of fruits and enumarate each group (6 fruits max)") + difficulty: 2 + data: [ + { "objective": qsTr("Enumarate up to 4 fruits"), + "numberOfItemType" : 1, + "numberOfItemMax" : 4 + }, + { "objective": qsTr("Group 2 types of fruits and enumarate each group (4 fruits max)"), + "numberOfItemType" : 2, + "numberOfItemMax" : 4 + }, + { "objective": qsTr("Enumarate up to 5 fruits"), + "numberOfItemType" : 1, + "numberOfItemMax" : 5 + }, + { "objective": qsTr("Group 2 types of fruits and enumarate each group (5 fruits max)"), + "numberOfItemType" : 2, + "numberOfItemMax" : 5 + }, + { "objective": qsTr("Enumarate up to 6 fruits"), + "numberOfItemType" : 1, + "numberOfItemMax" : 6 + }, + { "objective": qsTr("Group 2 types of fruits and enumarate each group (6 fruits max)"), + "numberOfItemType" : 2, + "numberOfItemMax" : 6 + } + ] +} diff --git a/src/activities/enumerate/resource/3/Data.qml b/src/activities/enumerate/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/enumerate/resource/3/Data.qml @@ -0,0 +1,58 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import "../../../../core" + +Dataset { + objective: qsTr("Group 3 types of fruits and enumarate each group (6 fruits max)") + difficulty: 2 + data: [ + { + "objective": qsTr("Group 2 types of fruits and enumarate each group (4 fruits max)"), + "numberOfItemType" : 2, + "numberOfItemMax" : 4 + }, + { + "objective": qsTr("Group 3 types of fruits and enumarate each group (4 fruits max)"), + "numberOfItemType" : 3, + "numberOfItemMax" : 4 + }, + { + "objective": qsTr("Group 2 types of fruits and enumarate each group (5 fruits max)"), + "numberOfItemType" : 2, + "numberOfItemMax" : 5 + }, + { + "objective": qsTr("Group 3 types of fruits and enumarate each group (5 fruits max)"), + "numberOfItemType" : 3, + "numberOfItemMax" : 5 + }, + { + "objective": qsTr("Group 2 types of fruits and enumarate each group (6 fruits max)"), + "numberOfItemType" : 2, + "numberOfItemMax" : 6 + }, + { + "objective": qsTr("Group 3 types of fruits and enumarate each group (6 fruits max)"), + "numberOfItemType" : 3, + "numberOfItemMax" : 6 + } + ] +} diff --git a/src/activities/enumerate/resource/4/Data.qml b/src/activities/enumerate/resource/4/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/enumerate/resource/4/Data.qml @@ -0,0 +1,88 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import "../../../../core" + +Dataset { + objective: qsTr("Group 5 types of fruits and enumarate each group (9 fruits max)") + difficulty: 3 + data: [ + { + "objective": qsTr("Group 3 types of fruits and enumarate each group (4 fruits max)"), + "numberOfItemType" : 3, + "numberOfItemMax" : 4 + }, + { + "objective": qsTr("Group 4 types of fruits and enumarate each group (4 fruits max)"), + "numberOfItemType" : 4, + "numberOfItemMax" : 4 + }, + { + "objective": qsTr("Group 4 types of fruits and enumarate each group (5 fruits max)"), + "numberOfItemType" : 4, + "numberOfItemMax" : 5 + }, + { + "objective": qsTr("Group 5 types of fruits and enumarate each group (5 fruits max)"), + "numberOfItemType" : 5, + "numberOfItemMax" : 5 + }, + { + "objective": qsTr("Group 4 types of fruits and enumarate each group (6 fruits max)"), + "numberOfItemType" : 4, + "numberOfItemMax" : 6 + }, + { + "objective": qsTr("Group 5 types of fruits and enumarate each group (6 fruits max)"), + "numberOfItemType" : 5, + "numberOfItemMax" : 6 + }, + { + "objective": qsTr("Group 4 types of fruits and enumarate each group (7 fruits max)"), + "numberOfItemType" : 4, + "numberOfItemMax" : 7 + }, + { + "objective": qsTr("Group 5 types of fruits and enumarate each group (7 fruits max)"), + "numberOfItemType" : 5, + "numberOfItemMax" : 7 + }, + { + "objective": qsTr("Group 4 types of fruits and enumarate each group (8 fruits max)"), + "numberOfItemType" : 4, + "numberOfItemMax" : 8 + }, + { + "objective": qsTr("Group 5 types of fruits and enumarate each group (8 fruits max)"), + "numberOfItemType" : 5, + "numberOfItemMax" : 8 + }, + { + "objective": qsTr("Group 4 types of fruits and enumarate each group (9 fruits max)"), + "numberOfItemType" : 4, + "numberOfItemMax" : 9 + }, + { + "objective": qsTr("Group 5 types of fruits and enumarate each group (9 fruits max)"), + "numberOfItemType" : 5, + "numberOfItemMax" : 9 + }, + ] +}