diff --git a/src/activities/multiplication_tables/Multiplication_tables.qml b/src/activities/multiplication_tables/Multiplication_tables.qml index b2f1ec79b..d8042bff3 100644 --- a/src/activities/multiplication_tables/Multiplication_tables.qml +++ b/src/activities/multiplication_tables/Multiplication_tables.qml @@ -1,982 +1,370 @@ /* GCompris - multiplication_tables.qml * - * Copyright (C) 2016 YOUR NAME + * Copyright (C) 2016 Nitish Chauhan * * Authors: - * (GTK+ version) - * YOUR NAME (Qt Quick port) + * + * Nitish Chauhan (Qt Quick port) * * 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.1 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 import "../../core" -import "multiplication_tables.js" as Activity -import "drawnumber_dataset.js" as Dataset +import "multiplication_tables.js" +as Activity +import "multiplicationtables_dataset.js" +as Dataset -ActivityBase { - id: activity - property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" - property double startTime: 0 - property int flag: 0 +ActivityBase { + id: activity + + property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" + property double startTime: 0 + property int flag: 0 + property var dataset: Dataset + property string mode: "multiplicationtables" + + onStart: focus = true + onStop: {} + + pageComponent: Rectangle { + id: background + anchors.fill: parent + color: "#ABCDEF" + signal start + signal stop + + Component.onCompleted: { + activity.start.connect(start) + activity.stop.connect(stop) + } - property var dataset: Dataset - property string mode: "multiplicationtables" + // Add here the QML items you need to access in javascript + QtObject { - onStart: focus = true - onStop: {} + id: items + property Item main: activity.main + property alias background: background + property alias bar: bar + property alias bonus: bonus + property alias heading_text: heading_text + property alias start_button: start_button + property alias stop_button: stop_button + property alias time: time + property alias score: score - pageComponent: Rectangle { - id: background - anchors.fill: parent - color: "#ABCDEF" - signal start - signal stop + property alias questionGrid: questionGrid + property alias repeater: repeater - Component.onCompleted: { - activity.start.connect(start) - activity.stop.connect(stop) - } - // Add here the QML items you need to access in javascript - QtObject { - id: items - property Item main: activity.main - property alias background: background - property alias bar: bar - property alias bonus: bonus - - - property alias tabletext_1: tabletext_1 - property alias tabletext_2: tabletext_2 - property alias tabletext_3: tabletext_3 - property alias tabletext_4: tabletext_4 - property alias tabletext_5: tabletext_5 - property alias tabletext_6: tabletext_6 - property alias tabletext_7: tabletext_7 - property alias tabletext_8: tabletext_8 - property alias tabletext_9: tabletext_9 - property alias tabletext_10: tabletext_10 - - property alias ans_1: ans_1 - property alias ans_2: ans_2 - property alias ans_3: ans_3 - property alias ans_4: ans_4 - property alias ans_5: ans_5 - property alias ans_6: ans_6 - property alias ans_7: ans_7 - property alias ans_8: ans_8 - property alias ans_9: ans_9 - property alias ans_10: ans_10 - - property alias img_1: img_1 - property alias img_2: img_2 - property alias img_3: img_3 - property alias img_4: img_4 - property alias img_5: img_5 - property alias img_6: img_6 - property alias img_7: img_7 - property alias img_8: img_8 - property alias img_9: img_9 - property alias img_10: img_10 - - property alias heading_text:heading_text - - property alias start_button: start_button - property alias stop_button: stop_button - property alias time: time - property alias score: score + } + onStart: { + Activity.start(items, mode, dataset, url) - } + } + onStop: { + Activity.stop() + } - onStart: { Activity.start(items,mode,dataset,url) } - onStop: { Activity.stop() } + //........................................................................... -//........................................................................... + // main heading + GCText { + id: heading_text + text:"Heading Text" + font.pointSize: 30 + color: "red" + anchors.top: parent.top; + anchors.margins: 20 + anchors.horizontalCenter: parent.horizontalCenter + } -// main heading -Text { - id: heading_text - font.family: "Helvetica" - font.pointSize: 30 - color: "red" - anchors.top: parent.top; - anchors.margins: 20 - anchors.horizontalCenter: parent.horizontalCenter + Grid { -} + id: questionGrid + spacing: 40 -// 10 questions -Text { - id: tabletext_1 - font.family: "Helvetica" - font.pointSize: 25 - font.bold: true - color: "black" - anchors.right : divider_img.left; - anchors.top: heading_text.bottom anchors { - topMargin: 65 - rightMargin: 360 - } -} - - -TextField { - - id:ans_1 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_1.right - anchors.top: heading_text.bottom - anchors { - topMargin: 65 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } - } - -} - - -Image { - id:img_1 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - anchors.left : ans_1.right - anchors.top: heading_text.bottom - anchors { - topMargin: 45 - leftMargin: 40 - } - -} - + left: parent.left + right: parent.rigth + top: heading_text.bottom + margins: 20 + } -Text { - id: tabletext_2 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.right : divider_img.left; - anchors.top: tabletext_1.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - rightMargin: 360 - } - - -} - -TextField { - - id:ans_2 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_2.right - anchors.top: ans_1.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } - } - -} - -Image { - id:img_2 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_1.right - anchors.top: ans_1.bottom - anchors { - topMargin: 35 - leftMargin: 40 - } + Repeater { -} + id: repeater + model: 10 + Question { + } + } -Text { - id: tabletext_3 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.right : divider_img.left; - anchors.top: tabletext_2.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - rightMargin: 360 - } -} + } -TextField { - - id:ans_3 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_3.right - anchors.top: ans_2.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } - } -} -Image { - id:img_3 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_2.right - anchors.top: ans_2.bottom - anchors { - topMargin: 35 - leftMargin: 40 - } +//} -} + Button { + id: stop_button + text: qsTr(" FINISH ") + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors { + bottomMargin: 50 + rightMargin: 120 + } -Text { - id: tabletext_4 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.right : divider_img.left; - anchors.top: tabletext_3.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - rightMargin: 360 - } -} -TextField { - - id:ans_4 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_4.right - anchors.top: ans_3.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + border.width: control.activeFocus ? 2 : 1 + border.color: "blue" + radius: 4 + gradient: Gradient { + GradientStop { + position: 0;color: control.pressed ? "#729fcf" : "#729fcf" } - -} - -Image { - id:img_4 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_3.right - anchors.top: ans_3.bottom - anchors { - topMargin: 35 - leftMargin: 40 - } - -} - - - - - - -Text { - id: tabletext_5 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.right : divider_img.left; - anchors.top: tabletext_4.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - rightMargin: 360 - } - -} - -TextField { - - id:ans_5 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_5.right - anchors.top: ans_4.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } + GradientStop { + position: 1;color: control.pressed ? "#3465a4" : "#3465a4" } + } + } + } -} - -Image { - id:img_5 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_4.right - anchors.top: ans_4.bottom - anchors { - topMargin: 35 - leftMargin: 40 - } -} + onClicked: { + if (flag == 1) { + score.visible = true + var str1 = new Date().getTime() - startTime -Image { - id: divider_img + time.text = qsTr("Your time: %1 ms").arg(str1) - anchors.horizontalCenter: parent.horizontalCenter - anchors.top:heading_text.bottom - source: activity.url + "divider_img.svg" - sourceSize: width = parent.width/14,height = parent.height/1.6 - anchors { - topMargin: 15 + startTime = 0 + flag = 0 + start_button.text = qsTr("Start again") + Activity.verifyAnswer() - } - } + } + } + } -Text { - id: tabletext_6 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.left : divider_img.right; - anchors.top: heading_text.bottom - anchors.margins: 20 - anchors { - topMargin: 65 - leftMargin:160 - } -} + Button { + id: start_button + text: qsTr(" START ") + anchors.bottom: parent.bottom + anchors.right: stop_button.left + anchors { + bottomMargin: 50 + rightMargin: 30 + } -TextField { - - id:ans_6 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_6.right - anchors.top: heading_text.bottom - anchors { - topMargin: 65 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + border.width: control.activeFocus ? 2 : 1 + border.color: "blue" + radius: 4 + gradient: Gradient { + GradientStop { + position: 0;color: control.pressed ? "#729fcf" : "#729fcf" } - -} - -Image { - id:img_6 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_6.right - anchors.top: heading_text.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - -} - - - - - - -Text { - id: tabletext_7 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.left : divider_img.right; - anchors.top: tabletext_6.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - leftMargin: 160 - } - -} - -TextField { - - id:ans_7 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_7.right - anchors.top: ans_6.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } + GradientStop { + position: 1;color: control.pressed ? "#3465a4" : "#3465a4" } + } + } + } -} - -Image { - id:img_7 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_7.right - anchors.top: ans_6.bottom - anchors { - topMargin: 40 - leftMargin: 40 - } - -} - - - - - - - -Text { - id: tabletext_8 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.left : divider_img.right; - anchors.top: tabletext_7.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - leftMargin: 160 - } -} + onClicked: { -TextField { - - id:ans_8 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_8.right - anchors.top: ans_7.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } - } + if (startTime == 0 && flag == 0) { -} + Activity.resetvalue() + start_button.text = qsTr(" START ") + time.text = qsTr(" Your timer started...") + startTime = new Date().getTime() + flag = 1 -Image { - id:img_8 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_8.right - anchors.top: ans_7.bottom - anchors { - topMargin: 40 - leftMargin: 40 - } + } -} + } + } + GCText { + id: score + font.pointSize: 20 + color: "#cc0000" + font.bold: true + anchors.bottom: time.top + anchors.right: parent.right + anchors { + bottomMargin: 15 + rightMargin: 150 -Text { - id: tabletext_9 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.left : divider_img.right; - anchors.top: tabletext_8.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - leftMargin: 160 - } -} + } -TextField { - - id:ans_9 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_9.right - anchors.top: ans_8.bottom - anchors { - topMargin: 50 - leftMargin: 40 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } - } + Layout.alignment: Qt.AlignCenter + } -} -Image { - id:img_9 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - source: activity.url + "wrong.svg" - anchors.left : ans_9.right - anchors.top: ans_8.bottom - anchors { - topMargin: 40 - leftMargin: 40 - } -} + //........implementing timer.............. + GCText { + id: time + font.pixelSize: 23 + font.bold: true + color: '#cc0000' + anchors.bottom: start_button.top + anchors.right: parent.right + anchors { + bottomMargin: 30 + rightMargin: 130 + } + text: qsTr("--") + Layout.alignment: Qt.AlignCenter + } -Text { - id: tabletext_10 - font.family: "Helvetica" - font.pointSize: 25 - color: "black" - font.bold: true - anchors.left : divider_img.right; - anchors.top: tabletext_9.bottom - anchors.margins: 20 - anchors { - topMargin: 40 - leftMargin: 160 - } + //........timerend.......................................................... -} -TextField { - - id:ans_10 - width: main.width - units.gu(25) - height: 35 - font.pixelSize: 20 - anchors.left : tabletext_10.right - anchors.top: ans_9.bottom - anchors { - topMargin: 50 - leftMargin: 23 - } - - style: TextFieldStyle { - textColor: "red" - background: Rectangle { - radius: 5 - color: "orange" - implicitWidth: 100 - implicitHeight: 24 - border.color: "#333" - border.width: 1 - } - } -} -Image { - id:img_10 - visible: false - width: 80; height: 60 - fillMode: Image.PreserveAspectFit - anchors.left : ans_10.right - anchors.top: ans_9.bottom - anchors { - topMargin: 40 - leftMargin: 40 - } + //........................................................................... -} + DialogActivityConfig { + id: dialogActivityConfig + currentActivity: activity + content: Component { + Item { + height: column.height + Column { + id: column + spacing: 10 + width: parent.width -Button { - id: stop_button - text: " FINISH " - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors { - bottomMargin: 50 - rightMargin: 120 + GCDialogCheckBox { + id: easyModeBox1 + width: 250 * ApplicationInfo.ratio + text: qsTr("School Mode") + checked: background.easyMode + onCheckedChanged: { + background.easyMode = checked + Activity.reloadRandom() + } } - style: ButtonStyle { - background: Rectangle { - implicitWidth: 100 - implicitHeight: 40 - border.width: control.activeFocus ? 2 : 1 - border.color: "blue" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#729fcf" : "#729fcf" } - GradientStop { position: 1 ; color: control.pressed ? "#3465a4" : "#3465a4" } - } - } - } - - - onClicked: { - - - if(flag==1){ - - - score.visible = true - var str1 = new Date().getTime() - startTime - time.text = " Your time :- " + str1 + " ms" - startTime = 0 - flag = 0 - start_button.text = "Start again" - Activity.verifyAnswer() - + } } - } -} - - + } - -Button { - id: start_button - text: " START " - anchors.bottom: parent.bottom - anchors.right: stop_button.left - anchors { - bottomMargin: 50 - rightMargin: 30 - } - - style: ButtonStyle { - background: Rectangle { - implicitWidth: 100 - implicitHeight: 40 - border.width: control.activeFocus ? 2 : 1 - border.color: "blue" - radius: 4 - gradient: Gradient { - GradientStop { position: 0 ; color: control.pressed ? "#729fcf" : "#729fcf" } - GradientStop { position: 1 ; color: control.pressed ? "#3465a4" : "#3465a4" } - } + onLoadData: { + if (dataToSave && dataToSave["mode"]) { + background.easyMode = (dataToSave["mode"] === "true"); } - } - - - onClicked: { - - if(startTime == 0 && flag==0){ - - Activity.resetvalue() - start_button.text = " START " - time.text = " Your timer started..." - startTime = new Date().getTime() - flag = 1 + } + onSaveData: { + dataToSave = { + "mode": "" + background.easyMode } + } + onClose: home() } -} -Text { - id: score - font.pointSize: 25 - - color: "#cc0000" - font.bold: true - - anchors.bottom: time.top - anchors.right: parent.right - - anchors { - bottomMargin: 15 - rightMargin: 150 - - } - - Layout.alignment: Qt.AlignCenter -} - - - - -//........implementing timer.............. - - - Text { - id: time - font.pixelSize: 27 - font.bold: true - color: '#cc0000' - anchors.bottom: start_button.top - anchors.right: parent.right - anchors { - bottomMargin: 30 - rightMargin: 130 - } - text: "--" - Layout.alignment: Qt.AlignCenter - } - - - -//........timerend.......................................................... - - - - - -//........................................................................... - - DialogActivityConfig { - id: dialogActivityConfig - currentActivity: activity - content: Component { - Item { - height: column.height - - Column { - id: column - spacing: 10 - width: parent.width - - GCDialogCheckBox { - id: easyModeBox1 - width: 250 * ApplicationInfo.ratio - text: qsTr("School Mode") - checked: background.easyMode - onCheckedChanged: { - background.easyMode = checked - Activity.reloadRandom() - } - } - - } - - } - } - - onLoadData: { - if(dataToSave && dataToSave["mode"]) { - background.easyMode = (dataToSave["mode"] === "true"); - } - } - - onSaveData: { - dataToSave = { "mode": "" + background.easyMode } - } - - onClose: home() - } - - - - DialogHelp { - id: dialogHelp - onClose: home() - } + DialogHelp { + id: dialogHelp + onClose: home() + } - Bar { - id: bar - content: BarEnumContent { value: help | home | level | config} - onHelpClicked: { - displayDialog(dialogHelp) - } - onPreviousLevelClicked: Activity.previousLevel() - onNextLevelClicked: Activity.nextLevel() - onHomeClicked: activity.home() - onReloadClicked: Activity.reloadRandom() - onConfigClicked: { - dialogActivityConfig.active = true - displayDialog(dialogActivityConfig) - } - } + Bar { + id: bar + content: BarEnumContent { + value: help | home | level | config + } + onHelpClicked: { + displayDialog(dialogHelp) + } + onPreviousLevelClicked: Activity.previousLevel() + onNextLevelClicked: Activity.nextLevel() + onHomeClicked: activity.home() + onReloadClicked: Activity.reloadRandom() + onConfigClicked: { + dialogActivityConfig.active = true + displayDialog(dialogActivityConfig) + } + } - Bonus { - id: bonus - Component.onCompleted: win.connect(Activity.nextLevel) - } + Bonus { + id: bonus + Component.onCompleted: win.connect(Activity.nextLevel) } + } } diff --git a/src/activities/multiplication_tables/Question.qml b/src/activities/multiplication_tables/Question.qml new file mode 100644 index 000000000..dff9b595a --- /dev/null +++ b/src/activities/multiplication_tables/Question.qml @@ -0,0 +1,92 @@ +/* GCompris + * + * + * 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.1 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Layouts 1.1 + +import "multiplication_tables.js" as Activity + +import QtGraphicalEffects 1.0 +import "../../core" +import GCompris 1.0 + + + + +Row { + + id: row1 + + property string url: "qrc:/gcompris/src/activities/multiplication_tables/resource/" + + property alias questionText: tabletext_1.text + property alias answerText: ans_1.text + property alias questionImage: question_image.source + property alias questionImage_visible: question_image.opacity + + + + + // 10 questions + GCText { + id: tabletext_1 + text:"Question" + font.pointSize: 20 + font.bold: true + color: "black" + + } + + + + TextField { + + id: ans_1 + height: 35 + font.pixelSize: 20 + + + style: TextFieldStyle { + textColor: "red" + background: Rectangle { + radius: 5 + color: "orange" + implicitWidth: 100 + implicitHeight: 24 + border.color: "#333" + border.width: 1 + } + } + + } + + Image { + id: question_image + width: 70;height: 50 + fillMode: Image.PreserveAspectFit + source: "qrc:/gcompris/src/activities/multiplication_tables/resource/wrong.svg" + opacity: 0 + } + + + +} + + + + diff --git a/src/activities/multiplication_tables/multiplication_tables.js b/src/activities/multiplication_tables/multiplication_tables.js index 6e02f5fc2..8c0caac5f 100644 --- a/src/activities/multiplication_tables/multiplication_tables.js +++ b/src/activities/multiplication_tables/multiplication_tables.js @@ -1,302 +1,161 @@ /* GCompris - multiplication_tables.js * - * Copyright (C) 2016 YOUR NAME + * Copyright (C) 2016 Nitish Chauhan * * Authors: - * (GTK+ version) - * "YOUR NAME" (Qt Quick port) + * + * "Nitish Chauhan" (Qt Quick port) * * 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 . */ .pragma library -.import QtQuick 2.2 as Quick -.import GCompris 1.0 as GCompris //for ApplicationInfo -.import "qrc:/gcompris/src/core/core.js" as Core + .import QtQuick 2.2 as Quick + .import GCompris 1.0 as GCompris //for ApplicationInfo + .import "qrc:/gcompris/src/core/core.js" as Core + var currentLevel = 0 var items var mode var dataset var numberOfLevel var url var table var question = [] var answer = [] var score_cnt = 0 +function start(_items, _mode, _dataset, _url) { -function start(_items, _mode,_dataset,_url) { - items = _items - mode = _mode - dataset = _dataset.get() - url = _url - numberOfLevel = dataset.length - currentLevel = 0 - initLevel() -} - - - -function stop() { -} - -function initLevel() { - items.bar.level = currentLevel + 1 - loadCoordinates() - + items = _items + mode = _mode + dataset = _dataset.get() + url = _url + numberOfLevel = dataset.length + currentLevel = 0 + initLevel() } -function loadCoordinates() { +function stop() {} +function initLevel() { -question = dataset[currentLevel].questions -answer = dataset[currentLevel].answers -table = dataset[currentLevel].TableName -items.heading_text.text = "Table of " + table + items.bar.level = currentLevel + 1 + loadCoordinates() -items.tabletext_1.text = question[0] + " = " -items.tabletext_2.text = question[1] + " = " -items.tabletext_3.text = question[2] + " = " -items.tabletext_4.text = question[3] + " = " -items.tabletext_5.text = question[4] + " = " -items.tabletext_6.text = question[5] + " = " -items.tabletext_7.text = question[6] + " = " -items.tabletext_8.text = question[7] + " = " -items.tabletext_9.text = question[8] + " = " -items.tabletext_10.text = question[9] + " = " } +function loadCoordinates() { + var i -function verifyAnswer() { - - - if(items.ans_1.text.toString()==answer[0]){ - - score_cnt = score_cnt + 1 - items.img_1.source = url + "right.svg" - items.img_1.visible = true - - - - } - else{ - - items.img_1.visible = true - items.img_1.source = url + "wrong.svg" - - } - - - - - if(items.ans_2.text.toString()==answer[1]){ - - score_cnt = score_cnt + 1 - items.img_2.source = url + "right.svg" - items.img_2.visible = true - - } - else{ - - items.img_2.source = url + "wrong.svg" - items.img_2.visible = true - } - - - - if(items.ans_3.text.toString()==answer[2]){ - - score_cnt = score_cnt + 1 - items.img_3.source = url + "right.svg" - items.img_3.visible = true - - } - else{ - - items.img_3.source = url + "wrong.svg" - items.img_3.visible = true - } - - - - if(items.ans_4.text.toString()==answer[3]){ - - score_cnt = score_cnt + 1 - items.img_4.source = url + "right.svg" - items.img_4.visible = true - - } - else{ - - items.img_4.source = url + "wrong.svg" - items.img_4.visible = true - } - - - - - if(items.ans_5.text.toString()==answer[4]){ - - score_cnt = score_cnt + 1 - items.img_5.source = url + "right.svg" - items.img_5.visible = true - } - else{ + question = dataset[currentLevel].questions + answer = dataset[currentLevel].answers + table = dataset[currentLevel].TableName - items.img_5.source = url + "wrong.svg" - items.img_5.visible = true - } + items.heading_text.text = qsTr("Table of %1").arg(table) + for(i=0;i * 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 . */ function get() { return [ - { + + { "TableName": "2", "questions": ["2 X 1","2 X 2","2 X 3","2 X 4","2 X 5","2 X 6","2 X 7","2 X 8","2 X 9","2 X 10"], "answers": ["2","4","6","8","10","12","14","16","18","20"] }, { "TableName": "3", "questions": ["3 X 1","3 X 2","3 X 3","3 X 4","3 X 5","3 X 6","3 X 7","3 X 8","3 X 9","3 X 10"], "answers": ["3","6","9","12","15","18","21","24","27","30"] }, { "TableName": "4", "questions": ["4 X 1","4 X 2","4 X 3","4 X 4","4 X 5","4 X 6","4 X 7","4 X 8","4 X 9","4 X 10"], "answers": ["4","8","12","16","20","24","28","32","36","40"] }, { "TableName": "5", "questions": ["5 X 1","5 X 2","5 X 3","5 X 4","5 X 5","5 X 6","5 X 7","5 X 8","5 X 9","5 X 10"], "answers": ["5","10","15","20","25","30","35","40","45","50"] }, { "TableName": "6", "questions": ["6 X 1","6 X 2","6 X 3","6 X 4","6 X 5","6 X 6","6 X 7","6 X 8","6 X 9","6 X 10"], "answers": ["6","12","18","24","30","36","42","48","54","60"] }, { "TableName": "7", "questions": ["7 X 1","7 X 2","7 X 3","7 X 4","7 X 5","7 X 6","7 X 7","7 X 8","7 X 9","7 X 10"], "answers": ["7","14","21","28","35","42","48","56","63","70"] }, { "TableName": "8", "questions": ["8 X 1","8 X 2","8 X 3","8 X 4","8 X 5","8 X 6","8 X 7","8 X 8","8 X 9","8 X 10"], "answers": ["8","16","24","32","40","48","56","64","72","80"] }, { "TableName": "9", "questions": ["9 X 1","9 X 2","9 X 3","9 X 4","9 X 5","9 X 6","9 X 7","9 X 8","9 X 9","9 X 10"], "answers": ["9","18","27","36","45","54","63","72","81","90"] } ] } + +