diff --git a/src/activities/calendar/ActivityInfo.qml b/src/activities/calendar/ActivityInfo.qml --- a/src/activities/calendar/ActivityInfo.qml +++ b/src/activities/calendar/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "math measures" createdInVersion: 9000 + levels: "1,2,3" } diff --git a/src/activities/calendar/CMakeLists.txt b/src/activities/calendar/CMakeLists.txt --- 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 --- a/src/activities/calendar/Calendar.qml +++ b/src/activities/calendar/Calendar.qml @@ -27,13 +27,17 @@ import "../../core" import "calendar.js" as Activity import "calendar_dataset.js" as Dataset +import "tutorial_instructions.js" as Instructions ActivityBase { id: activity property var dataset: Dataset onStart: focus = true onStop: {} + property var tutorialInstructions: Instructions.get() + property bool showTutorial: true + pageComponent: Image { id: background signal start @@ -43,6 +47,7 @@ sourceSize.width: Math.max(parent.width, parent.height) Component.onCompleted: { + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } @@ -57,15 +62,17 @@ 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 + property bool showTutorial: activity.showTutorial } - onStart: { Activity.start(items, dataset) } + onStart: { Activity.start(items) } onStop: { Activity.stop() } Keys.onPressed: (answerChoices.visible) ? answerChoices.handleKeys(event) : handleKeys(event); @@ -345,6 +352,7 @@ Rectangle { id: questionItemBackground + visible: !showTutorial color: "#373737" border.width: 2 border.color: "#f2f2f2" @@ -362,6 +370,7 @@ // Displays the question. GCText { id: questionItem + visible: !showTutorial anchors.fill: questionItemBackground anchors.bottom: questionItemBackground.bottom fontSizeMode: Text.Fit @@ -372,6 +381,33 @@ horizontalAlignment: Text.AlignHCenter } + //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() + } + } + } + } + } + // Tutorial section ends + // Answer Submission button. BarButton { id: okButton @@ -397,17 +433,39 @@ } } + DialogChooseLevel { + id: dialogActivityConfig + currentActivity: activity.activityInfo + + onSaveData: { + levelFolder = dialogActivityConfig.chosenLevel + currentActivity.currentLevel = dialogActivityConfig.chosenLevel + ApplicationSettings.setCurrentLevel(currentActivity.name, dialogActivityConfig.chosenLevel) + background.start() + home() + } + onClose: { + home() + } + onStartActivity: { + background.start() + } + } + DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar - content: BarEnumContent { value: help | home | level } + content: BarEnumContent { value: help | home | level | activityConfig } onHelpClicked: { displayDialog(dialogHelp) } + onActivityConfigClicked: { + displayDialog(dialogActivityConfig) + } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() @@ -420,6 +478,7 @@ Score { id: score + visible: !showTutorial height: okButton.height width: height anchors.top: calendarBox.bottom diff --git a/src/activities/calendar/calendar.js b/src/activities/calendar/calendar.js --- a/src/activities/calendar/calendar.js +++ b/src/activities/calendar/calendar.js @@ -40,11 +40,11 @@ var maxRange //sum of max. visible month and year on calendar for navigation bar next/prev button visibility. var correctAnswer var mode +var daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] -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) { @@ -59,7 +59,7 @@ function initLevel() { currentSubLevel = 1; items.bar.level = currentLevel + 1 - currentLevelConfig = dataset[currentLevel][0][0] + currentLevelConfig = items.levels[currentLevel] setCalendarConfigurations() initQuestion(); } @@ -92,20 +92,108 @@ 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 getDateInLongFormat(date) { + var months = [qsTr("January"), qsTr("February"), qsTr("March"), qsTr("April"), qsTr("May"), qsTr("June"), qsTr("July"), + qsTr("August"), qsTr("September"), qsTr("October"), qsTr("November"), qsTr("December")]; + return date.day.toString() + " " + months[date.month] + " " + date.year.toString() + "?"; +} + +function generateRandomYearMonthDay(minimumDate, maximumDate) { + 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 currentYear = minYear + Math.floor(Math.random() * Math.floor((maxYear - minYear + 1))) + var currentMonth = minMonth + Math.floor(Math.random() * Math.floor((maxMonth - minMonth + 1))) + var currentDate + daysInMonths[1] = (isLeapYear(currentYear)) ? 29 : 28; + currentDate = minDate + Math.floor(Math.random() * Math.floor((daysInMonths[currentMonth - 1] - minDate + 1))) + return { year: currentYear, month: currentMonth - 1, day: currentDate } +} + +function addOffsetToCurrentDate(currentDate) { + var maxOffset = currentLevelConfig.questionAnswers.maxOffset + var offset = Math.floor(maxOffset / 2) + Math.floor(Math.random() * Math.floor(maxOffset)) + daysInMonths[1] = (isLeapYear(currentDate.year)) ? 29 : 28; + var currentOffset = offset; + currentOffset += currentDate.day + var answerDate = 1; + var answerMonth = currentDate.month + var answerYear = currentDate.year + while(currentOffset > 0) { + if(currentOffset - daysInMonths[answerMonth] > 0) { + currentOffset -= daysInMonths[answerMonth] + answerMonth++; + } else { + answerDate = currentOffset; + currentOffset = 0 + } + if(answerMonth > 12) { + answerYear++; + daysInMonths[1] = (isLeapYear(answerYear)) ? 29 : 28; + answerMonth = 0; + } + } + return { year: answerYear, month: answerMonth, day: answerDate, offset: offset } +} + +function getTemplateQuestionText(mode, date) { + var questionText + if(mode == "findDayOfWeek") { + questionText = qsTr("What day of the week is on %1 ?").arg(date.day) + } else if(mode == "findDay") { + questionText = qsTr("Select day %1 ?").arg(date.day) + } else if(mode == "findMonthOnly") { + questionText = qsTr("Find month number %1").arg(date.month + 1) + } else { + if(date.offset) { + questionText = qsTr("Find the date %1 days after %2").arg(date.offset).arg(getDateInLongFormat(date)) + } else + questionText = qsTr("Find the date %1").arg(getDateInLongFormat(date)) + } + 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 if(currentLevelConfig.mode == "findYearMonthDay" && currentLevelConfig.questionAnswers.maxOffset) { + correctAnswer = addOffsetToCurrentDate(randomDate) + randomDate.offset = correctAnswer.offset + } 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"] + } } } @@ -134,8 +222,14 @@ 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 } diff --git a/src/activities/calendar/calendar_dataset.js b/src/activities/calendar/calendar_dataset.js --- a/src/activities/calendar/calendar_dataset.js +++ b/src/activities/calendar/calendar_dataset.js @@ -38,7 +38,8 @@ "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDay" + "mode": "findDay", + "questionsExplicitly": false } ], [ // Level 1 Questions @@ -78,7 +79,8 @@ "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDayOfWeek" + "mode": "findDayOfWeek", + "questionsExplicitly": false } ], [ // Level 2 Questions @@ -121,7 +123,8 @@ "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDay" + "mode": "findDay", + "questionsExplicitly": false } ], @@ -165,7 +168,8 @@ "maximumDate": "2018-03-31", "visibleMonth": 2, "visibleYear": 2018, - "mode": "findDay" + "mode": "findDay", + "questionsExplicitly": false } ], [ // Level 4 Questions @@ -200,7 +204,8 @@ "maximumDate": "2018-12-31", "visibleMonth": 1, "visibleYear": 2018, - "mode": "findMonthOnly" + "mode": "findMonthOnly", + "questionsExplicitly": false } ], [ // Level 5 Questions @@ -231,11 +236,13 @@ [ // 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, } ], @@ -287,7 +294,8 @@ "maximumDate": "2019-12-31", "visibleMonth": 1, "visibleYear": 2018, - "mode": "findYearMonthDay" + "mode": "findYearMonthDay", + "questionsExplicitly": true } ], [ // Level 7 Questions diff --git a/src/activities/calendar/resource/1/Data.qml b/src/activities/calendar/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/calendar/resource/1/Data.qml @@ -0,0 +1,223 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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" + +/* +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) +If questions are provided explicitly field questionAnswers contains an array of questions and answers and +if they are not provided, then questionAnswers field contains parameter length signifying the number of questions, and optional +parameter maxOffset for questions where the user has to find date some days ahead of the given date. +[ + //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. + ] +*/ + +Dataset { + objective: qsTr("Calendar Questions for a single month") + 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} + } + ] + } + ] +} diff --git a/src/activities/calendar/resource/2/Data.qml b/src/activities/calendar/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/calendar/resource/2/Data.qml @@ -0,0 +1,135 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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" + +/* +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) +If questions are provided explicitly field questionAnswers contains an array of questions and answers and +if they are not provided, then questionAnswers field contains parameter length signifying the number of questions, and optional +parameter maxOffset for questions where the user has to find date some days ahead of the given date. +[ + //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. + ] +*/ + +Dataset { + objective: qsTr("Calendar Questions involving 2 months") + difficulty: 2 + data: [ + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 30 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 2, + "visibleYear": 2018, + "mode": "findDayOfWeek", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("What day of week is 30 days after 10 March?"), + "answer": {"dayOfWeek": 1} + }, + { + "question": qsTr("What day of the week is 40 days after 15 July?"), + "answer": {"dayOfWeek": 5} + }, + { + "question": qsTr("What day of the week is 20 days after 1 June?"), + "answer": {"dayOfWeek": 5} + }, + { + "question": qsTr("What day of the week is 60 days after 10 April?"), + "answer": {"dayOfWeek": 6} + }, + { + "question": qsTr("What day of the week is 10 days after 15 December?"), + "answer": {"dayOfWeek": 2} + } + ] + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 60 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2017-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 1, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "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/3/Data.qml b/src/activities/calendar/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/calendar/resource/3/Data.qml @@ -0,0 +1,151 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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" + +/* +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) +If questions are provided explicitly field questionAnswers contains an array of questions and answers and +if they are not provided, then questionAnswers field contains parameter length signifying the number of questions, and optional +parameter maxOffset for questions where the user has to find date some days ahead of the given date. +[ + //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. + ] +*/ + +Dataset { + objective: qsTr("Calendar Questions involving several months") + difficulty: 2 + data: [ + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 1, + "visibleYear": 2018, + "mode": "findMonthOnly", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "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]} + } + ] + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 90 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 120 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "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} + } + ] + } + ] +} diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/calendar/resource/Tutorial1.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/calendar/resource/Tutorial1.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/calendar/resource/Tutorial1.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial1.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,11 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("January \t February \t March \t April \t May \t June \t July \t August \t September \t October \t November \t December.") } + diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/calendar/resource/Tutorial2.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/calendar/resource/Tutorial2.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/calendar/resource/Tutorial2.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial2.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,10 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("Sunday \t Monday \t Tuesday \t Wednesday \t Thusday \t Friday \t Saturday \t") } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/calendar/resource/Tutorial3.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/calendar/resource/Tutorial3.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/calendar/resource/Tutorial3.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial3.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,10 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("February has 29 days if the year is a leap year and 28 days if it is not.") } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/calendar/resource/Tutorial4.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/calendar/resource/Tutorial4.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/calendar/resource/Tutorial4.qml @@ -1,9 +1,10 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial4.qml + * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +20,10 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("If an year is divisible by 400 then it is a leap year.\nIf an year is divisible by 100 and not 400 then it is not a leap year.\nIf none of the above cases hold then only the years which are divisible by 4 are leap years.") } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/calendar/resource/Tutorial5.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/calendar/resource/Tutorial5.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/calendar/resource/Tutorial5.qml @@ -1,9 +1,10 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial5.qml + * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +20,13 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: "Select Leap year" + firstNumber: "2018" + secondNumber: "2016" + answer: 2016 } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/calendar/resource/Tutorial6.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/calendar/resource/Tutorial6.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/calendar/resource/Tutorial6.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial6.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,12 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset +import "../../../core" -Calendar { - dataset: Dataset +TutorialBase { + firstNumber: "111" + secondNumber: "108" } diff --git a/src/activities/calendar/resource/TutorialBase.qml b/src/activities/calendar/resource/TutorialBase.qml new file mode 100644 --- /dev/null +++ b/src/activities/calendar/resource/TutorialBase.qml @@ -0,0 +1,126 @@ +/* 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 questionText: question.text + property int answer + + GCText { + id: question + 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 + } + + AnswerButton { + id: firstNumber + visible: answer + 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: Number(textLabel) === tutorialRectangle.answer + onPressed: { + if(isCorrectAnswer) { + message.text = qsTr("Great") + message.visible = true + messageRectangle.visible = true + } + } + } + + AnswerButton { + id: secondNumber + textLabel: "" + visible: answer + 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: Number(textLabel) === tutorialRectangle.answer + onPressed: { + if(isCorrectAnswer) { + message.text = qsTr("Great") + 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/calendar/tutorial_instructions.js b/src/activities/calendar/tutorial_instructions.js new file mode 100644 --- /dev/null +++ b/src/activities/calendar/tutorial_instructions.js @@ -0,0 +1,51 @@ +/* GCompris - tutorial_instructions.js + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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 . + */ + +function get() { + return [ + { + "instruction": qsTr("This activity teaches how to use a calendar."), + "instructionQml": "" + }, + { + "instruction": qsTr("For every year there are 12 months namely,"), + "instructionQml": "qrc:/gcompris/src/activities/calendar/resource/Tutorial1.qml" + }, + + { + "instruction": qsTr("For every week there are 7 days namely,"), + "instructionQml" : "qrc:/gcompris/src/activities/calendar/resource/Tutorial2.qml" + }, + + { + "instruction": qsTr("The number of days in a month are fixed for every year, except for february."), + "instructionQml" : "qrc:/gcompris/src/activities/calendar/resource/Tutorial3.qml" + }, + { + "instruction": qsTr("Calculating Leap years."), + "instructionQml": "qrc:/gcompris/src/activities/calendar/resource/Tutorial4.qml" + }, + { + "instruction": qsTr("Select the leap year out of the two."), + "instructionQml": "qrc:/gcompris/src/activities/calendar/resource/Tutorial5.qml" + } + ] +} \ No newline at end of file diff --git a/src/activities/find_the_day/ActivityInfo.qml b/src/activities/find_the_day/ActivityInfo.qml --- a/src/activities/find_the_day/ActivityInfo.qml +++ b/src/activities/find_the_day/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "math measures" createdInVersion: 9000 + levels: "1,2,3" } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/find_the_day/FindTheDay.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/find_the_day/FindTheDay.qml @@ -22,8 +22,9 @@ import "../calendar" import "find_the_day_dataset.js" as Dataset +import "tutorial_instructions.js" as Instructions Calendar { dataset: Dataset - + tutorialInstructions: Instructions.get() } diff --git a/src/activities/find_the_day/resource/1/Data.qml b/src/activities/find_the_day/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/find_the_day/resource/1/Data.qml @@ -0,0 +1,129 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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" + +/* +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) +If questions are provided explicitly field questionAnswers contains an array of questions and answers and +if they are not provided, then questionAnswers field contains parameter length signifying the number of questions, and optional +parameter maxOffset for questions where the user has to find date some days ahead of the given date. +[ + //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. + ] +*/ + +Dataset { + objective: qsTr("Find the date less than one month away") + difficulty: 1 + data: [ + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-01-31", + "visibleMonth": 0, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-03-31", + "visibleMonth": 1, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 10 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-03-31", + "visibleMonth": 1, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 20 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 7, + "visibleYear": 2018, + "mode": "findDayOfWeek", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Find day of week 3 days after December 5."), + "answer": {"dayOfWeek": 6} + }, + { + "question": qsTr("Find day of week 12 days before November 12."), + "answer": {"dayOfWeek": 3} + }, + { + "question": qsTr("Find day of week 32 days after January 5."), + "answer": {"dayOfWeek": 2} + }, + { + "question": qsTr("Find day of week 5 days after February 23."), + "answer": {"dayOfWeek": 3} + }, + { + "question": qsTr("Find day of week 17 days before August 16."), + "answer": {"dayOfWeek": 1} + } + ] + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-05-31", + "visibleMonth": 1, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 30 + } + } + ] +} diff --git a/src/activities/find_the_day/resource/2/Data.qml b/src/activities/find_the_day/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/find_the_day/resource/2/Data.qml @@ -0,0 +1,129 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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" + +/* +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) +If questions are provided explicitly field questionAnswers contains an array of questions and answers and +if they are not provided, then questionAnswers field contains parameter length signifying the number of questions, and optional +parameter maxOffset for questions where the user has to find date some days ahead of the given date. +[ + //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. + ] +*/ + +Dataset { + objective: qsTr("Find the date less than two month away") + difficulty: 2 + data: [ + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-03-31", + "visibleMonth": 1, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 30 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 45 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 60 + } + }, + { + "navigationBarVisible": true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 7, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Find the date 2 weeks and 3 days after January 12."), + "answer": {"year": 2018, "month": 0, "day": 29} + }, + { + "question": qsTr("Find the date 3 weeks and 2 days after March 22."), + "answer": {"year": 2018, "month": 3, "day": 14} + }, + { + "question": qsTr("Find the date 5 weeks and 6 days after October 5."), + "answer": {"year": 2018, "month": 10, "day": 15} + }, + { + "question": qsTr("Find the date 1 week and 1 day before August 8."), + "answer": {"year": 2018, "month": 6, "day": 31} + }, + { + "question": qsTr("Find the date 2 weeks and 5 days before July 2."), + "answer": {"year": 2018, "month": 5, "day": 13} + } + ] + } + ] +} diff --git a/src/activities/find_the_day/resource/3/Data.qml b/src/activities/find_the_day/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/find_the_day/resource/3/Data.qml @@ -0,0 +1,147 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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" + +/* +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) +If questions are provided explicitly field questionAnswers contains an array of questions and answers and +if they are not provided, then questionAnswers field contains parameter length signifying the number of questions, and optional +parameter maxOffset for questions where the user has to find date some days ahead of the given date. +[ + //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. + ] +*/ + +Dataset { + objective: qsTr("Find the date several months away") + difficulty: 3 + data: [ + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 0, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 60 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2019-12-31", + "visibleMonth": 10, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": false, + "questionAnswers": { + "length": 5, + "maxOffset": 90 + } + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 7, + "visibleYear": 2018, + "mode": "findDayOfWeek", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Find day of week 5 months and 2 days after July 3."), + "answer": {"dayOfWeek": 3} + }, + { + "question": qsTr("Find day of week 2 months and 4 days after October 8."), + "answer": {"dayOfWeek": 3} + }, + { + "question": qsTr("Find day of week 1 month and 3 days before December 28."), + "answer": {"dayOfWeek": 0} + }, + { + "question": qsTr("Find day of week 8 months and 7 days after February 28."), + "answer": {"dayOfWeek": 0} + }, + { + "question": qsTr("Find day of week 3 months and 3 days before September 15."), + "answer": {"dayOfWeek": 2} + } + ] + }, + { + "navigationBarVisible" : true, + "minimumDate": "2018-01-01", + "maximumDate": "2018-12-31", + "visibleMonth": 7, + "visibleYear": 2018, + "mode": "findYearMonthDay", + "questionsExplicitlyGiven": true, + "questionAnswers": [ + { + "question": qsTr("Find the date 2 months, 1 week and 5 days after January 12."), + "answer": {"year": 2018, "month": 2, "day": 24} + }, + { + "question": qsTr("Find the date 3 months, 2 weeks and 1 day after August 23."), + "answer": {"year": 2018, "month": 11, "day": 8} + }, + { + "question": qsTr("Find the date 5 months, 3 weeks and 2 days after March 20."), + "answer": {"year": 2018, "month": 8, "day": 12} + }, + { + "question": qsTr("Find the date 1 month 1 week and 1 day before September 10."), + "answer": {"year": 2018, "month": 7, "day": 2} + }, + { + "question": qsTr("Find the date 2 months, 1 week and 8 days before April 7."), + "answer": {"year": 2018, "month": 0, "day": 23} + } + ] + } + ] +} diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/find_the_day/resource/Tutorial1.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/find_the_day/resource/Tutorial1.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/find_the_day/resource/Tutorial1.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial1.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,11 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("We add 5 to the current date, which gives us the new date 20, and since December has 31 days and the new date is less than that. So the answer will be 20 December 2018.") } + diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/find_the_day/resource/Tutorial2.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/find_the_day/resource/Tutorial2.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/find_the_day/resource/Tutorial2.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial2.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,10 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("Since July has 31 days, out of 20 the first 7 days will change the month from July to August. Now we have to add the remaining 20 - 7 = 14 days to 1 August 2018 which will make the final date equal to 14 August 2018") } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/find_the_day/resource/Tutorial3.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/find_the_day/resource/Tutorial3.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/find_the_day/resource/Tutorial3.qml @@ -1,9 +1,9 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial3.qml * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +19,13 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("Select the correct option") + firstNumber: "16" + secondNumber: "14" + answer: 16 } diff --git a/src/activities/find_the_day/FindTheDay.qml b/src/activities/find_the_day/resource/Tutorial4.qml copy from src/activities/find_the_day/FindTheDay.qml copy to src/activities/find_the_day/resource/Tutorial4.qml --- a/src/activities/find_the_day/FindTheDay.qml +++ b/src/activities/find_the_day/resource/Tutorial4.qml @@ -1,9 +1,10 @@ -/* GCompris - find_the_day.qml +/* GCompris - Tutorial4.qml + * - * Copyright (C) 2018 Amit Sagtani + * Copyright (C) 2019 Deepak Kumar * * Authors: - * Amit Sagtani + * 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 @@ -19,11 +20,13 @@ * along with this program; if not, see . */ import QtQuick 2.6 +import GCompris 1.0 -import "../calendar" -import "find_the_day_dataset.js" as Dataset - -Calendar { - dataset: Dataset +import "../../../core" +TutorialBase { + questionText: qsTr("Select the correct option") + firstNumber: "18" + secondNumber: "13" + answer: 13 } diff --git a/src/activities/find_the_day/resource/TutorialBase.qml b/src/activities/find_the_day/resource/TutorialBase.qml new file mode 100644 --- /dev/null +++ b/src/activities/find_the_day/resource/TutorialBase.qml @@ -0,0 +1,126 @@ +/* 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 questionText: question.text + property int answer + + GCText { + id: question + 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 + } + + AnswerButton { + id: firstNumber + visible: answer + 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: Number(textLabel) === tutorialRectangle.answer + onPressed: { + if(isCorrectAnswer) { + message.text = qsTr("Great") + message.visible = true + messageRectangle.visible = true + } + } + } + + AnswerButton { + id: secondNumber + textLabel: "" + visible: answer + 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: Number(textLabel) === tutorialRectangle.answer + onPressed: { + if(isCorrectAnswer) { + message.text = qsTr("Great") + 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/find_the_day/tutorial_instructions.js b/src/activities/find_the_day/tutorial_instructions.js new file mode 100644 --- /dev/null +++ b/src/activities/find_the_day/tutorial_instructions.js @@ -0,0 +1,45 @@ +/* GCompris - tutorial_instructions.js + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay 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 . + */ + +function get() { + return [ + { + "instruction": qsTr("This activity teaches students to find the exact date."), + "instructionQml": "" + }, + { + "instruction": qsTr("For example if today is 15 December 2019, find the date 5 days after today,"), + "instructionQml": "qrc:/gcompris/src/activities/find_the_day/resource/Tutorial1.qml" + }, + { + "instruction": qsTr("What will be the date 20 days after 25 July 2018"), + "instructionQml" : "qrc:/gcompris/src/activities/find_the_day/resource/Tutorial2.qml" + }, + { + "instruction": qsTr("What will be the date 5 days after 11 August 2018."), + "instructionQml" : "qrc:/gcompris/src/activities/find_the_day/resource/Tutorial3.qml" + }, + { + "instruction": qsTr("What will be the date 25 days after 18 April 2018."), + "instructionQml": "qrc:/gcompris/src/activities/find_the_day/resource/Tutorial4.qml" + } + ] +} \ No newline at end of file