diff --git a/src/activities/multiplication_tables/Multiplication_tables.qml b/src/activities/multiplication_tables/Multiplication_tables.qml --- a/src/activities/multiplication_tables/Multiplication_tables.qml +++ b/src/activities/multiplication_tables/Multiplication_tables.qml @@ -38,7 +38,6 @@ property var dataset: Dataset property string mode: "multiplicationtables" - onStart: focus = true onStop: {} @@ -61,20 +60,16 @@ property alias background: background property alias bar: bar property alias bonus: bonus - property string modeType: "normalMode" property alias startButton: startButton property alias stopButton: stopButton property alias time: time property alias score: score property alias questionGrid: questionGrid property alias repeater: repeater - property alias repeaterModel: repeater.model - - property string isSchoolMode: isSchoolMode + property string modeType: modeType property var data: Dataset property alias keyboard: keyboard - } onStart: { @@ -86,7 +81,6 @@ Flow { id: questionGrid - opacity: 1 anchors.top: parent.top anchors.bottom: startStopButton.top spacing: 30/800*parent.width @@ -176,21 +170,9 @@ } } onClicked: { - if (startTime == 0 && startButtonClicked == false) { - - if(items.isSchoolMode == "school"){ - - Activity.resetvalue2() - Activity.canAnswer2() - - } - else{ - - Activity.resetvalue() - Activity.canAnswer() - - } - + if (startTime == 0 && startButtonClicked == false) { + Activity.canAnswer() + Activity.resetvalue() startButton.text = qsTr("START") time.text = qsTr(" Your Timer Started...") startTime = new Date().getTime() @@ -220,7 +202,6 @@ } } } - onClicked: { if (startButtonClicked == true) { score.visible = true @@ -229,37 +210,27 @@ startTime = 0 startButtonClicked = false startButton.text = qsTr("START AGAIN") - - if(items.isSchoolMode == "school"){ - + if(items.modeType == "school"){ Activity.verifyAnswer2() - Activity.cannotAnswer2() } else{ - Activity.verifyAnswer() - Activity.cannotAnswer() } - - + Activity.cannotAnswer() } } } } - DialogHelp { id: dialogHelp onClose: home() } - - DialogActivityConfig { id: dialogActivityConfig currentActivity: activity content: Component { Item { - property alias modeBox: modeBox property alias repeater2: repeater2 property var availableModes: [ @@ -300,7 +271,6 @@ top: labels.bottom topMargin: 5 } - Grid { spacing : 30 columns: 10 @@ -316,30 +286,28 @@ } } } - onClose: { Activity.initLevel() home() } - - onLoadData: { } - onSaveData: { - + if(dialogActivityConfig.configItem.modeBox.currentIndex == 1){ + items.modeType = "normal" + } + else{ + Activity.flushQuestionsAnswers() var j1 = 0 for (var i = 0; i < Activity.allQuestions.length; i++) { if(dialogActivityConfig.configItem.repeater2.itemAt(i).questionChecked === true){ Activity.selectedQuestions[j1] = dialogActivityConfig.configItem.repeater2.itemAt(i).selectedQuestionText Activity.selectedAnswers[j1] = Activity.allAnswers[i] j1 = j1 + 1 - } } - - Activity.loadSchoolMode() - items.isSchoolMode = "school" + items.modeType = "school" + } } function setDefaultValues() { @@ -352,7 +320,6 @@ } } - Bar { id: bar content: BarEnumContent { diff --git a/src/activities/multiplication_tables/multiplication_tables.js b/src/activities/multiplication_tables/multiplication_tables.js --- a/src/activities/multiplication_tables/multiplication_tables.js +++ b/src/activities/multiplication_tables/multiplication_tables.js @@ -1,28 +1,28 @@ /* GCompris - multiplication_tables.js -* -* Copyright (C) 2016 Nitish Chauhan -* -* Authors: -* -* "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 . -*/ + * + * Copyright (C) 2016 Nitish Chauhan + * + * Authors: + * + * "Nitish Chauhan" + * + * 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 schoolMode @@ -53,36 +53,28 @@ numberOfLevel = dataset.length currentLevel = 0 initLevel() - loadQuestions2() + loadAllQuestionAnswer() } function stop() {} function initLevel() { items.bar.level = currentLevel + 1 - if(items.isSchoolMode == "school"){ + if (items.modeType == "school") { loadSchoolMode() - console.log("school mode") - resetvalue2(); - items.startButton.text = qsTr("START") - items.score.visible = false - items.time.text = "--" loadSelectedQuestions() - cannotAnswer2() + } else { + loadAllQuestionAnswer() + items.repeaterModel = 10 + loadQuestions() } - - else{ - console.log("normad mode") - resetvalue(); items.startButton.text = qsTr("START") items.score.visible = false items.time.text = "--" - loadQuestions() + resetvalue() cannotAnswer() } -} - function loadQuestions() { var i var j @@ -95,10 +87,8 @@ } - function loadSelectedQuestions() { - var i - var j + var i = 0 question2 = selectedQuestions answer2 = selectedAnswers for (i = 0; i < question2.length; i++) { @@ -106,28 +96,33 @@ } } - function loadSchoolMode() { items.repeaterModel = selectedQuestions } +function flushQuestionsAnswers() { + selectedQuestions = [] + selectedAnswers = [] + question2 = [] + answer2 = [] +} -function loadQuestions2() { +function loadAllQuestionAnswer() { var i var j var t1 = 0 var t2 = 0 for (i = 0; i < numberOfLevel; i++) { - questionOfLevel = dataset[i].questions - answerOfLevel = dataset[i].answers - for(j = 0; j < questionOfLevel.length;j++){ - allQuestions[t1] = questionOfLevel[j] - t1 = t1 + 1 - } - for(j = 0; j < answerOfLevel.length;j++){ - allAnswers[t2] = answerOfLevel[j] - t2 = t2 + 1 - } + questionOfLevel = dataset[i].questions + answerOfLevel = dataset[i].answers + for (j = 0; j < questionOfLevel.length; j++) { + allQuestions[t1] = questionOfLevel[j] + t1 = t1 + 1 + } + for (j = 0; j < answerOfLevel.length; j++) { + allAnswers[t2] = answerOfLevel[j] + t2 = t2 + 1 + } } } @@ -138,8 +133,7 @@ scoreCounter = scoreCounter + 1 items.repeater.itemAt(j).questionImage = url + "right.svg" items.repeater.itemAt(j).questionImageOpacity = 1 - } - else if(items.repeater.itemAt(j).answerText.toString() != answer[j] && items.repeater.itemAt(j).answerText.toString() != ""){ + } else if (items.repeater.itemAt(j).answerText.toString() != answer[j] && items.repeater.itemAt(j).answerText.toString() != "") { items.repeater.itemAt(j).questionImageOpacity = 1 items.repeater.itemAt(j).questionImage = url + "wrong.svg" } @@ -154,8 +148,7 @@ scoreCounter = scoreCounter + 1 items.repeater.itemAt(j).questionImage = url + "right.svg" items.repeater.itemAt(j).questionImageOpacity = 1 - } - else if(items.repeater.itemAt(j).answerText.toString() != answer2[j] && items.repeater.itemAt(j).answerText.toString() != ""){ + } else if (items.repeater.itemAt(j).answerText.toString() != answer2[j] && items.repeater.itemAt(j).answerText.toString() != "") { items.repeater.itemAt(j).questionImageOpacity = 1 items.repeater.itemAt(j).questionImage = url + "wrong.svg" } @@ -163,10 +156,8 @@ items.score.text = qsTr("Your Score :- %1").arg(scoreCounter.toString()) } - function processKeyPress(text) { var typedText = uppercaseOnly ? text.toLocaleUpperCase() : text; - if (currentWord !== null) { // check against a currently typed word if (!currentWord.checkMatch(typedText)) { @@ -178,7 +169,7 @@ } else { // no current word, check against all available words var found = false - for (var i = 0; i< droppedWords.length; i++) { + for (var i = 0; i < droppedWords.length; i++) { if (droppedWords[i].checkMatch(typedText)) { // typed correctly currentWord = droppedWords[i]; @@ -187,63 +178,54 @@ break; } } - if(!found) { + if (!found) { audioCrashPlay() } } if (currentWord !== null && currentWord.isCompleted()) { // win! - currentWord.won(); // note: deleteWord() is triggered after fadeout + currentWord.won(); // note: deleteWord() is triggered after fadeout successRate += 0.1 currentWord = null nextSubLevel(); } } - function canAnswer() { var q - for (q = 0; q < question.length; q++) { - items.repeater.itemAt(q).answerTextReadonly = false + var questionList + if (items.modeType == "school") { + questionList = question2 + } else { + questionList = question } -} - -function canAnswer2() { - var q - for (q = 0; q < question2.length; q++) { + for (q = 0; q < questionList.length; q++) { items.repeater.itemAt(q).answerTextReadonly = false } } function cannotAnswer() { var r - for (r = 0; r < question.length; r++) { - items.repeater.itemAt(r).answerTextReadonly = true + var questionList + if (items.modeType == "school") { + questionList = question2 + } else { + questionList = question } -} - -function cannotAnswer2() { - var r - for (r = 0; r < question2.length; r++) { + for (r = 0; r < questionList.length; r++) { items.repeater.itemAt(r).answerTextReadonly = true } } function resetvalue() { var k - for (k = 0; k < question.length; k++) { - items.repeater.itemAt(k).answerText = "" - items.repeater.itemAt(k).questionImageOpacity = 0 - scoreCounter = 0 - items.score.visible = false + var questionList + if (items.modeType == "school") { + questionList = question2 + } else { + questionList = question } - scoreCounter = 0 - items.score.visible = false -} - -function resetvalue2() { - var k - for (k = 0; k < question2.length; k++) { + for (k = 0; k < questionList.length; k++) { items.repeater.itemAt(k).answerText = "" items.repeater.itemAt(k).questionImageOpacity = 0 scoreCounter = 0