diff --git a/src/activities/gletters/Gletters.qml b/src/activities/gletters/Gletters.qml --- a/src/activities/gletters/Gletters.qml +++ b/src/activities/gletters/Gletters.qml @@ -86,6 +86,7 @@ property Item main: activity.main property Item ourActivity: activity property GCAudio audioVoices: activity.audioVoices + property var levels: activity.datasetLoader.item.data property alias background: background property alias bar: bar property alias bonus: bonus diff --git a/src/activities/gletters/gletters.js b/src/activities/gletters/gletters.js --- a/src/activities/gletters/gletters.js +++ b/src/activities/gletters/gletters.js @@ -76,9 +76,8 @@ // register the voices for the locale GCompris.DownloadManager.updateResource(GCompris.DownloadManager.getVoicesResourceForLocale(GCompris.ApplicationInfo.getVoicesLocale(items.locale))); - items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( - items.ourActivity.dataSetUrl + "default-"+locale+".json")); + items.ourActivity.dataSetUrl + "default-"+locale+".json"), items.levels); // If wordlist is empty, we try to load from short locale and if not present again, we switch to default one var localeUnderscoreIndex = locale.indexOf('_') // probably exist a better way to see if the list is empty @@ -94,7 +93,7 @@ // If not found, we will use the default file items.wordlist.useDefault = true items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( - items.ourActivity.dataSetUrl + "default-"+localeShort+".json")); + items.ourActivity.dataSetUrl + "default-"+localeShort+".json"), items.levels) // We remove the using of default file for next time we enter this function items.wordlist.useDefault = false } diff --git a/src/activities/smallnumbers/ActivityInfo.qml b/src/activities/smallnumbers/ActivityInfo.qml --- a/src/activities/smallnumbers/ActivityInfo.qml +++ b/src/activities/smallnumbers/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "computer keyboard math numeration" createdInVersion: 0 + levels: "1,2,3" } diff --git a/src/activities/smallnumbers/resource/1/Data.qml b/src/activities/smallnumbers/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/smallnumbers/resource/1/Data.qml @@ -0,0 +1,53 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Select number on dice upto 4") + data: [ + { + "level" : "1", + "words" : [ + "1", + "2" + ] + }, + { + "level" : "2", + "words" : [ + "1", + "2", + "3", + ] + }, + { + "level" : "3", + "words" : [ + "1", + "2", + "3", + "4" + ] + } + ] +} diff --git a/src/activities/smallnumbers/resource/2/Data.qml b/src/activities/smallnumbers/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/smallnumbers/resource/2/Data.qml @@ -0,0 +1,71 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Select number on dice upto 7") + data: [ + { + "level" : "1", + "words" : [ + "1", + "2", + "3", + "4" + ] + }, + { + "level" : "2", + "words" : [ + "1", + "2", + "3", + "4", + "5" + ] + }, + { + "level" : "3", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6" + ] + }, + { + "level" : "4", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7" + ] + } + ] +} diff --git a/src/activities/smallnumbers/resource/3/Data.qml b/src/activities/smallnumbers/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/smallnumbers/resource/3/Data.qml @@ -0,0 +1,80 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + + objective: qsTr("Select number on dice upto 9") + data: [ + { + "level" : "1", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6" + ] + }, + { + "level" : "2", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7" + ] + }, + { + "level" : "3", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8" + ] + }, + { + "level" : "4", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9" + ] + } + ] +} diff --git a/src/activities/smallnumbers2/ActivityInfo.qml b/src/activities/smallnumbers2/ActivityInfo.qml --- a/src/activities/smallnumbers2/ActivityInfo.qml +++ b/src/activities/smallnumbers2/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "math numeration" createdInVersion: 0 + levels: "1,2,3" } diff --git a/src/activities/smallnumbers2/resource/1/Data.qml b/src/activities/smallnumbers2/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/smallnumbers2/resource/1/Data.qml @@ -0,0 +1,53 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Select number on dice upto 4") + data: [ + { + "level" : "1", + "words" : [ + "1", + "2" + ] + }, + { + "level" : "2", + "words" : [ + "1", + "2", + "3", + ] + }, + { + "level" : "3", + "words" : [ + "1", + "2", + "3", + "4" + ] + } + ] +} diff --git a/src/activities/smallnumbers2/resource/2/Data.qml b/src/activities/smallnumbers2/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/smallnumbers2/resource/2/Data.qml @@ -0,0 +1,71 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Select number on dice upto 7") + data: [ + { + "level" : "1", + "words" : [ + "1", + "2", + "3", + "4" + ] + }, + { + "level" : "2", + "words" : [ + "1", + "2", + "3", + "4", + "5" + ] + }, + { + "level" : "3", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6" + ] + }, + { + "level" : "4", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7" + ] + } + ] +} diff --git a/src/activities/smallnumbers2/resource/3/Data.qml b/src/activities/smallnumbers2/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/smallnumbers2/resource/3/Data.qml @@ -0,0 +1,80 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 QtQuick 2.6 +import GCompris 1.0 +import "../../../../core" + +Dataset { + + objective: qsTr("Select number on dice upto 9") + data: [ + { + "level" : "1", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6" + ] + }, + { + "level" : "2", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7" + ] + }, + { + "level" : "3", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8" + ] + }, + { + "level" : "4", + "words" : [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9" + ] + } + ] +} diff --git a/src/core/Wordlist.qml b/src/core/Wordlist.qml --- a/src/core/Wordlist.qml +++ b/src/core/Wordlist.qml @@ -102,7 +102,17 @@ * * @param type:string fname Filename to load wordlist from. */ - function loadFromFile(fname) { + function loadFromFile(fname, levels) { + + // If levels are provided explicitly as function parameter, use them as wordlist + if(levels !== undefined) { + var levelsObject = {levels: levels} + wordList = levelsObject; + maxLevel = wordList.levels.length; + return wordList; + } + + // Otherwise load wordlist from file filename = fname; var from; maxLevel = 0