diff --git a/src/activities/numbers-odd-even/NumbersOddEven.qml b/src/activities/numbers-odd-even/NumbersOddEven.qml --- a/src/activities/numbers-odd-even/NumbersOddEven.qml +++ b/src/activities/numbers-odd-even/NumbersOddEven.qml @@ -21,6 +21,8 @@ Planegame { + showTutorial: true + dataset: [ { data: "0 2 4 6 8 10 12 14 16 18 20".split(" "), @@ -39,4 +41,42 @@ showNext: false } ] + + tutorialInstructions: [ + { + "instruction": qsTr("This activity teaches about even and odd numbers."), + "instructionQml": "" + }, + { + "instruction": qsTr("Even numbers are numbers which leave remainder 0 when divided by 2."), + "instructionQml": "" + }, + + { + "instruction": qsTr("What is meant by remainder of a number?"), + "instructionQml" : "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial1.qml" + }, + + { + "instruction": qsTr("Even numbers are numbers which leave remainder 0 when divided by 2."), + "instructionQml" : "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial2.qml" + }, + { + "instruction": qsTr("Odd numbers are numbers which do not leave remainder 0 when divided by 2."), + "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial3.qml" + }, + { + "instruction": qsTr("Exercise to test your understanding."), + "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial4.qml" + }, + { + "instruction": qsTr("Exercise to test your understanding."), + "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial5.qml" + }, + { + "instruction": qsTr("Exercise to test your understanding."), + "instructionQml": "qrc:/gcompris/src/activities/numbers-odd-even/resource/Tutorial6.qml" + } + + ] } diff --git a/src/activities/numbers-odd-even/resource/Tutorial1.qml b/src/activities/numbers-odd-even/resource/Tutorial1.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/Tutorial1.qml @@ -0,0 +1,45 @@ +/* GCompris - Tutorial1.qml + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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" + +Rectangle { + id: tutorialRectangle + anchors.fill: parent + color: "#80FFFFFF" + + GCText { + id: remainder + text: qsTr("The remainder is the amount \"left over\" after dividing the given number with the other number.\n If 6 is divided by 2 the result is 3 and the remainder is 0.\n If 7 is divided by 2 the result is 3 and the remainder is 1.") + fontSizeMode: Text.Fit + fontSize: mediumSize + anchors.left: tutorialRectangle.left + anchors.leftMargin: parent.height * 0.01 + color: "black" + horizontalAlignment: Text.AlignLeft + width: parent.width + height: parent.height + wrapMode: Text.WordWrap + z: 2 + } +} diff --git a/src/activities/numbers-odd-even/resource/Tutorial2.qml b/src/activities/numbers-odd-even/resource/Tutorial2.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/Tutorial2.qml @@ -0,0 +1,45 @@ +/* GCompris - Tutorial2.qml + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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" + +Rectangle { + id: tutorialRectangle + anchors.fill: parent + color: "#80FFFFFF" + + GCText { + id: even + text: qsTr("For example: 12, 38, 52, 68, 102, 118, 168, 188, 502, 532, 700, 798, 842, 892, 1000. All of these numbers are even numbers as they leave remainder 0 when divided by 2.") + fontSizeMode: Text.Fit + fontSize: mediumSize + anchors.left: tutorialRectangle.left + anchors.leftMargin: parent.height * 0.01 + color: "black" + horizontalAlignment: Text.AlignLeft + width: parent.width + height: parent.height + wrapMode: Text.WordWrap + z: 2 + } +} diff --git a/src/activities/numbers-odd-even/resource/Tutorial3.qml b/src/activities/numbers-odd-even/resource/Tutorial3.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/Tutorial3.qml @@ -0,0 +1,45 @@ +/* GCompris - Tutorial3.qml + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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" + +Rectangle { + id: tutorialRectangle + anchors.fill: parent + color: "#80FFFFFF" + + GCText { + id: odd + text: qsTr("For example: 15, 19, 51, 65, 103, 119, 169, 185, 505, 533, 701, 799, 845, 897, 1001. All of these numbers are odd numbers as they do not leave remainder 0 when divided by 2.") + fontSizeMode: Text.Fit + fontSize: mediumSize + anchors.left: tutorialRectangle.left + anchors.leftMargin: parent.height * 0.01 + color: "black" + horizontalAlignment: Text.AlignLeft + width: parent.width + height: parent.height + wrapMode: Text.WordWrap + z: 2 + } +} diff --git a/src/activities/numbers-odd-even/resource/Tutorial4.qml b/src/activities/numbers-odd-even/resource/Tutorial4.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/Tutorial4.qml @@ -0,0 +1,31 @@ +/* GCompris - Tutorial4.qml + + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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" + +TutorialBase { + + firstNumber: "2" + secondNumber: "5" +} diff --git a/src/activities/numbers-odd-even/resource/Tutorial5.qml b/src/activities/numbers-odd-even/resource/Tutorial5.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/Tutorial5.qml @@ -0,0 +1,32 @@ +/* GCompris - Tutorial5.qml + + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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" + +TutorialBase { + + isEvenExpected: false + firstNumber: "59" + secondNumber: "52" +} diff --git a/src/activities/numbers-odd-even/resource/Tutorial6.qml b/src/activities/numbers-odd-even/resource/Tutorial6.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/Tutorial6.qml @@ -0,0 +1,30 @@ +/* GCompris - Tutorial6.qml + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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" + +TutorialBase { + + firstNumber: "111" + secondNumber: "108" +} diff --git a/src/activities/numbers-odd-even/resource/TutorialBase.qml b/src/activities/numbers-odd-even/resource/TutorialBase.qml new file mode 100644 --- /dev/null +++ b/src/activities/numbers-odd-even/resource/TutorialBase.qml @@ -0,0 +1,147 @@ +/* GCompris - TutorialBase.qml + * + * Copyright (C) 2019 Deepak Kumar + * + * Authors: + * Deepak 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 "../../../core" + +Rectangle { + id: tutorialRectangle + anchors.fill: parent + color: "#80FFFFFF" + property alias firstNumber: firstNumber.textLabel + property alias secondNumber: secondNumber.textLabel + property alias message: message.text + property bool isEvenExpected: true + + GCText { + id: question + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + leftMargin: parent.height * 0.1 + centerIn: parent.Center + top: parent.top + topMargin: parent.height * 0.05 + } + text: isEvenExpected ? qsTr("Choose the even number:") : qsTr("Choose the odd number:") + fontSize: mediumSize + color: "black" + horizontalAlignment: Text.AlignLeft + width: 1.8 * parent.width + height: 1.8 * parent.height + wrapMode: Text.WordWrap + z: 2 + } + + AnswerButton { + id: firstNumber + textLabel: "" + anchors { + top: parent.top + topMargin: parent.height * 0.3 + left: parent.left + leftMargin: parent.width * 0.2 + } + width: parent.width * 0.2 + height: parent.height * 0.4 + isCorrectAnswer: (isEvenExpected && Number(textLabel) % 2 === 0) || + (!isEvenExpected && Number(textLabel) % 2 !== 0) + onPressed: { + if(isCorrectAnswer) { + message.text = qsTr("Great") + } + else { + if(isEvenExpected) { + message.text = qsTr("There is an error: when divided by 2, %1 leaves remainder as 1. Therefore this is an odd number.").arg(textLabel) + } + else { + message.text = qsTr("There is an error: when divided by 2, %1 leaves remainder as 0. Therefore this is an even number.").arg(textLabel) + } + } + message.visible = true + messageRectangle.visible = true + } + } + + AnswerButton { + id: secondNumber + textLabel: "" + anchors { + top: parent.top + topMargin: parent.height * 0.3 + left: parent.left + leftMargin: parent.width * 0.65 + } + width: parent.width * 0.2 + height: parent.height * 0.4 + isCorrectAnswer: (isEvenExpected && Number(textLabel) % 2 === 0) || + (!isEvenExpected && Number(textLabel) % 2 !== 0) + onPressed: { + if(isCorrectAnswer) { + message.text = qsTr("Great") + } + else { + if(isEvenExpected) { + message.text = qsTr("There is an error: when divided by 2, %1 leaves remainder as 1. Therefore this is an odd number.").arg(textLabel) + } + else { + message.text = qsTr("There is an error: when divided by 2, %1 leaves remainder as 0. Therefore this is an even number.").arg(textLabel) + } + } + message.visible = true + messageRectangle.visible = true + } + } + + Rectangle { + id: messageRectangle + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + topMargin: parent.height * 0.75 + } + opacity: 0.8 + radius: 10 + border.width: 6 + color: "white" + border.color: "#87A6DD" + width: parent.width * 1.15 + height: parent.height * 0.4 + visible: false + + GCText { + id: message + anchors { + centerIn: parent + margins: parent.border.width+1 + } + text: "" + fontSizeMode: Text.Fit + fontSize: smallSize + color: "black" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + width: parent.width + height: parent.height + wrapMode: Text.WordWrap + z: 2 + } + } +} diff --git a/src/activities/planegame/Planegame.qml b/src/activities/planegame/Planegame.qml --- a/src/activities/planegame/Planegame.qml +++ b/src/activities/planegame/Planegame.qml @@ -36,6 +36,8 @@ Keys.onReleased: Activity.processReleasedKey(event) property var dataset + property var tutorialInstructions + property bool showTutorial: false property int oldWidth: width onWidthChanged: { @@ -60,9 +62,10 @@ sourceSize.width: parent.width Component.onCompleted: { - activity.start.connect(start) - activity.stop.connect(stop) + activity.start.connect(start) + activity.stop.connect(stop) } + QtObject { id: items property alias background: background @@ -74,11 +77,40 @@ property GCSfx audioEffects: activity.audioEffects property alias movePlaneTimer: movePlaneTimer property alias cloudCreation: cloudCreation + property bool showTutorial: activity.showTutorial + } + + onStart: { Activity.start(items, dataset) } + onStop: { Activity.stop() } + + //Tutorial section starts + Loader { + active: showTutorial + anchors.fill: parent + z: 1 + sourceComponent: tutorialComponent + Component { + id: tutorialComponent + Image { + id: tutorialImage + source: "../digital_electricity/resource/texture01.png" + anchors.fill: parent + fillMode: Image.Tile + Tutorial { + id: tutorialSection + tutorialDetails: tutorialInstructions + useImage: false + onSkipPressed: { + showTutorial = false + Activity.initLevel() + } + } + } + } } - onStart: Activity.start(items, dataset) - onStop: Activity.stop(); + // Tutorial section ends - MultiPointTouchArea { + MultiPointTouchArea { anchors.fill: parent touchPoints: [ TouchPoint { id: point1 } ] @@ -97,8 +129,12 @@ id: bar content: BarEnumContent { value: help | home | level } onHelpClicked: displayDialog(dialogHelp) - onPreviousLevelClicked: Activity.previousLevel() - onNextLevelClicked: Activity.nextLevel() + onPreviousLevelClicked: if(showTutorial === false) { + Activity.previousLevel() + } + onNextLevelClicked: if(showTutorial === false) { + Activity.nextLevel() + } onHomeClicked: activity.home() } @@ -109,11 +145,11 @@ Score { id: score - visible: false fontSize: background.width >= background.height ? internalTextComponent.largeSize : internalTextComponent.mediumSize height: internalTextComponent.height + 10 anchors.bottom: bar.top anchors.margins: 10 + visible: !showTutorial } property int movePlaneTimerCounter: 0 @@ -143,6 +179,7 @@ Plane { id: plane + visible: !showTutorial background: background } diff --git a/src/activities/planegame/planegame.js b/src/activities/planegame/planegame.js --- a/src/activities/planegame/planegame.js +++ b/src/activities/planegame/planegame.js @@ -52,7 +52,9 @@ dataset = dataset_ numberOfLevel = dataset.length currentLevel = 0 - initLevel() + if(items.showTutorial === false) { + initLevel() + } } function stop() { @@ -80,7 +82,6 @@ items.movePlaneTimer.stop(); items.cloudCreation.stop() - items.score.visible = dataset[currentLevel].showNext items.score.message = dataset[currentLevel].data[currentSubLevel] upPressed = false @@ -95,16 +96,17 @@ items.plane.state = "init" items.movePlaneTimer.interval = 1000 items.movePlaneTimer.start(); + items.score.visible = dataset[currentLevel].showNext items.cloudCreation.start() - // Inject the first cloud now - createCloud() + + //Inject the first cloud now + createCloud() } function nextLevel() { if(numberOfLevel <= ++currentLevel) { currentLevel = 0 } - initLevel(); }