diff --git a/src/activities/solar_system/ActivityConfig.qml b/src/activities/solar_system/ActivityConfig.qml new file mode 100644 --- /dev/null +++ b/src/activities/solar_system/ActivityConfig.qml @@ -0,0 +1,65 @@ +/* GCompris - ActivityConfig.qml + * + * Copyright (C) 2020 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" + +Item { + id: activityConfiguration + property Item background + property alias modeBox: modeBox + width: if(background) background.width + property var availableModes: [ + { "text": qsTr("Learning Mode"), "value": "learning" }, + { "text": qsTr("Assessment Mode"), "value": "assessment" } + ] + Flow { + id: flow + spacing: 5 + width: parent.width + GCComboBox { + id: modeBox + model: availableModes + background: activityConfiguration.background + label: qsTr("Select your mode") + } + } + + property var dataToSave + + function setDefaultValues() { + if(dataToSave["mode"] === undefined) { + dataToSave["mode"] = "learning"; + modeBox.currentIndex = 0 + } + for(var i = 0 ; i < availableModes.length ; i++) { + if(availableModes[i].value === dataToSave["mode"]) { + modeBox.currentIndex = i; + break; + } + } + } + + function saveValues() { + var newMode = availableModes[modeBox.currentIndex].value; + dataToSave = {"mode": newMode}; + } +} diff --git a/src/activities/solar_system/SolarSystem.qml b/src/activities/solar_system/SolarSystem.qml --- a/src/activities/solar_system/SolarSystem.qml +++ b/src/activities/solar_system/SolarSystem.qml @@ -60,6 +60,7 @@ signal stop Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } @@ -74,7 +75,8 @@ property alias planetsModel: planetsModel property alias mainQuizScreen: mainQuizScreen property alias dialogActivityConfig: dialogActivityConfig - property bool assessmentMode: false + property string mode: "learning" + property bool assessmentMode: mode === "assessment" ? true : false property bool solarSystemVisible: true property bool quizScreenVisible: false property string temperatureHint @@ -84,7 +86,6 @@ } onStart: { - dialogActivityConfig.getInitialConfiguration() Activity.start(items) } @@ -102,9 +103,9 @@ } z: 10 - readonly property string commonInstruction: qsTr("Mode: %1

There are two modes in the activity which you can switch from the configuration window:
1. Normal mode - In this mode you can play and learn about the Solar System.
2. Assessment mode - In this mode you can test your knowledge about the Solar System.").arg(items.assessmentMode ? qsTr("Assessment") : qsTr("Normal")) + readonly property string commonInstruction: qsTr("Mode: %1

There are two modes in the activity which you can switch from the configuration window:
1. Learning mode - In this mode you can play and learn about the Solar System.
2. Assessment mode - In this mode you can test your knowledge about the Solar System.").arg(items.assessmentMode ? qsTr("Assessment") : qsTr("Learning")) - readonly property var normalModeInstructions: [ + readonly property var learningModeInstructions: [ commonInstruction, qsTr("Click on the Sun or any planet to reveal questions. Each question will have 4 options, out of which one is correct."), qsTr("After a planet is clicked, the Closeness meter at the bottom-right corner of the screen represents the degree of correctness of your selected answer. The least correct answer is represented by 1%. Try again until you reach a 100% closeness by following the closeness meter, or hint which indicates the correct answer.") @@ -117,7 +118,7 @@ qsTr("You should score above 90% to pass the assessment and become a Solar System expert!") ] - intro: items.assessmentMode ? assessmentModeInstructions : normalModeInstructions + intro: items.assessmentMode ? assessmentModeInstructions : learningModeInstructions onIntroChanged: index = 0 } @@ -304,55 +305,24 @@ onButton0Hit: solarSystemImageHint.visible = true } - DialogActivityConfig { + DialogChooseLevel { id: dialogActivityConfig - currentActivity: activity - content: Component { - Item { - width: dialogActivityConfig.width - height: dialogActivityConfig.height - - property alias assessmentModeBox: assessmentModeBox - property bool initialCheckStatus - - GCDialogCheckBox { - id: assessmentModeBox - width: dialogActivityConfig.width - text: qsTr("Assessment mode") - checked: items.assessmentMode - } + currentActivity: activity.activityInfo + onClose: { + if(items.assessmentMode) { + Activity.startAssessmentMode() + } + else { + Activity.showSolarModel() } + home(); } - onLoadData: { - if(dataToSave && dataToSave["assessmentMode"]) - items.assessmentMode = dataToSave["assessmentMode"] === "true" ? true : false - Activity.numberOfLevel = items.assessmentMode ? 1 : 2 - - } - - onSaveData: { - if(!dialogActivityConfig.configItem) { - return - } - dialogActivityConfig.configItem.initialCheckStatus = items.assessmentMode - if(dialogActivityConfig.configItem.assessmentModeBox.checked != items.assessmentMode) { - items.assessmentMode = !items.assessmentMode - dataToSave["assessmentMode"] = items.assessmentMode ? "true" : "false" + if(activityData && activityData["mode"]) { + items.mode = activityData["mode"]; Activity.numberOfLevel = items.assessmentMode ? 1 : 2 } } - - onClose: { - if(items.assessmentMode != dialogActivityConfig.configItem.initialCheckStatus) { - if(items.assessmentMode) - Activity.startAssessmentMode() - else { - Activity.showSolarModel() - } - } - home() - } } DialogHelp { @@ -369,11 +339,11 @@ items.hintProvided ? withoutConfigWithHint : withoutConfigWithoutHint - property BarEnumContent withConfig: BarEnumContent { value: help | home | config } + property BarEnumContent withConfig: BarEnumContent { value: help | home | activityConfig } property BarEnumContent withoutConfigWithHint: BarEnumContent { value: help | home | level | hint } property BarEnumContent withoutConfigWithoutHint: BarEnumContent { value: help | home | level } - property BarEnumContent withConfigWithRestart: BarEnumContent { value: help | home | config | reload } - property BarEnumContent withConfigWithHint: BarEnumContent { value: help | home | config | hint } + property BarEnumContent withConfigWithRestart: BarEnumContent { value: help | home | activityConfig | reload } + property BarEnumContent withConfigWithHint: BarEnumContent { value: help | home | activityConfig | hint } onHelpClicked: { displayDialog(dialogHelp) @@ -393,8 +363,7 @@ else displayDialog(hintDialog) } - onConfigClicked: { - dialogActivityConfig.active = true + onActivityConfigClicked: { displayDialog(dialogActivityConfig) } onReloadClicked: Activity.startAssessmentMode()