diff --git a/src/activities/calendar/ActivityInfo.qml b/src/activities/calendar/ActivityInfo.qml index 44df7af7e..5b0d46033 100644 --- a/src/activities/calendar/ActivityInfo.qml +++ b/src/activities/calendar/ActivityInfo.qml @@ -1,40 +1,41 @@ /* GCompris - ActivityInfo.qml * * Copyright (C) 2017 Amit Sagtani * * 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 GCompris 1.0 ActivityInfo { name: "calendar/Calendar.qml" difficulty: 4 icon: "calendar/calendar.svg" author: "Amit Sagtani <asagtani06@gmail.com>" demo: true //: Activity title title: qsTr("Calendar") //: Help title description: qsTr("Read the instructions and select the correct date on the calendar") //intro: "Select the asked date on the calendar" //: Help goal goal: qsTr("Learn how to use a calendar") //: Help prerequisite prerequisite: qsTr("Concept of week, month and year") //: Help manual manual: qsTr("Read the instructions and select the correct date on the calendar.") credit: "" section: "math measures" createdInVersion: 9000 + levels: "1" } diff --git a/src/activities/calendar/CMakeLists.txt b/src/activities/calendar/CMakeLists.txt index c4d47026d..7a61a9c7d 100644 --- a/src/activities/calendar/CMakeLists.txt +++ b/src/activities/calendar/CMakeLists.txt @@ -1 +1 @@ -GCOMPRIS_ADD_RCC(activities/calendar *.qml *.svg *.js) +GCOMPRIS_ADD_RCC(activities/calendar *.qml *.svg *.js resource/* resource/*/*/*.qml) diff --git a/src/activities/calendar/Calendar.qml b/src/activities/calendar/Calendar.qml index 627bac502..280a463b7 100644 --- a/src/activities/calendar/Calendar.qml +++ b/src/activities/calendar/Calendar.qml @@ -1,434 +1,435 @@ /* GCompris - Calendar.qml * * Copyright (C) 2017 Amit Sagtani * * Authors: * Amit Sagtani * * 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 QtQuick.Controls 1.5 import QtQuick.Controls.Private 1.0 import QtQuick.Controls.Styles 1.4 import "../../core" import "calendar.js" as Activity import "calendar_dataset.js" as Dataset ActivityBase { id: activity property var dataset: Dataset onStart: focus = true onStop: {} pageComponent: Image { id: background signal start signal stop fillMode: Image.PreserveAspectCrop source: "qrc:/gcompris/src/activities/fifteen/resource/background.svg" sourceSize.width: Math.max(parent.width, parent.height) 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 calendar: calendar property alias okButton: okButton property alias questionItem: questionItem + property var levels: activity.datasetLoader.item.data property alias score: score property alias answerChoices: answerChoices property alias questionDelay: questionDelay property alias okButtonParticles: okButtonParticles property bool horizontalLayout: background.width >= background.height * 1.5 property alias daysOfTheWeekModel: daysOfTheWeekModel } - onStart: { Activity.start(items, dataset) } + onStart: { Activity.start(items) } onStop: { Activity.stop() } Keys.onPressed: (answerChoices.visible) ? answerChoices.handleKeys(event) : handleKeys(event); // Question time delay Timer { id: questionDelay repeat: false interval: 1600 onTriggered: { Activity.initQuestion() } onRunningChanged: okButtonMouseArea.enabled = !okButtonMouseArea.enabled } Rectangle { id: calendarBox width: items.horizontalLayout ? (answerChoices.visible ? parent.width * 0.75 : parent.width * 0.80) : (answerChoices.visible ? parent.width * 0.65 : parent.width * 0.85) height: items.horizontalLayout ? parent.height * 0.68 : parent.height - bar.height - questionItemBackground.height - okButton.height * 1.5 anchors.top: questionItem.bottom anchors.topMargin: 5 anchors.rightMargin: answerChoices.visible ? 100 : undefined anchors.horizontalCenterOffset: answerChoices.visible ? 80 : 0 anchors.horizontalCenter: parent.horizontalCenter color: "black" opacity: 0.3 } Calendar { id: calendar weekNumbersVisible: false width: calendarBox.width * 0.96 height: calendarBox.height * 0.96 anchors.centerIn: calendarBox frameVisible: true focus: !answerChoices.visible __locale: Qt.locale(ApplicationInfo.localeShort) style: CalendarStyle { navigationBar: Rectangle { height: calendar.height * 0.12 color: "#f2f2f2" BarButton { id: previousMonth height: parent.height * 0.8 width: previousMonth.height sourceSize.height: previousMonth.height sourceSize.width: previousMonth.width anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: parent.height * 0.1 source: "qrc:/gcompris/src/core/resource/scroll_down.svg" rotation: 90 visible: ((calendar.visibleYear + calendar.visibleMonth) > Activity.minRange) ? true : false onClicked: calendar.showPreviousMonth() } GCText { id: dateText text: styleData.title color: "#373737" horizontalAlignment: Text.AlignHCenter fontSizeMode: Text.Fit anchors.verticalCenter: parent.verticalCenter anchors.left: previousMonth.right anchors.leftMargin: 2 anchors.right: nextMonth.left anchors.rightMargin: 2 } BarButton { id: nextMonth height: previousMonth.height width: nextMonth.height sourceSize.height: nextMonth.height sourceSize.width: nextMonth.width anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: previousMonth.anchors.leftMargin source: "qrc:/gcompris/src/core/resource/scroll_down.svg" rotation: 270 visible: ((calendar.visibleYear + calendar.visibleMonth) < Activity.maxRange) ? true : false onClicked: calendar.showNextMonth() } } dayDelegate: Rectangle { anchors.fill: parent anchors.leftMargin: (!addExtraMargin || control.weekNumbersVisible) && styleData.index % CalendarUtils.daysInAWeek === 0 ? 0 : -1 anchors.rightMargin: !addExtraMargin && styleData.index % CalendarUtils.daysInAWeek === CalendarUtils.daysInAWeek - 1 ? 0 : -1 anchors.bottomMargin: !addExtraMargin && styleData.index >= CalendarUtils.daysInAWeek * (CalendarUtils.weeksOnACalendarMonth - 1) ? 0 : -1 anchors.topMargin: styleData.selected ? -1 : 0 color: styleData.date !== undefined && styleData.selected ? selectedDateColor : "#F2F2F2" border.color: "#cec4c4" radius: 5 property bool addExtraMargin: control.frameVisible && styleData.selected readonly property color sameMonthDateTextColor: "#373737" readonly property color selectedDateColor: "#3778d0" readonly property color selectedDateTextColor: "white" readonly property color differentMonthDateTextColor: "#bbb" readonly property color invalidDateColor: "#dddddd" Label { id: dayDelegateText text: styleData.date.getDate() anchors.centerIn: parent horizontalAlignment: Text.AlignRight font.family: GCSingletonFontLoader.fontLoader.name font.pixelSize: Math.min(parent.height/3, parent.width/3) color: { var theColor = invalidDateColor; if (styleData.valid) { // Date is within the valid range. theColor = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor; if (styleData.selected) theColor = selectedDateTextColor; } theColor; } } } dayOfWeekDelegate: Rectangle { color: "lightgray" implicitHeight: Math.round(TextSingleton.implicitHeight * 2.25) Label { text: control.__locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat) font.family: GCSingletonFontLoader.fontLoader.name fontSizeMode: Text.Fit minimumPixelSize: 1 font.pixelSize: items.horizontalLayout ? parent.height * 0.7 : parent.width * 0.2 color: "#373737" anchors.centerIn: parent } } } onVisibleMonthChanged: { Activity.monthSelected = visibleMonth Activity.daySelected = selectedDate.getDate() } onVisibleYearChanged: { Activity.yearSelected = visibleYear Activity.daySelected = selectedDate.getDate() } onClicked: { Activity.daySelected = selectedDate.getDate() } onSelectedDateChanged: { Activity.daySelected = selectedDate.getDate() } } function handleKeys(event) { if(event.key === Qt.Key_Space && okButtonMouseArea.enabled) { Activity.checkAnswer() event.accepted = true } if(event.key === Qt.Key_Enter && okButtonMouseArea.enabled) { Activity.checkAnswer() event.accepted = true } if(event.key === Qt.Key_Return && okButtonMouseArea.enabled) { Activity.checkAnswer() event.accepted = true } if(event.key === Qt.Key_Home) { calendar.__selectFirstDayOfMonth(); event.accepted = true; } if(event.key === Qt.Key_End) { calendar.__selectLastDayOfMonth(); event.accepted = true; } if(event.key === Qt.Key_PageUp) { calendar.__selectPreviousMonth(); event.accepted = true; } if(event.key === Qt.Key_PageDown) { calendar.__selectNextMonth(); event.accepted = true; } if(event.key === Qt.Key_Left) { calendar.__selectPreviousDay(); event.accepted = true; } if(event.key === Qt.Key_Up) { calendar.__selectPreviousWeek(); event.accepted = true; } if(event.key === Qt.Key_Down) { calendar.__selectNextWeek(); event.accepted = true; } if(event.key === Qt.Key_Right) { calendar.__selectNextDay(); event.accepted = true; } } ListModel { id: daysOfTheWeekModel ListElement { text: qsTr("Sunday"); dayIndex: 0 } ListElement { text: qsTr("Monday"); dayIndex: 1 } ListElement { text: qsTr("Tuesday"); dayIndex: 2 } ListElement { text: qsTr("Wednesday"); dayIndex: 3 } ListElement { text: qsTr("Thursday"); dayIndex: 4 } ListElement { text: qsTr("Friday"); dayIndex: 5 } ListElement { text: qsTr("Saturday"); dayIndex: 6 } } // Creates a table consisting of days of weeks. GridView { id: answerChoices model: daysOfTheWeekModel anchors.top: calendarBox.top anchors.left: questionItem.left anchors.topMargin: 5 interactive: false property bool keyNavigation: false width: calendarBox.x - anchors.rightMargin height: (calendar.height / 6.5) * 7 cellWidth: calendar.width * 0.5 cellHeight: calendar.height / 6.5 keyNavigationWraps: true anchors.rightMargin: 10 * ApplicationInfo.ratio delegate: ChoiceTable { width: answerChoices.width height: answerChoices.height / 7 choices.text: text anchors.rightMargin: 2 } Keys.enabled: answerChoices.visible function handleKeys(event) { if(event.key === Qt.Key_Down) { keyNavigation = true answerChoices.moveCurrentIndexDown() } if(event.key === Qt.Key_Up) { keyNavigation = true answerChoices.moveCurrentIndexUp() } if(event.key === Qt.Key_Enter && !questionDelay.running) { keyNavigation = true Activity.dayOfWeekSelected = model.get(currentIndex).dayIndex answerChoices.currentItem.select() } if(event.key === Qt.Key_Space && !questionDelay.running) { keyNavigation = true Activity.dayOfWeekSelected = model.get(currentIndex).dayIndex answerChoices.currentItem.select() } if(event.key === Qt.Key_Return && !questionDelay.running) { keyNavigation = true Activity.dayOfWeekSelected = model.get(currentIndex).dayIndex answerChoices.currentItem.select() } } highlight: Rectangle { width: parent.width * 1.2 height: parent.height / 7 anchors.horizontalCenter: parent.horizontalCenter color: "#e99e33" border.width: 2 border.color: "#f2f2f2" radius: 5 visible: answerChoices.keyNavigation y: answerChoices.currentItem.y Behavior on y { SpringAnimation { spring: 3 damping: 0.2 } } } highlightFollowsCurrentItem: false focus: answerChoices.visible } Rectangle { id: questionItemBackground color: "#373737" border.width: 2 border.color: "#f2f2f2" radius: 10 opacity: 0.85 z: 10 anchors { horizontalCenter: parent.horizontalCenter bottomMargin: 10 } width: parent.width - 20 height: parent.height * 0.1 } // Displays the question. GCText { id: questionItem anchors.fill: questionItemBackground anchors.bottom: questionItemBackground.bottom fontSizeMode: Text.Fit wrapMode: Text.Wrap z: 10 color: "white" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } // Answer Submission button. BarButton { id: okButton source: "qrc:/gcompris/src/core/resource/bar_ok.svg" height: bar.height * 0.8 width: okButton.height sourceSize.width: okButton.width sourceSize.height: okButton.height z: 10 anchors.top: calendarBox.bottom anchors.right: calendarBox.right anchors.margins: items.horizontalLayout ? 30 : 6 ParticleSystemStarLoader { id: okButtonParticles clip: false } MouseArea { id: okButtonMouseArea anchors.fill: parent onClicked: { Activity.checkAnswer() } } } DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | level } onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } Score { id: score height: okButton.height width: height anchors.top: calendarBox.bottom anchors.bottom: undefined anchors.left: undefined anchors.right: answerChoices.visible ? calendarBox.right : okButton.left anchors.margins: items.horizontalLayout ? 30 : 8 } } } diff --git a/src/activities/calendar/calendar.js b/src/activities/calendar/calendar.js index edef10d82..f7055aca4 100644 --- a/src/activities/calendar/calendar.js +++ b/src/activities/calendar/calendar.js @@ -1,145 +1,226 @@ /* GCompris - calendar.js * * Copyright (C) 2017 Amit Sagtani * * Authors: * Amit Sagtani * * 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.6 as Quick .import QtQml 2.2 as Qml .import GCompris 1.0 as GCompris //for ApplicationInfo .import "qrc:/gcompris/src/core/core.js" as Core var currentLevel = 0 var numberOfLevel var currentSubLevel = 1 var currentDataSet var currentLevelConfig var dataset var items var daySelected = 1 var monthSelected = 2 var yearSelected = 2018 var dayOfWeekSelected var minRange //sum of min. visible month and year on calendar for navigation bar next/prev button visibility. var maxRange //sum of max. visible month and year on calendar for navigation bar next/prev button visibility. var correctAnswer var mode -function start(items_, dataset_) { +function start(items_) { items = items_ - dataset = dataset_.get() - numberOfLevel = dataset.length + numberOfLevel = items.levels.length currentLevel = 0 if(Qt.locale(GCompris.ApplicationSettings.locale).firstDayOfWeek == Qml.Locale.Monday) { items.daysOfTheWeekModel.move(0, items.daysOfTheWeekModel.count - 1, 1) } initLevel(); } function stop() { } function initLevel() { currentSubLevel = 1; items.bar.level = currentLevel + 1 - currentLevelConfig = dataset[currentLevel][0][0] + currentLevelConfig = items.levels[currentLevel] setCalendarConfigurations() initQuestion(); } function nextLevel() { if(numberOfLevel <= ++currentLevel) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); } // Configure calendar properties for every level. function setCalendarConfigurations() { minRange = Number(currentLevelConfig["minimumDate"].slice(5,7)) + Number(currentLevelConfig["minimumDate"].slice(0,4)) - 1; maxRange = Number(currentLevelConfig["maximumDate"].slice(5,7)) + Number(currentLevelConfig["maximumDate"].slice(0,4)) - 1; mode = currentLevelConfig["mode"] items.calendar.navigationBarVisible = currentLevelConfig["navigationBarVisible"] items.calendar.minimumDate = currentLevelConfig["minimumDate"] items.calendar.maximumDate = currentLevelConfig["maximumDate"] items.calendar.visibleYear = currentLevelConfig["visibleYear"] yearSelected = currentLevelConfig["visibleYear"] items.calendar.visibleMonth = currentLevelConfig["visibleMonth"] monthSelected = currentLevelConfig["visibleMonth"] items.answerChoices.visible = (mode === "findDayOfWeek") ? true : false items.okButton.visible = !items.answerChoices.visible - currentDataSet = dataset[currentLevel][1] + currentDataSet = currentLevelConfig["questionAnswers"] currentDataSet = Core.shuffle(currentDataSet) items.score.numberOfSubLevels = currentDataSet.length items.score.currentSubLevel = currentSubLevel } +function isLeapYear(year) { + if(year % 100 == 0 && year % 400 != 0) { + return false + } else if(year % 4 == 0) { + return true + } else { + return false + } +} + +function generateRandomYearMonthDay(minimumDate, maximumDate) { + var daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + var minYear = Number(minimumDate.slice(0, 4)) + var maxYear = Number(maximumDate.slice(0, 4)) + var minMonth = Number(minimumDate.slice(5, 7)) + var maxMonth = Number(maximumDate.slice(5, 7)) + var minDate = Number(minimumDate.slice(8, 10)) + var maxDate = Number(maximumDate.slice(8, 10)) + var currentYear = minYear + Math.floor(Math.random() * Math.floor((maxYear - minYear))) + var currentMonth = minMonth + Math.floor(Math.random() * Math.floor((maxMonth - minMonth))) + var currentDate + daysInMonths[1] = (isLeapYear(currentYear)) ? 29 : 28; + currentDate = minDate + Math.floor(Math.random() * Math.floor((daysInMonths[currentMonth - 1] - minMonth))) + var maxOffset = (maxDate - minDate) + (maxMonth - minMonth) * 28 + (maxYear - minYear) * 365 + var offset = 1 + Math.floor(Math.random() * Math.floor(maxOffset)) + var currentOffset = offset; + currentOffset += currentDate + var answerDate = 1; + var answerMonth = currentMonth + var answerYear = currentYear + while(currentOffset > 0) { + if(currentOffset - daysInMonths[answerMonth - 1] > 0) { + currentOffset -= daysInMonths[answerMonth - 1] + answerMonth++; + } else { + answerDate = currentOffset; + currentOffset = 0 + } + if(answerMonth > 12) { + answerYear++; + answerMonth = 1; + } + } + + var question = "Find the date " + offset.toString() + "days after " + currentYear.toString() + "-" + + currentMonth.toString() + "-" + currentDate.toString(); + return { year: answerYear, month: answerMonth - 1, day: answerDate, offset: offset } +} + +function getTemplateQuestionText(mode, date) { + var questionText + if(mode == "findDayOfWeek") { + questionText = "Find the Week Day on " + date.day.toString() + } else if(mode == "findDay") { + questionText = "Select Day " + date.day.toString() + } else if(mode == "findMonthOnly") { + questionText = "Find the month" + date.month.toString() + } else { + "Find the date " + date.offset.toString() + "days after " + date.year.toString() + "-" + + date.month.toString() + "-" + date.day.toString(); + } + return questionText +} + function initQuestion() { if(currentDataSet.length < currentSubLevel) { items.bonus.good("lion") } else { - items.score.currentSubLevel = currentSubLevel - items.questionItem.text = currentDataSet[currentSubLevel-1]["question"] - correctAnswer = currentDataSet[currentSubLevel-1]["answer"] + if(!currentLevelConfig.questionsExplicitlyGiven) { + var randomDate = generateRandomYearMonthDay(currentLevelConfig.minimumDate, currentLevelConfig.maximumDate) + items.score.currentSubLevel = currentSubLevel + if(currentLevelConfig.mode == "findDayOfWeek") { + var selectedDate = new Date(randomDate.year, randomDate.month - 1, randomDate.day) + correctAnswer.dayOfWeek = Number(selectedDate.getDay()) + } else { + correctAnswer = randomDate + } + items.questionItem.text = getTemplateQuestionText(currentLevelConfig.mode, randomDate) + } else { + items.score.currentSubLevel = currentSubLevel + items.questionItem.text = currentDataSet[currentSubLevel-1]["question"] + correctAnswer = currentDataSet[currentSubLevel-1]["answer"] + } } } function updateScore(isCorrectAnswer) { if(isCorrectAnswer) { items.questionDelay.start() items.okButtonParticles.burst(20) items.score.playWinAnimation() currentSubLevel++; } else items.bonus.bad("lion") } function checkAnswer() { var isCorrectAnswer = false // For levels having questions based on day of week only. if(mode === "findDayOfWeek") { if(dayOfWeekSelected === correctAnswer["dayOfWeek"]) { isCorrectAnswer = true } } // For levels having question based on month only. else if(mode === "findMonthOnly") { if(correctAnswer["month"].indexOf(monthSelected) >= 0) { isCorrectAnswer = true } } + // For levels having question based on day only. + else if(mode === "findDay") { + if(daySelected === correctAnswer["day"]) { + isCorrectAnswer = true + } + } // For levels having questions based on dayOfWeek, month and year. - else if(mode !== "findDayOfWeek") { + else { if(monthSelected === correctAnswer["month"] && daySelected === correctAnswer["day"] && yearSelected === correctAnswer["year"]) { isCorrectAnswer = true } } updateScore(isCorrectAnswer) } diff --git a/src/activities/calendar/calendar_dataset.js b/src/activities/calendar/calendar_dataset.js index 309108779..6e8aeee7c 100644 --- a/src/activities/calendar/calendar_dataset.js +++ b/src/activities/calendar/calendar_dataset.js @@ -1,317 +1,325 @@ /* GCompris - calendar_dataset.js * * Copyright (C) 2017 Amit Sagtani * * 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 . */ // Contains the questions, answers and calendar configurations of every level. // Add more levels by inserting questions and answers below. // Days of weeks are indexed from 0 i.e (Sunday = 0, Monday = 1, Tuesday = 2, .... ..... .... , Saturday = 6) // Months of year are indexed from 0 i.e (January = 0, February = 1, March = 2, .... ..... ...., December = 11) //[ //MODES // findMonthOnly --> For questions based on finding month only. // findYearMonthDay --> For questions based on finding year, month and day. // findDayOfWeek --> For questions based on finding day of week only. // findDay --> For questions based on finding day of a given month and year. // ] function get() { return [ [ // Level 1 [ // Level 1 Configurations { "navigationBarVisible" : false, "minimumDate": "2018-03-01", "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDay" + "mode": "findDay", + "questionsExplicitly": false } ], [ // Level 1 Questions { "question": qsTr("Select day 23"), "answer": {"year": 2018, "month": 2, "day": 23} }, { "question": qsTr("Select day 1"), "answer": {"year": 2018, "month": 2, "day": 1} }, { "question": qsTr("Select day 16"), "answer": {"year": 2018, "month": 2, "day": 16} }, { "question": qsTr("Select day 28"), "answer": {"year": 2018, "month": 2, "day": 28} }, { "question": qsTr("Select day 11"), "answer": {"year": 2018, "month": 2, "day": 11} }, { "question": qsTr("Select day 20"), "answer": {"year": 2018, "month": 2, "day": 20} } ] ], [ // Level 2 [ // Level 2 Configurations { "navigationBarVisible" : false, "minimumDate": "2018-03-01", "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDayOfWeek" + "mode": "findDayOfWeek", + "questionsExplicitly": false } ], [ // Level 2 Questions { "question": qsTr("What day of week is the 4th of given month?"), "answer": {"dayOfWeek": 0} }, { "question": qsTr("What day of the week is the 12th of given month?"), "answer": {"dayOfWeek": 1} }, { "question": qsTr("What day of the week is the 20th of given month?"), "answer": {"dayOfWeek": 2} }, { "question": qsTr("What day of the week is the 28th of given month?"), "answer": {"dayOfWeek": 3} }, { "question": qsTr("What day of the week is the 22nd of given month?"), "answer": {"dayOfWeek": 4} }, { "question": qsTr("What day of the week is the 16th of given month?"), "answer": {"dayOfWeek": 5} }, { "question": qsTr("What day of the week is the 10th of given month?"), "answer": {"dayOfWeek": 6} } ] ], [ // Level 3 [ // Level 3 configurations { "navigationBarVisible": false, "minimumDate": "2018-03-01", "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDay" + "mode": "findDay", + "questionsExplicitly": false } ], [ // Level 3 Questions { "question": qsTr("Select a Monday between days 1 and 7 of given month"), "answer": {"year": 2018, "month": 2, "day": 5} }, { "question": qsTr("Select a Tuesday between days 8 and 16 of given month"), "answer": {"year": 2018, "month": 2, "day": 13} }, { "question": qsTr("Select a Wednesday between days 15 and 22 of given month"), "answer": {"year": 2018, "month": 2, "day": 21} }, { "question": qsTr("Select a Thursday between days 26 and 31 of given month"), "answer": {"year": 2018, "month": 2, "day": 29} }, { "question": qsTr("Select a Friday between days 20 and 25 of given month"), "answer": {"year": 2018, "month": 2, "day": 23} }, { "question": qsTr("Select a Saturday between days 13 and 23 of given month"), "answer": {"year": 2018, "month": 2, "day": 17} }, { "question": qsTr("Select a Sunday between days 5 and 17 of given month"), "answer": {"year": 2018, "month": 2, "day": 11} } ] ], [ // level 4 [ // Level 4 Configurations { "navigationBarVisible" : false, "minimumDate": "2018-03-01", "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDay" + "mode": "findDay", + "questionsExplicitly": false } ], [ // Level 4 Questions { "question": qsTr("Select second day before the 15th of given month"), "answer": {"year": 2018, "month": 2, "day": 13} }, { "question": qsTr("Select fourth Sunday of given month"), "answer": {"year": 2018, "month": 2, "day": 25} }, { "question": qsTr("Select day one week after 13th of given month"), "answer": {"year": 2018, "month": 2, "day": 20} }, { "question": qsTr("Select fifth Thursday of given month"), "answer": {"year": 2018, "month": 2, "day": 29} }, { "question": qsTr("Select third day after 27th of given month"), "answer": {"year": 2018, "month": 2, "day": 30} } ] ], [ // Level 5 [ // Level 5 Configurations { "navigationBarVisible" : true, "minimumDate": "2018-01-01", "maximumDate": "2018-12-31", "visibleMonth": 1, "visibleYear": 2018, - "mode": "findMonthOnly" + "mode": "findMonthOnly", + "questionsExplicitly": false } ], [ // Level 5 Questions { "question": qsTr("Find the month starting a Thursday and having 28 days"), "answer": {"month": [1]} }, { "question": qsTr("Find a month starting a Monday and having 31 days"), "answer": {"month": [0, 9]} }, { "question": qsTr("Find the month between June and August"), "answer": {"month": [6]} }, { "question": qsTr("Find a month starting a Saturday"), "answer": {"month": [8, 11]} }, { "question": qsTr("Find a month having 30 days"), "answer": {"month": [3, 5, 8, 10]} } ] ], [ // level 6 [ // Level 6 Configurations { "navigationBarVisible" : true, - "minimumDate": "2017-01-01", - "maximumDate": "2019-12-31", - "visibleMonth": 2, + "minimumDate": "2018-09-01", + "maximumDate": "2019-01-31", + "visibleMonth": 10, "visibleYear": 2018, - "mode": "findYearMonthDay" + "mode": "findYearMonthDay", + "questionsExplicitly": true, + "maxOffset": 30, } ], [ // Level 6 Questions { "question": qsTr("Find the first Monday of January month of year 2019"), "answer": {"year": 2019, "month": 0, "day": 7} }, { "question": qsTr("Find the second Wednesday of February month of year 2019"), "answer": {"year": 2019, "month": 1, "day": 13} }, { "question": qsTr("Find the third Friday of March month of year 2019"), "answer": {"year": 2019, "month": 2, "day": 15} }, { "question": qsTr("Find the fifth Sunday of April month of year 2018"), "answer": {"year": 2018, "month": 3, "day": 29} }, { "question": qsTr("Find the fourth Tuesday of July month of year 2018"), "answer": {"year": 2018, "month": 6, "day": 24} }, { "question": qsTr("Find the first Monday of August month of year 2018"), "answer": {"year": 2018, "month": 7, "day": 6} }, { "question": qsTr("Find the third Thursday of September month of year 2017"), "answer": {"year": 2017, "month": 8, "day": 21} }, { "question": qsTr("Find the fifth Sunday of October month of year 2017"), "answer": {"year": 2017, "month": 9, "day": 29} }, { "question": qsTr("Find the second Friday of December month of year 2017"), "answer": {"year": 2017, "month": 11, "day": 8} } ] ], [ // Level 7 [ // Level 7 Configurations { "navigationBarVisible" : true, "minimumDate": "2017-01-01", "maximumDate": "2019-12-31", "visibleMonth": 1, "visibleYear": 2018, - "mode": "findYearMonthDay" + "mode": "findYearMonthDay", + "questionsExplicitly": true } ], [ // Level 7 Questions { "question": qsTr("Human Rights Day is celebrated five days after December 5.
Find the date of Human Rights Day in 2017."), "answer": {"year": 2017, "month": 11, "day": 10} }, { "question": qsTr("Braille Day is celebrated one day before January 5.
Find the date of Braille Day in 2018"), "answer": {"year": 2018, "month": 0, "day": 4} }, { "question": qsTr("Mark's birthday is on November 4. In 2017 his party was exactly two weeks later.
Find the date of his party in 2017"), "answer": {"year": 2017, "month": 10, "day": 18} }, { "question": qsTr("International Women's Day is celebrated two days before March 10.
Find the date of International Women's Day in 2018."), "answer": {"year": 2018, "month": 2, "day": 8} }, { "question": qsTr("Sports competition was held on last Friday of September 2017.
Select the date of sports competition on the calendar."), "answer": {"year": 2017, "month": 8, "day": 29} } ] ] ] } diff --git a/src/activities/calendar/resource/1/Data.qml b/src/activities/calendar/resource/1/Data.qml new file mode 100644 index 000000000..600b4bb96 --- /dev/null +++ b/src/activities/calendar/resource/1/Data.qml @@ -0,0 +1,206 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2018 Johnny Jazeix + * + * Authors: + * Johnny Jazeix + * + * 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" + +Dataset { + objective: qsTr("Calendar Questions for a single mohth") + difficulty: 1 + data: [ + { + "navigationBarVisible" : false, + "minimumDate": "2018-03-01", + "maximumDate": "2018-03-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5 + } + }, + { + "navigationBarVisible" : false, + "minimumDate": "2018-03-01", + "maximumDate": "2018-03-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Select day 23"), + "answer": {"year": 2018, "month": 2, "day": 23} + }, + { + "question": qsTr("Select day 1"), + "answer": {"year": 2018, "month": 2, "day": 1} + }, + { + "question": qsTr("Select day 16"), + "answer": {"year": 2018, "month": 2, "day": 16} + }, + { + "question": qsTr("Select day 28"), + "answer": {"year": 2018, "month": 2, "day": 28} + }, + { + "question": qsTr("Select day 11"), + "answer": {"year": 2018, "month": 2, "day": 11} + }, + { + "question": qsTr("Select day 20"), + "answer": {"year": 2018, "month": 2, "day": 20} + } + ] + }, + { + "navigationBarVisible" : false, + "minimumDate": "2018-03-01", + "maximumDate": "2018-03-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDayOfWeek", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 7 + } + }, + { + "navigationBarVisible" : false, + "minimumDate": "2018-03-01", + "maximumDate": "2018-03-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDayOfWeek", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("What day of week is the 4th of given month?"), + "answer": {"dayOfWeek": 0} + }, + { + "question": qsTr("What day of the week is the 12th of given month?"), + "answer": {"dayOfWeek": 1} + }, + { + "question": qsTr("What day of the week is the 20th of given month?"), + "answer": {"dayOfWeek": 2} + }, + { + "question": qsTr("What day of the week is the 28th of given month?"), + "answer": {"dayOfWeek": 3} + }, + { + "question": qsTr("What day of the week is the 22nd of given month?"), + "answer": {"dayOfWeek": 4} + }, + { + "question": qsTr("What day of the week is the 16th of given month?"), + "answer": {"dayOfWeek": 5} + }, + { + "question": qsTr("What day of the week is the 10th of given month?"), + "answer": {"dayOfWeek": 6} + } + ] + }, + { + "navigationBarVisible": false, + "minimumDate": "2018-03-01", + "maximumDate": "2018-03-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Select a Monday between days 1 and 7 of given month"), + "answer": {"year": 2018, "month": 2, "day": 5} + }, + { + "question": qsTr("Select a Tuesday between days 8 and 16 of given month"), + "answer": {"year": 2018, "month": 2, "day": 13} + }, + { + "question": qsTr("Select a Wednesday between days 15 and 22 of given month"), + "answer": {"year": 2018, "month": 2, "day": 21} + }, + { + "question": qsTr("Select a Thursday between days 26 and 31 of given month"), + "answer": {"year": 2018, "month": 2, "day": 29} + }, + { + "question": qsTr("Select a Friday between days 20 and 25 of given month"), + "answer": {"year": 2018, "month": 2, "day": 23} + }, + { + "question": qsTr("Select a Saturday between days 13 and 23 of given month"), + "answer": {"year": 2018, "month": 2, "day": 17} + }, + { + "question": qsTr("Select a Sunday between days 5 and 17 of given month"), + "answer": {"year": 2018, "month": 2, "day": 11} + } + ] + }, + { + "navigationBarVisible" : false, + "minimumDate": "2018-03-01", + "maximumDate": "2018-03-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Select a Monday between days 1 and 7 of given month"), + "answer": {"year": 2018, "month": 2, "day": 5} + }, + { + "question": qsTr("Select a Tuesday between days 8 and 16 of given month"), + "answer": {"year": 2018, "month": 2, "day": 13} + }, + { + "question": qsTr("Select a Wednesday between days 15 and 22 of given month"), + "answer": {"year": 2018, "month": 2, "day": 21} + }, + { + "question": qsTr("Select a Thursday between days 26 and 31 of given month"), + "answer": {"year": 2018, "month": 2, "day": 29} + }, + { + "question": qsTr("Select a Friday between days 20 and 25 of given month"), + "answer": {"year": 2018, "month": 2, "day": 23} + }, + { + "question": qsTr("Select a Saturday between days 13 and 23 of given month"), + "answer": {"year": 2018, "month": 2, "day": 17} + }, + { + "question": qsTr("Select a Sunday between days 5 and 17 of given month"), + "answer": {"year": 2018, "month": 2, "day": 11} + } + ] + } + ] +}