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":"
","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":"","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_home
- work
- work_related
- education
- shopping
- social_recreation
- personal_business_services
- AUTOMATIC
- other
Choose one that covers the longest distance- vehicle_driver
- vehicle_passenger
- walk
- bus
- train
- ferry
- taxi_and_ride_
- AUTOMATIC
Including yourself- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 0
- 1
- 2
- 3
- 4
- 5
Only for yourself- 1
- 2
- 3
- 4
- 5
- 6
- 997
(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_24
- 25_33
- 34_44
- 45_54
- 55_64
- 65_74
- male
- female
- others
- self_employed
- employed_full_
- employed_part_
- not_currently_
- not_in_labour
- yes
- no
- accommodation_
- administrative
- agriculture__f
- arts_and_recre
- construction
- education_and_
- electricity__g
- financial_and_
- health_care_an
- information_me
- manufacturing
- mining
- other_services
- professional__
- public_adminis
- rental__hiring
- retail_trade
- transport__pos
- wholesale_trad
- less_than__0_p
- no_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_49
- postgraduate_d
- AUTOMATIC
- graduate_diplo
- diploma_and_ce
- year_12_or_bel
- study_full_time
- study_part_time
- not_studying
- adult
- child_youth
- concession
- senior_pension
- i_don_t_own_an
Select the option that best describes your household type- couple_family__1
- couple_family_
- lone_parent
- other_family
- group_househol
- lone_person
Including yourselfIncluding yourself- yes
- no
- none
- 1_car
- 2_cars
- 3_cars_or_more
For example: Toyota, Corona 2001- yes
- no
- increases
- doesn_t_change
- decreases
- cannot_work_fr
- less_than_5_mi
- 5_to_10_minute
- more_than_10_m
- never
- rarely
- sometimes
- often
- always
- never
- rarely
- sometimes
- often
- always
- never
- rarely
- sometimes
- often
- always
- never
- rarely
- sometimes
- often
- always
- never
- rarely
- sometimes
- often
- always
- never
- rarely
- sometimes
- often
- always
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
- strongly_disag
- disagree
- neutral
- agree
- strongly_agree
Enter 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":"","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":"","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
+
+