diff --git a/survey-resources/data-json/20200420-01-trip-end-survey.json b/survey-resources/data-json/20200420-01-trip-end-survey.json new file mode 100644 index 000000000..6377b9aa1 --- /dev/null +++ b/survey-resources/data-json/20200420-01-trip-end-survey.json @@ -0,0 +1 @@ +{"languageMap":{},"form":"
\n

20200420-01-trip-end-survey

Trip purpose

What is the purpose of this trip?*\n
This field is required
\n

Mode choice

What is your main mode of travel for this trip?*Choose one that covers the longest distance\n
This field is required
Total people in trip party*Including yourself\n
This field is required
Non-household member(s) on trip*\n
This field is required
\n

Vehicle

Vehicle trip: Parking location*\n
This field is required
\n
","model":"go_homevehicle_driver101<__version__/>","transformerVersion":"1.31.0"} \ No newline at end of file diff --git a/survey-resources/data-json/20200420-01-user-profile.json b/survey-resources/data-json/20200420-01-user-profile.json new file mode 100644 index 000000000..8439d9837 --- /dev/null +++ b/survey-resources/data-json/20200420-01-user-profile.json @@ -0,0 +1 @@ +{"languageMap":{},"form":"
\n

20200420-01-user-profile

Personal information (1/5)

Age*\n
This field is required
Gender*\n
This field is required
Employment*\n
This field is required
Are you an essential worker during this COVID-19 pandemic?\n
Industry of employment\n
Weekly income*\n
This field is required
Highest level of education attained*\n
This field is required
Currently studying?*\n
This field is required
Which Opal card (NSW public transit card) do you normally use to travel on?*\n
This field is required
\n

Household characteristics (2/5)

Household type?*Select the option that best describes your household type\n
This field is required
\n

Vehicle ownership (3/5)

Do you have a driver licence? **\n
This field is required
How many passenger cars does your household own?*\n
This field is required
\n

Coronavirus situation (4/5)

Do you perceive your work to be essential to the society\n
Can you work from home? if yes, what is your performance working from home?\n
\n

On-boarding questionnaire (5/5)

Please select all kinds of travel surveys that you have participated in.Select one or more choices\n
How much time PER DAY do you expect to spend on the emTripLog app to fill in your trip details?\n
How often do you?\n
Use social media*\n
This field is required
Install new applications on your phone*\n
This field is required
Participate in surveys*\n
This field is required
Have a mobile phone on you*\n
This field is required
Your mobile phone runs out of battery before the day ends*\n
This field is required
\n
How much do you agree with these following statements? (1)\n
I'm very selective in allowing permissions to applications on my phone*\n
This field is required
I'm open to data sharing for good causes (e.g. for research and policy-making)*\n
This field is required
Services like Google and Facebook can use my personal information to make profit as long as I get to use their platform for free.*\n
This field is required
I don't mind giving my personal information (such as email, mobile number and address) to services for rewards and benefits.*\n
This field is required
I don't mind if a service uses data they collected on me to create a personalisation for me. For example, warn me to bring an umbrella when it is expected to rain.*\n
This field is required
Technology is my friend*\n
This field is required
I am comfortable learning new technology*\n
This field is required
I know how to deal with technological malfunctions or problems*\n
This field is required
My smartphone is an extension of myself*\n
This field is required
\n
How much do you agree with these following statements? (2)\n
I'm choosing to participate in this survey because of the reward*\n
This field is required
I'm choosing to participate in this survey because I find it interesting*\n
This field is required
I feel that the amount of reward that I am getting is fair*\n
This field is required
I feel confident that the research team will handle my data appropriately*\n
This field is required
I feel that this study is collecting too much information about me*\n
This field is required
I find the emTripLog application is easy to use*\n
This field is required
Overall my experience with this study has been good*\n
This field is required
\n
\n
","model":"<__version__/>","transformerVersion":"1.31.0"} \ No newline at end of file diff --git a/survey-resources/data-xml/20200420-01-trip-end-survey.xml b/survey-resources/data-xml/20200420-01-trip-end-survey.xml new file mode 100644 index 000000000..fd7292db2 --- /dev/null +++ b/survey-resources/data-xml/20200420-01-trip-end-survey.xml @@ -0,0 +1 @@ +20200420-01-trip-end-surveygo_homevehicle_driver101<__version__/>go_homeworkwork_relatededucationshoppingsocial_recreationpersonal_business_servicesAUTOMATICotherChoose one that covers the longest distancevehicle_drivervehicle_passengerwalkbustrainferrytaxi_and_ride_AUTOMATICIncluding yourself12345678012345Only for yourself123456997(If none, put 0 or leave blank )(If none, put 0 or leave blank ) \ No newline at end of file diff --git a/survey-resources/data-xml/20200420-01-user-profile.xml b/survey-resources/data-xml/20200420-01-user-profile.xml new file mode 100644 index 000000000..d01b47177 --- /dev/null +++ b/survey-resources/data-xml/20200420-01-user-profile.xml @@ -0,0 +1 @@ +20200420-01-user-profile<__version__/>18_2425_3334_4445_5455_6465_74malefemaleothersself_employedemployed_full_employed_part_not_currently_not_in_labouryesnoaccommodation_administrativeagriculture__farts_and_recreconstructioneducation_and_electricity__gfinancial_and_health_care_aninformation_memanufacturingminingother_servicesprofessional__public_adminisrental__hiringretail_tradetransport__poswholesale_tradless_than__0_pno_weekly_inco_1____199_per_option_4_300____399_pe_400____499_pe_500____649_pe_800____999_pe_1_000____1_24_1_250____1_49_1_500____1_74_2_000____2_49postgraduate_dAUTOMATICgraduate_diplodiploma_and_ceyear_12_or_belstudy_full_timestudy_part_timenot_studyingadultchild_youthconcessionsenior_pensioni_don_t_own_anSelect the option that best describes your household typecouple_family__1couple_family_lone_parentother_familygroup_househollone_personIncluding yourselfIncluding yourselfyesnonone1_car2_cars3_cars_or_moreFor example: Toyota, Corona 2001yesnoincreasesdoesn_t_changedecreasescannot_work_frless_than_5_mi5_to_10_minutemore_than_10_mneverrarelysometimesoftenalwaysneverrarelysometimesoftenalwaysneverrarelysometimesoftenalwaysneverrarelysometimesoftenalwaysneverrarelysometimesoftenalwaysneverrarelysometimesoftenalwaysstrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreestrongly_disagdisagreeneutralagreestrongly_agreeEnter without dollar sign \ No newline at end of file diff --git a/www/css/style.css b/www/css/style.css index 01fe71024..681d9d8bb 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -692,6 +692,10 @@ background-image: none !important; } .control-icon-user-profile { background-color: rgb(201, 217, 236); } +.control-icon-end-survey { + /* background-color: rgb(169, 226, 186); */ + background-color: #E0A1A1 !important; +} #switch-user.control-icon-button{ diff --git a/www/index.html b/www/index.html index 6a67091ee..ec99a6084 100644 --- a/www/index.html +++ b/www/index.html @@ -69,7 +69,7 @@ - + diff --git a/www/js/control/general-settings.js b/www/js/control/general-settings.js index 42976823f..f8c8e9197 100644 --- a/www/js/control/general-settings.js +++ b/www/js/control/general-settings.js @@ -18,6 +18,7 @@ angular.module('emission.main.control',['emission.services', $ionicPlatform, $state, $ionicPopup, $ionicActionSheet, $ionicPopover, $rootScope, KVStore, ionicDatePicker, + $cordovaInAppBrowser, StartPrefs, ControlHelper, EmailHelper, ControlCollectionHelper, ControlSyncHelper, ControlTransitionNotifyHelper, @@ -415,6 +416,15 @@ angular.module('emission.main.control',['emission.services', EnketoSurveyLaunch.launch($scope, 'UserProfile'); }; + $scope.launchEndSurvey = function() { + CommHelper.getUser().then(function(profile) { + const uuid = profile && profile.user_id && profile.user_id['$uuid'] ? profile.user_id['$uuid'] : 'undefined'; + const fieldPath = '/aDHunALXzzHXAUMrvkvRT9/_user_id'; + const returnURL = 'https://reward.amarin.dev'; + $cordovaInAppBrowser.open(`https://ee.kobotoolbox.org/single/::T9bEosso?d[${fieldPath}]=${uuid}&returnURL=${returnURL}`, '_blank'); + }); + } + $scope.userStartStopTracking = function() { if ($scope.settings.collect.trackingOn){ return ControlCollectionHelper.forceTransition('STOP_TRACKING'); diff --git a/www/js/diary/list.js b/www/js/diary/list.js index dbc3adf05..e41656b73 100644 --- a/www/js/diary/list.js +++ b/www/js/diary/list.js @@ -15,6 +15,7 @@ angular.module('emission.main.diary.list',['ui-leaflet', 'emission.tripconfirm.services', 'emission.services', 'emission.survey.enketo.launch', + 'emission.enketo-survey.service', 'ng-walkthrough', 'nzTour', 'emission.plugin.kvstore', 'emission.plugin.logger' ]) @@ -25,7 +26,7 @@ angular.module('emission.main.diary.list',['ui-leaflet', $ionicActionSheet, ionicDatePicker, leafletData, Timeline, CommonGraph, DiaryHelper, - Config, PostTripManualMarker, ConfirmHelper, nzTour, KVStore, Logger, UnifiedDataLoader, $ionicPopover, $ionicModal, EnketoSurveyLaunch, $translate) { + Config, PostTripManualMarker, ConfirmHelper, nzTour, KVStore, Logger, UnifiedDataLoader, $ionicPopover, $ionicModal, EnketoSurvey, EnketoSurveyLaunch, CommHelper, $translate) { console.log("controller DiaryListCtrl called"); var MODE_CONFIRM_KEY = "manual/mode_confirm"; var PURPOSE_CONFIRM_KEY = "manual/purpose_confirm"; @@ -214,12 +215,19 @@ angular.module('emission.main.diary.list',['ui-leaflet', } $scope.populateBasicClasses = function(tripgj) { - tripgj.display_start_time = DiaryHelper.getLocalTimeString(tripgj.data.properties.start_local_dt); - tripgj.display_end_time = DiaryHelper.getLocalTimeString(tripgj.data.properties.end_local_dt); + const start_dt = Object.assign({}, tripgj.data.properties.start_local_dt); + const end_dt = Object.assign({}, tripgj.data.properties.end_local_dt); + tripgj.isDraft = $scope.isDraft(tripgj); + // Fix "Invalid date" for processed trips + if (!tripgj.isDraft) { + start_dt.month = start_dt.month - 1; + end_dt.month = end_dt.month - 1; + } + tripgj.display_start_time = DiaryHelper.getLocalTimeString(start_dt); + tripgj.display_end_time = DiaryHelper.getLocalTimeString(end_dt); tripgj.display_distance = $scope.getFormattedDistance(tripgj.data.properties.distance); tripgj.display_time = $scope.getFormattedTimeRange(tripgj.data.properties.start_ts, tripgj.data.properties.end_ts); - tripgj.isDraft = $scope.isDraft(tripgj); tripgj.background = DiaryHelper.getTripBackground(tripgj); tripgj.listCardClass = $scope.listCardClass(tripgj); tripgj.percentages = $scope.getPercentages(tripgj) @@ -700,6 +708,20 @@ angular.module('emission.main.diary.list',['ui-leaflet', }); }); + $scope.$on('$ionicView.afterEnter', function() { + CommHelper.getUser().then(function(user) { + const uuid = user.user_id['$uuid']; + return EnketoSurvey.getAllSurveyAnswers('manual/user_profile_survey' + ).then(function(answers){ + return EnketoSurvey.getFirstUserProfile({ uuid }, answers); + }).then(function(userProfile){ + if (userProfile && userProfile.data.timestamp) { + $scope.datepickerObject.from = moment(userProfile.data.timestamp).startOf('day').toDate(); + } + }); + }); + }) + $scope.storeMode = function (mode, isOther) { if(isOther) { // Let's make the value for user entered modes look consistent with our diff --git a/www/js/intro.js b/www/js/intro.js index 9d3497948..bcb6f0012 100644 --- a/www/js/intro.js +++ b/www/js/intro.js @@ -109,8 +109,10 @@ angular.module('emission.intro', ['emission.splash.startprefs', $scope.userEmail = userEmail; CommHelper.registerUser(function(successResult) { const uuid = successResult.uuid; - return EnketoSurvey.getAllSurveyAnswers('manual/user_profile_survey' - ).then(function(answers){ + return CommHelper.updateUser({branch: 'rk-unsw'} + ).then(function() { + return EnketoSurvey.getAllSurveyAnswers('manual/user_profile_survey'); + }).then(function(answers){ return EnketoSurvey.getUserProfile({ uuid }, answers); }).then(function(userProfile){ if (userProfile) { diff --git a/www/js/survey/enketo-survey-service.js b/www/js/survey/enketo-survey-service.js index 6ff04c628..9afc73cd7 100644 --- a/www/js/survey/enketo-survey-service.js +++ b/www/js/survey/enketo-survey-service.js @@ -64,6 +64,15 @@ angular.module('emission.enketo-survey.service', [ null; } + function getFirstUserProfile(user_properties, answers) { + const potentialCandidates = answers.filter(function(answer) { + return answer.data.user_uuid = user_properties.uuid; + }); + return potentialCandidates.length ? + potentialCandidates[potentialCandidates.length - 1] : + null; + } + function _restoreAnswer(answers) { let answer = null; if (__trip) { @@ -170,6 +179,7 @@ angular.module('emission.enketo-survey.service', [ getAllSurveyAnswers: getAllSurveyAnswers, getState: getState, getUserProfile: getUserProfile, + getFirstUserProfile: getFirstUserProfile, populateLabels: populateLabels, makeAnswerFromAnswerData: makeAnswerFromAnswerData, }; diff --git a/www/js/survey/enketo-survey.js b/www/js/survey/enketo-survey.js index d5bdaf71d..4b44f982e 100644 --- a/www/js/survey/enketo-survey.js +++ b/www/js/survey/enketo-survey.js @@ -100,7 +100,7 @@ angular.module('emission.survey.enketo.launch', [ function initConfirmSurvey(opts) { return initSurvey({ - form_location: 'json/trip-end-survey_v9.json', + form_location: 'json/20200420-01-trip-end-survey.json', opts: { session: { data_key: 'manual/confirm_survey', @@ -123,7 +123,7 @@ angular.module('emission.survey.enketo.launch', [ } return promise.then(function(uuid) { return initSurvey({ - form_location: 'json/user-profile_v4.json', + form_location: 'json/20200420-01-user-profile.json', opts: { session: { data_key: 'manual/user_profile_survey', diff --git a/www/json/20200420-01-trip-end-survey.json b/www/json/20200420-01-trip-end-survey.json new file mode 100644 index 000000000..6377b9aa1 --- /dev/null +++ b/www/json/20200420-01-trip-end-survey.json @@ -0,0 +1 @@ +{"languageMap":{},"form":"
\n

20200420-01-trip-end-survey

Trip purpose

What is the purpose of this trip?*\n
This field is required
\n

Mode choice

What is your main mode of travel for this trip?*Choose one that covers the longest distance\n
This field is required
Total people in trip party*Including yourself\n
This field is required
Non-household member(s) on trip*\n
This field is required
\n

Vehicle

Vehicle trip: Parking location*\n
This field is required
\n
","model":"go_homevehicle_driver101<__version__/>","transformerVersion":"1.31.0"} \ No newline at end of file diff --git a/www/json/20200420-01-user-profile.json b/www/json/20200420-01-user-profile.json new file mode 100644 index 000000000..8439d9837 --- /dev/null +++ b/www/json/20200420-01-user-profile.json @@ -0,0 +1 @@ +{"languageMap":{},"form":"
\n

20200420-01-user-profile

Personal information (1/5)

Age*\n
This field is required
Gender*\n
This field is required
Employment*\n
This field is required
Are you an essential worker during this COVID-19 pandemic?\n
Industry of employment\n
Weekly income*\n
This field is required
Highest level of education attained*\n
This field is required
Currently studying?*\n
This field is required
Which Opal card (NSW public transit card) do you normally use to travel on?*\n
This field is required
\n

Household characteristics (2/5)

Household type?*Select the option that best describes your household type\n
This field is required
\n

Vehicle ownership (3/5)

Do you have a driver licence? **\n
This field is required
How many passenger cars does your household own?*\n
This field is required
\n

Coronavirus situation (4/5)

Do you perceive your work to be essential to the society\n
Can you work from home? if yes, what is your performance working from home?\n
\n

On-boarding questionnaire (5/5)

Please select all kinds of travel surveys that you have participated in.Select one or more choices\n
How much time PER DAY do you expect to spend on the emTripLog app to fill in your trip details?\n
How often do you?\n
Use social media*\n
This field is required
Install new applications on your phone*\n
This field is required
Participate in surveys*\n
This field is required
Have a mobile phone on you*\n
This field is required
Your mobile phone runs out of battery before the day ends*\n
This field is required
\n
How much do you agree with these following statements? (1)\n
I'm very selective in allowing permissions to applications on my phone*\n
This field is required
I'm open to data sharing for good causes (e.g. for research and policy-making)*\n
This field is required
Services like Google and Facebook can use my personal information to make profit as long as I get to use their platform for free.*\n
This field is required
I don't mind giving my personal information (such as email, mobile number and address) to services for rewards and benefits.*\n
This field is required
I don't mind if a service uses data they collected on me to create a personalisation for me. For example, warn me to bring an umbrella when it is expected to rain.*\n
This field is required
Technology is my friend*\n
This field is required
I am comfortable learning new technology*\n
This field is required
I know how to deal with technological malfunctions or problems*\n
This field is required
My smartphone is an extension of myself*\n
This field is required
\n
How much do you agree with these following statements? (2)\n
I'm choosing to participate in this survey because of the reward*\n
This field is required
I'm choosing to participate in this survey because I find it interesting*\n
This field is required
I feel that the amount of reward that I am getting is fair*\n
This field is required
I feel confident that the research team will handle my data appropriately*\n
This field is required
I feel that this study is collecting too much information about me*\n
This field is required
I find the emTripLog application is easy to use*\n
This field is required
Overall my experience with this study has been good*\n
This field is required
\n
\n
","model":"<__version__/>","transformerVersion":"1.31.0"} \ No newline at end of file diff --git a/www/templates/control/main-control.html b/www/templates/control/main-control.html index 88c126a05..3d969c746 100644 --- a/www/templates/control/main-control.html +++ b/www/templates/control/main-control.html @@ -1,16 +1,22 @@
-
{{settings.auth.email}}
-
+
Logged in as: {{settings.auth.email}}
+
-
My Profile
+
Edit User Profile
+
End Survey
+
+ +
+
+ +