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 !== null ? activity.datasetLoader.item.data : undefined 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,11 @@ // register the voices for the locale GCompris.DownloadManager.updateResource(GCompris.DownloadManager.getVoicesResourceForLocale(GCompris.ApplicationInfo.getVoicesLocale(items.locale))); - - items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( + if(items.levels == undefined) + items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( items.ourActivity.dataSetUrl + "default-"+locale+".json")); + else + items.wordlist.loadFromJSON(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 @@ -93,8 +95,11 @@ } // 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")); + if(items.levels == undefined) + items.wordlist.loadFromFile(GCompris.ApplicationInfo.getLocaleFilePath( + items.ourActivity.dataSetUrl + "default-"+localeShort+".json")); + else + items.wordlist.loadFromJSON(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,54 @@ +/* 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 up to 4") + difficulty: 1 + 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,72 @@ +/* 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 up to 7") + difficulty: 2 + 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 up to 9") + difficulty: 3 + 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,54 @@ +/* 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 up to 4") + difficulty: 1 + 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,72 @@ +/* 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 up to 7") + difficulty: 2 + 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 up to 9") + difficulty: 3 + 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 @@ -97,6 +97,17 @@ */ signal error(string msg); + /** + * Load Wordlist from JSON Object. + * + * @param type:object levels to load wordlist from. + */ + function loadFromJSON(levels) { + wordList = {levels: levels}; + maxLevel = wordList.levels.length; + return wordList; + } + /** * Load Wordlist from file @p fname. *