diff --git a/src/activities/algebra_by/ActivityInfo.qml b/src/activities/algebra_by/ActivityInfo.qml --- a/src/activities/algebra_by/ActivityInfo.qml +++ b/src/activities/algebra_by/ActivityInfo.qml @@ -37,5 +37,5 @@ credit: "" section: "math multiplication arithmetic" createdInVersion: 0 - levels: "1,2,3,4" + levels: "1,2,3,4,5,6,7,8,9,10" } diff --git a/src/activities/algebra_by/Algebra.qml b/src/activities/algebra_by/Algebra.qml --- a/src/activities/algebra_by/Algebra.qml +++ b/src/activities/algebra_by/Algebra.qml @@ -54,6 +54,7 @@ property alias score: score property alias balloon: balloon property alias timer: timer + property var levels: activity.datasetLoader.data.length !== 0 ? activity.datasetLoader.data : null property GCSfx audioEffects: activity.audioEffects } @@ -78,7 +79,7 @@ fontSize: mediumSize wrapMode: Text.WordWrap } - Flow { + Flow { width: dialogActivityConfig.width spacing: 5 GCSlider { @@ -96,10 +97,10 @@ onClose: home() onLoadData: { - if(dataToSave) { - if(dataToSave["speedSetting"]) { - activity.speedSetting = dataToSave["speedSetting"]; - } + if(dataToSave) { + if(dataToSave["speedSetting"]) { + activity.speedSetting = dataToSave["speedSetting"]; + } } } onSaveData: { @@ -113,6 +114,30 @@ } } + DialogChooseLevel { + id: dialogActivityConf + currentActivity: activity.activityInfo + onSaveData: { + levelFolder = dialogActivityConf.chosenLevels + currentActivity.currentLevels = dialogActivityConf.chosenLevels + ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConf.chosenLevels) + activity.focus = true + background.stop() + background.start() + } + onLoadData: { + if(activityData) { + Activity.initLevel() + } + } + onClose: { + home() + } + onStartActivity: { + background.start() + } + } + DialogHelp { id: dialogHelpLeftRight onClose: home() @@ -129,8 +154,7 @@ height: background.height Bar { id: bar - - content: BarEnumContent { value: (help | home | level | config) } + content: BarEnumContent { value: (help | home | level | config | activityConfig)} onHelpClicked: { displayDialog(dialogHelpLeftRight) } @@ -141,9 +165,12 @@ Activity.nextLevel() } onConfigClicked: { - dialogActivityConfig.active = true - displayDialog(dialogActivityConfig) - } + dialogActivityConfig.active = true + displayDialog(dialogActivityConfig) + } + onActivityConfigClicked: { + displayDialog(dialogActivityConf) + } onHomeClicked: home() } } @@ -176,14 +203,28 @@ id: otherItems property alias iAmReady: iAmReady property alias firstOp: firstOp + property alias okButton: okButton property alias secondOp: secondOp property alias numpad: numpad property int result } + BarButton { + id: okButton + x: parent.width * 0.60 + y: parent.height * 0.60 + source: "qrc:/gcompris/src/core/resource/bar_ok.svg" + sourceSize.width: 80 * ApplicationInfo.ratio + onClicked: Activity.questionsLeft(); + enabled: false + } + + Keys.onReturnPressed: okButton.enabled === true ? Activity.questionsLeft() : "" + Keys.onEnterPressed: okButton.enabled === true ? Activity.questionsLeft() : "" + NumPad { id: numpad - onAnswerChanged: Activity.questionsLeft() + onAnswerChanged: okButton.enabled = (answer != "") maxDigit: ('' + otherItems.result).length + 1 } diff --git a/src/activities/algebra_by/algebra.js b/src/activities/algebra_by/algebra.js --- a/src/activities/algebra_by/algebra.js +++ b/src/activities/algebra_by/algebra.js @@ -21,37 +21,31 @@ .import "qrc:/gcompris/src/core/core.js" as Core var currentLevel +var maxLevel var coreItems var otherItems +var dataset var operand var secondOperandVal var firstOperandVal -var operations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +var operations = [] var speedSetting var OperandsEnum = { TIMES_SIGN : "\u00D7", PLUS_SIGN : "\u002B", MINUS_SIGN : "\u2212", DIVIDE_SIGN : "\u2215" } -var nbLevel = operations.length function start(coreItems_, otherItems_, operand_, speedSetting_) { operand = operand_ coreItems = coreItems_ otherItems = otherItems_ speedSetting = speedSetting_ currentLevel = 0 - coreItems.score.numberOfSubLevels = 10 - // for multiplication and addition, the first levels will display - // currentLevel * N (N behind random) - // where the last levels will do: - // N * currentLevel - if(operand.text === OperandsEnum.TIMES_SIGN || operand.text === OperandsEnum.PLUS_SIGN) - nbLevel = 2 * operations.length - else - nbLevel = operations.length + dataset = coreItems.levels + maxLevel = dataset.length initLevel() } @@ -62,37 +56,63 @@ function initLevel() { coreItems.bar.level = currentLevel + 1 coreItems.score.visible = false + otherItems.okButton.visible = false coreItems.score.currentSubLevel = 1 + operations = [] + if(currentLevel === maxLevel) + initLastLevel(); + else { + coreItems.score.numberOfSubLevels = dataset[currentLevel].operands.length; + for( var i = 0; i < coreItems.score.numberOfSubLevels; i++) + operations.push([dataset[currentLevel].operands[i].first, dataset[currentLevel].operands[i].second]) + } operations = Core.shuffle(operations) calculateOperands() - otherItems.iAmReady.visible = true otherItems.firstOp.visible = false otherItems.secondOp.visible = false coreItems.balloon.stopMoving() } +function circularShiftElements() { + if(!validateAnswer(parseInt(otherItems.numpad.answer))) + operations.push(operations.shift()) + else + operations.shift() +} + function nextLevel() { - if(++currentLevel >= nbLevel) { + if(maxLevel < ++currentLevel) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { - currentLevel = nbLevel - 1 + currentLevel = maxLevel } initLevel(); } +function initLastLevel() { + coreItems.score.numberOfSubLevels = maxLevel * 5; + for (var i = 0; i < coreItems.score.numberOfSubLevels; i++) { + //randomly choose a level + var randomLevel = Math.floor(Math.random() * maxLevel) + // randomly choose question from level + var randomIndex = Math.floor(Math.random() * dataset[randomLevel].operands.length) + operations.push([dataset[randomLevel].operands[randomIndex].first, dataset[randomLevel].operands[randomIndex].second]) + } +} + function calculateOperands() { switch(operand.text) { case OperandsEnum.TIMES_SIGN: - firstOperandVal = coreItems.bar.level - secondOperandVal = operations[coreItems.score.currentSubLevel - 1] + firstOperandVal = operations[0][0] + secondOperandVal = operations[0][1] break; case OperandsEnum.PLUS_SIGN: firstOperandVal = coreItems.bar.level @@ -107,16 +127,8 @@ secondOperandVal = coreItems.bar.level break; } - - if(currentLevel < operations.length) { - otherItems.firstOp.text = firstOperandVal - otherItems.secondOp.text = secondOperandVal - } else { - otherItems.firstOp.text = secondOperandVal - // Don't forget to remove the first operations.length levels - firstOperandVal -= operations.length - otherItems.secondOp.text = firstOperandVal - } + otherItems.firstOp.text = firstOperandVal + otherItems.secondOp.text = secondOperandVal } // Return the expected answer @@ -131,7 +143,7 @@ case OperandsEnum.MINUS_SIGN: return (firstOperandVal - secondOperandVal) - + case OperandsEnum.DIVIDE_SIGN: return (firstOperandVal / secondOperandVal) } @@ -149,12 +161,15 @@ otherItems.iAmReady.visible = false otherItems.firstOp.visible = true otherItems.secondOp.visible = true + otherItems.okButton.visible = true otherItems.numpad.answerFlag = false otherItems.result = getAnswer() coreItems.balloon.startMoving(100000 / speedSetting) } function questionsLeft() { + otherItems.okButton.enabled = false + circularShiftElements() if(validateAnswer(parseInt(otherItems.numpad.answer))) { otherItems.numpad.answerFlag = true @@ -168,4 +183,6 @@ coreItems.bonus.good("smiley"); } } + else + coreItems.bonus.bad("smiley"); } diff --git a/src/activities/algebra_by/resource/1/Data.qml b/src/activities/algebra_by/resource/1/Data.qml --- a/src/activities/algebra_by/resource/1/Data.qml +++ b/src/activities/algebra_by/resource/1/Data.qml @@ -1,9 +1,9 @@ /* GCompris - Data.qml * - * Copyright (C) 2018 Johnny Jazeix + * Copyright (C) 2020 Shubham Mishra * * Authors: - * Johnny Jazeix + * 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 @@ -21,27 +21,52 @@ import "../../../../core" Dataset { - objective: qsTr("This is a long long long long objective. We want to see it it can display long long texts. But it is not long long long enough. Or maybe it is...") + objective: qsTr("Learn multiplication table of 1") + difficulty: 5 data: [ - { - "maxNumber": 1, /* Max number on each domino side */ - "minNumber": 1, - "numberOfFish": 3 - }, - { - "maxNumber": 2, - "minNumber": 1, - "numberOfFish": 4 - }, - { - "maxNumber": 3, - "minNumber": 1, - "numberOfFish": 5 - }, - { - "maxNumber": 4, - "minNumber": 1, - "numberOfFish": 5 - } + { + "operands": [ + { + "first": 1, + "second": 1 + }, + { + "first": 1, + "second": 2 + }, + { + "first": 1, + "second": 3 + }, + { + "first": 1, + "second": 4 + }, + { + "first": 1, + "second": 5 + }, + { + "first": 1, + "second": 6 + }, + { + "first": 1, + "second": 7 + }, + { + "first": 1, + "second": 8 + }, + { + "first": 1, + "second": 9 + }, + { + "first": 1, + "second": 10 + }, + ] + } ] } diff --git a/src/activities/algebra_by/resource/10/Data.qml b/src/activities/algebra_by/resource/10/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/algebra_by/resource/10/Data.qml @@ -0,0 +1,72 @@ +/* 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("Learn multiplication table of 10") + difficulty: 6 + data: [ + { + "operands": [ + { + "first": 10, + "second": 1 + }, + { + "first": 10, + "second": 2 + }, + { + "first": 10, + "second": 3 + }, + { + "first": 10, + "second": 4 + }, + { + "first": 10, + "second": 5 + }, + { + "first": 10, + "second": 6 + }, + { + "first": 10, + "second": 7 + }, + { + "first": 10, + "second": 8 + }, + { + "first": 10, + "second": 9 + }, + { + "first": 10, + "second": 10 + }, + ] + } + ] +} diff --git a/src/activities/algebra_by/resource/2/Data.qml b/src/activities/algebra_by/resource/2/Data.qml --- a/src/activities/algebra_by/resource/2/Data.qml +++ b/src/activities/algebra_by/resource/2/Data.qml @@ -1,9 +1,9 @@ /* GCompris - Data.qml * - * Copyright (C) 2018 Johnny Jazeix + * Copyright (C) 2020 Shubham Mishra * * Authors: - * Johnny Jazeix + * 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 @@ -21,27 +21,52 @@ import "../../../../core" Dataset { - objective: qsTr("obj 2") + objective: qsTr("Learn multiplication table of 2") + difficulty: 5 data: [ - { - "maxNumber": 1, /* Max number on each domino side */ - "minNumber": 1, - "numberOfFish": 3 - }, - { - "maxNumber": 2, - "minNumber": 1, - "numberOfFish": 4 - }, - { - "maxNumber": 3, - "minNumber": 1, - "numberOfFish": 5 - }, - { - "maxNumber": 4, - "minNumber": 1, - "numberOfFish": 5 - } + { + "operands": [ + { + "first": 2, + "second": 1 + }, + { + "first": 2, + "second": 2 + }, + { + "first": 2, + "second": 3 + }, + { + "first": 2, + "second": 4 + }, + { + "first": 2, + "second": 5 + }, + { + "first": 2, + "second": 6 + }, + { + "first": 2, + "second": 7 + }, + { + "first": 2, + "second": 8 + }, + { + "first": 2, + "second": 9 + }, + { + "first": 2, + "second": 10 + }, + ] + } ] } diff --git a/src/activities/algebra_by/resource/3/Data.qml b/src/activities/algebra_by/resource/3/Data.qml --- a/src/activities/algebra_by/resource/3/Data.qml +++ b/src/activities/algebra_by/resource/3/Data.qml @@ -1,9 +1,9 @@ /* GCompris - Data.qml * - * Copyright (C) 2018 Johnny Jazeix + * Copyright (C) 2020 Shubham Mishra * * Authors: - * Johnny Jazeix + * 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 @@ -21,27 +21,52 @@ import "../../../../core" Dataset { - objective: qsTr("obj 3") + objective: qsTr("Learn multiplication table of 3") + difficulty: 6 data: [ - { - "maxNumber": 1, /* Max number on each domino side */ - "minNumber": 1, - "numberOfFish": 3 - }, - { - "maxNumber": 2, - "minNumber": 1, - "numberOfFish": 4 - }, - { - "maxNumber": 3, - "minNumber": 1, - "numberOfFish": 5 - }, - { - "maxNumber": 4, - "minNumber": 1, - "numberOfFish": 5 - } + { + "operands": [ + { + "first": 3, + "second": 1 + }, + { + "first": 3, + "second": 2 + }, + { + "first": 3, + "second": 3 + }, + { + "first": 3, + "second": 4 + }, + { + "first": 3, + "second": 5 + }, + { + "first": 3, + "second": 6 + }, + { + "first": 3, + "second": 7 + }, + { + "first": 3, + "second": 8 + }, + { + "first": 3, + "second": 9 + }, + { + "first": 3, + "second": 10 + }, + ] + } ] } diff --git a/src/activities/algebra_by/resource/4/Data.qml b/src/activities/algebra_by/resource/4/Data.qml --- a/src/activities/algebra_by/resource/4/Data.qml +++ b/src/activities/algebra_by/resource/4/Data.qml @@ -1,9 +1,9 @@ /* GCompris - Data.qml * - * Copyright (C) 2018 Johnny Jazeix + * Copyright (C) 2020 Shubham Mishra * * Authors: - * Johnny Jazeix + * 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 @@ -21,27 +21,52 @@ import "../../../../core" Dataset { - objective: qsTr("obj 4") + objective: qsTr("Learn multiplication table of 4") + difficulty: 6 data: [ - { - "maxNumber": 1, /* Max number on each domino side */ - "minNumber": 1, - "numberOfFish": 3 - }, - { - "maxNumber": 2, - "minNumber": 1, - "numberOfFish": 4 - }, - { - "maxNumber": 3, - "minNumber": 1, - "numberOfFish": 5 - }, - { - "maxNumber": 4, - "minNumber": 1, - "numberOfFish": 5 - } + { + "operands": [ + { + "first": 4, + "second": 4 + }, + { + "first": 4, + "second": 2 + }, + { + "first": 4, + "second": 3 + }, + { + "first": 4, + "second": 4 + }, + { + "first": 4, + "second": 5 + }, + { + "first": 4, + "second": 6 + }, + { + "first": 4, + "second": 7 + }, + { + "first": 4, + "second": 8 + }, + { + "first": 4, + "second": 9 + }, + { + "first": 4, + "second": 10 + }, + ] + } ] } diff --git a/src/activities/algebra_by/resource/5/Data.qml b/src/activities/algebra_by/resource/5/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/algebra_by/resource/5/Data.qml @@ -0,0 +1,72 @@ +/* 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("Learn multiplication table of 5") + difficulty: 6 + data: [ + { + "operands": [ + { + "first": 5, + "second": 1 + }, + { + "first": 5, + "second": 2 + }, + { + "first": 5, + "second": 3 + }, + { + "first": 5, + "second": 4 + }, + { + "first": 5, + "second": 5 + }, + { + "first": 5, + "second": 6 + }, + { + "first": 5, + "second": 7 + }, + { + "first": 5, + "second": 8 + }, + { + "first": 5, + "second": 9 + }, + { + "first": 5, + "second": 10 + }, + ] + } + ] +} diff --git a/src/activities/algebra_by/resource/6/Data.qml b/src/activities/algebra_by/resource/6/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/algebra_by/resource/6/Data.qml @@ -0,0 +1,72 @@ +/* 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("Learn multiplication table of 6") + difficulty: 6 + data: [ + { + "operands": [ + { + "first": 6, + "second": 1 + }, + { + "first": 6, + "second": 2 + }, + { + "first": 6, + "second": 3 + }, + { + "first": 6, + "second": 4 + }, + { + "first": 6, + "second": 5 + }, + { + "first": 6, + "second": 6 + }, + { + "first": 6, + "second": 7 + }, + { + "first": 6, + "second": 8 + }, + { + "first": 6, + "second": 9 + }, + { + "first": 6, + "second": 10 + }, + ] + } + ] +} diff --git a/src/activities/algebra_by/resource/7/Data.qml b/src/activities/algebra_by/resource/7/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/algebra_by/resource/7/Data.qml @@ -0,0 +1,72 @@ +/* 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("Learn multiplication table of 7") + difficulty: 6 + data: [ + { + "operands": [ + { + "first": 7, + "second": 1 + }, + { + "first": 7, + "second": 2 + }, + { + "first": 7, + "second": 3 + }, + { + "first": 7, + "second": 4 + }, + { + "first": 7, + "second": 5 + }, + { + "first": 7, + "second": 6 + }, + { + "first": 7, + "second": 7 + }, + { + "first": 7, + "second": 8 + }, + { + "first": 7, + "second": 9 + }, + { + "first": 7, + "second": 10 + }, + ] + } + ] +} diff --git a/src/activities/algebra_by/resource/8/Data.qml b/src/activities/algebra_by/resource/8/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/algebra_by/resource/8/Data.qml @@ -0,0 +1,72 @@ +/* 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("Learn multiplication table of 8") + difficulty: 6 + data: [ + { + "operands": [ + { + "first": 8, + "second": 1 + }, + { + "first": 8, + "second": 2 + }, + { + "first": 8, + "second": 3 + }, + { + "first": 8, + "second": 4 + }, + { + "first": 8, + "second": 5 + }, + { + "first": 8, + "second": 6 + }, + { + "first": 8, + "second": 7 + }, + { + "first": 8, + "second": 8 + }, + { + "first": 8, + "second": 9 + }, + { + "first": 8, + "second": 10 + }, + ] + } + ] +} diff --git a/src/activities/algebra_by/resource/9/Data.qml b/src/activities/algebra_by/resource/9/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/algebra_by/resource/9/Data.qml @@ -0,0 +1,72 @@ +/* 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("Learn multiplication table of 9") + difficulty: 6 + data: [ + { + "operands": [ + { + "first": 9, + "second": 1 + }, + { + "first": 9, + "second": 2 + }, + { + "first": 9, + "second": 3 + }, + { + "first": 9, + "second": 4 + }, + { + "first": 9, + "second": 5 + }, + { + "first": 9, + "second": 6 + }, + { + "first": 9, + "second": 7 + }, + { + "first": 9, + "second": 8 + }, + { + "first": 9, + "second": 9 + }, + { + "first": 9, + "second": 10 + }, + ] + } + ] +}