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,6 +43,7 @@ sourceSize.width: Math.max(parent.width, parent.height) Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } @@ -67,6 +68,7 @@ property alias bonus: bonus property alias answerColumnModel: answerColumn.model property alias itemListModel: itemList.model + property var levels: activity.datasetLoader.data.length !== 0 ? activity.datasetLoader.data : null } DropArea { @@ -157,21 +159,49 @@ 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) + } } 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", @@ -62,54 +63,13 @@ function initLevel() { 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() 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,44 @@ +/* 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("Count or recognise 1 type of fruit with maximum count 4") + difficulty: 1 + data: [ + { + "numberOfItemType" : 1, + "numberOfItemMax" : 1 + }, + { + "numberOfItemType" : 1, + "numberOfItemMax" : 2 + }, + { + "numberOfItemType" : 1, + "numberOfItemMax" : 3 + }, + { + "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("Count or recognise up to 2 types of fruits, each of maximum count 6") + difficulty: 2 + data: [ + { + "numberOfItemType" : 1, + "numberOfItemMax" : 4 + }, + { + "numberOfItemType" : 2, + "numberOfItemMax" : 4 + }, + { + "numberOfItemType" : 1, + "numberOfItemMax" : 5 + }, + { + "numberOfItemType" : 2, + "numberOfItemMax" : 5 + }, + { + "numberOfItemType" : 1, + "numberOfItemMax" : 6 + }, + { + "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,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("Count or recognise up to 3 types of fruits, each of maximum count 6") + difficulty: 2 + data: [ + { + "numberOfItemType" : 2, + "numberOfItemMax" : 4 + }, + { + "numberOfItemType" : 3, + "numberOfItemMax" : 4 + }, + { + "numberOfItemType" : 2, + "numberOfItemMax" : 5 + }, + { + "numberOfItemType" : 3, + "numberOfItemMax" : 5 + }, + { + "numberOfItemType" : 2, + "numberOfItemMax" : 6 + }, + { + "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,76 @@ +/* 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("Count or recognise up to 5 types of fruits, each of maximum count 9") + difficulty: 3 + data: [ + { + "numberOfItemType" : 3, + "numberOfItemMax" : 4 + }, + { + "numberOfItemType" : 4, + "numberOfItemMax" : 4 + }, + { + "numberOfItemType" : 4, + "numberOfItemMax" : 5 + }, + { + "numberOfItemType" : 5, + "numberOfItemMax" : 5 + }, + { + "numberOfItemType" : 4, + "numberOfItemMax" : 6 + }, + { + "numberOfItemType" : 5, + "numberOfItemMax" : 6 + }, + { + "numberOfItemType" : 4, + "numberOfItemMax" : 7 + }, + { + "numberOfItemType" : 5, + "numberOfItemMax" : 7 + }, + { + "numberOfItemType" : 4, + "numberOfItemMax" : 8 + }, + { + "numberOfItemType" : 5, + "numberOfItemMax" : 8 + }, + { + "numberOfItemType" : 4, + "numberOfItemMax" : 9 + }, + { + "numberOfItemType" : 5, + "numberOfItemMax" : 9 + }, + ] +}