Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode/Purpose Confirm Survey #572

Closed
wants to merge 49 commits into from
Closed

Mode/Purpose Confirm Survey #572

wants to merge 49 commits into from

Conversation

atton16
Copy link
Contributor

@atton16 atton16 commented May 23, 2019

In this PR we are trying to implement:

  1. Survey display for Mode & Purpose confirmation
  2. Survey display with previous answer restoration (if any)
  3. Dynamic button label display based on previously answered survey on both Mode Button and Purpose Button

At this point, I am struggle at Point (2). It appears that somehow $window.cordova.plugins.BEMUserCache.getAllMessages complicate things up.

If you look at the code in the file js/survey/enketo-survey-services.js line 55-64 never get executes.

Here is the output:

[phonegap] [console.log] EnketoSurvey.init()
[phonegap] [console.log] try to restore answer
[phonegap] [console.log] DEBUG:Answers stored locally[{"trip_properties":{"end_ts":1437582214.517,"start_ts":1437578093.881},"data":"<trip-end-survey_v5 xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" id=\"trip-end-survey_v5\" version=\"veMfY6eZ2W9qoGhmfzJX8F\"><start>2019-05-23T17:19:43.089+07:00</start><end>2019-05-23T17:19:43.098+07:00</end><group_vs9ga59><trip_purpose_main>1</trip_purpose_main><trip_purpose_sub_category/></group_vs9ga59><group_ee9rk21><travel_mode_main>walk</travel_mode_main><travel_mode_sub_category/><Total_people_in_trip_party>1</Total_people_in_trip_party><Non_household_member_s_on_trip>0</Non_household_member_s_on_trip><Household_member_s_on_trip>1</Household_member_s_on_trip><group_bn3jd79><Vehicle_trip_with_2_Driver_or_passenger/><Vehicle_trip_Parking_location/><Parking_cost/></group_bn3jd79><Rail_payment_method/><Transit_fees_AUD/><Taxi_fees/></group_ee9rk21><__version__>vLX8oPb8xP2pLvxNBagygU</__version__><_version_>vwpCadzPYVsW9XEjxZzwnR</_version_><_version__001>vSuFDQ2DcmpRpKcRfSXReq</_version__001><_version__002>veMfY6eZ2W9qoGhmfzJX8F</_version__002><meta><instanceID>uuid:69bb39ae-6420-471a-afe0-3012e4de23c8</instanceID></meta></trip-end-survey_v5>"}]
[phonegap] [console.log] DEBUG:[object Object]
[phonegap] [console.log] DEBUG:[object Object]
[phonegap] [console.log] DEBUG:found
[phonegap] [console.log] DEBUG:false

At first the problem was worse, when the code was combined in the EnketoSurveyCtrl controller (now resides in the file js/survey/enketo-survey.js) the button in the corresponding template cannot call validateForm function. So my assumption is that $scope get lost in the process of executing $window.cordova.plugins.BEMUserCache.getAllMessages. Now that I have separate the controller and service, I am stuck with the same bizarre problem where some code gets lost and never fired up.

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

@shankari shankari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small suggestions based on the current state of the draft.
This does look super promising otherwise...

www/js/survey/enketo-survey-services.js Outdated Show resolved Hide resolved
www/js/survey/enketo-survey-services.js Outdated Show resolved Hide resolved
www/js/survey/enketo-survey.js Outdated Show resolved Hide resolved
@atton16
Copy link
Contributor Author

atton16 commented May 24, 2019

In this PR we are trying to implement:

  1. Survey display for Mode & Purpose confirmation
  2. Survey display with previous answer restoration (if any)
  3. Dynamic button label display based on previously answered survey on both Mode Button and Purpose Button

At this point, I am struggle at Point (2). It appears that somehow $window.cordova.plugins.BEMUserCache.getAllMessages complicate things up.

If you look at the code in the file js/survey/enketo-survey-services.js line 55-64 never get executes.

Here is the output:

[phonegap] [console.log] EnketoSurvey.init()
[phonegap] [console.log] try to restore answer
[phonegap] [console.log] DEBUG:Answers stored locally[{"trip_properties":{"end_ts":1437582214.517,"start_ts":1437578093.881},"data":"<trip-end-survey_v5 xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:odk=\"http://www.opendatakit.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" id=\"trip-end-survey_v5\" version=\"veMfY6eZ2W9qoGhmfzJX8F\"><start>2019-05-23T17:19:43.089+07:00</start><end>2019-05-23T17:19:43.098+07:00</end><group_vs9ga59><trip_purpose_main>1</trip_purpose_main><trip_purpose_sub_category/></group_vs9ga59><group_ee9rk21><travel_mode_main>walk</travel_mode_main><travel_mode_sub_category/><Total_people_in_trip_party>1</Total_people_in_trip_party><Non_household_member_s_on_trip>0</Non_household_member_s_on_trip><Household_member_s_on_trip>1</Household_member_s_on_trip><group_bn3jd79><Vehicle_trip_with_2_Driver_or_passenger/><Vehicle_trip_Parking_location/><Parking_cost/></group_bn3jd79><Rail_payment_method/><Transit_fees_AUD/><Taxi_fees/></group_ee9rk21><__version__>vLX8oPb8xP2pLvxNBagygU</__version__><_version_>vwpCadzPYVsW9XEjxZzwnR</_version_><_version__001>vSuFDQ2DcmpRpKcRfSXReq</_version__001><_version__002>veMfY6eZ2W9qoGhmfzJX8F</_version__002><meta><instanceID>uuid:69bb39ae-6420-471a-afe0-3012e4de23c8</instanceID></meta></trip-end-survey_v5>"}]
[phonegap] [console.log] DEBUG:[object Object]
[phonegap] [console.log] DEBUG:[object Object]
[phonegap] [console.log] DEBUG:found
[phonegap] [console.log] DEBUG:false

At first the problem was worse, when the code was combined in the EnketoSurveyCtrl controller (now resides in the file js/survey/enketo-survey.js) the button in the corresponding template cannot call validateForm function. So my assumption is that $scope get lost in the process of executing $window.cordova.plugins.BEMUserCache.getAllMessages. Now that I have separate the controller and service, I am stuck with the same bizarre problem where some code gets lost and never fired up.

Fixed over our recent Skype meetings.

Copy link
Contributor

@shankari shankari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atton16 great job. I see that you can already read and extract parts of the stored survey results - now you just need to put them into the $scope and display them in the UX. I have a couple of minor comments, all dealing with consistency with the rest of the framework.

Would be great if you could address them so that it is easier for it to take advantage of future improvements to the platform after you are done with this project...

<button id="validate-form" class="btn btn-primary" ng-click="validateForm()" style="width:200px; margin-left: calc(50% - 100px);">Validate</button>
<a href="#" class="btn btn-primary next-page disabled" style="width: 200px; margin-left: calc(50% - 100px)">Next</a>
<button id="validate-form" class="btn btn-primary" ng-click="validateForm()" style="width:200px; margin-left: calc(50% - 100px);">Save</button>
<a href="#survey-paper" class="btn btn-primary next-page disabled" style="width: 200px; margin-left: calc(50% - 100px)">Next</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat! I filed an issue with enekto-core for this (https://github.com/enketo/enketo-core/issues/626), and we've been going back and forth on a good solution. I proposed this as an alternative.

www/js/survey/enketo-survey-services.js Outdated Show resolved Hide resolved
www/js/survey/enketo-survey-services.js Outdated Show resolved Hide resolved
www/js/survey/enketo-survey-services.js Outdated Show resolved Hide resolved
@atton16 atton16 marked this pull request as ready for review May 25, 2019 15:00
@atton16
Copy link
Contributor Author

atton16 commented May 25, 2019

@shankari Can you please review this?

@shankari
Copy link
Contributor

@atton16 I hate to be pedantic about this, but would it be possible for you to be consistent with the coding conventions for the rest of the project?

I use 4 spaces for indentation, no spaces between function and the next (, " for strings and no space between string components.

Your editor is apparently set with 2 spaces for indentation and spaces between function and (.
But that is an arbitrary choice, and not one that is consistent with the rest of the code. Can you change your settings to match mine?

It is fairly common for open source projects to enforce formatting standards (e.g. https://stackoverflow.com/questions/4714648/enforce-coding-standards-in-all-files-of-a-project-at-build, exercism/cpp#274)

As you can see, reformatting messes up git blame and makes it harder to review.

There's probably something clever we can do with jslint (or rather, prettifier https://stackoverflow.com/a/53636796) to check for this, and to incorporate it into continuous integration, but I don't have time to work on it right now :(

@shankari
Copy link
Contributor

I should really put the formatting guidelines into a CONTRIBUTING guide for the future. @atton16 do you have thoughts on where best to put it? I already have a CONTRIBUTING document in e-mission-docs - should I put the guidelines in there, or have a specific one for each repository?

@atton16
Copy link
Contributor Author

atton16 commented May 25, 2019

I think best is to use linting tool, I normally use eslint for most of my project.

@atton16
Copy link
Contributor Author

atton16 commented May 25, 2019

Actually, I set spaces to 2 on purpose. It makes everything tight especially large project. So it is easier to read complex function as most of the time they are all in the same screen. But I am happy with any. Leave it to you to decide. I can setup lint for you to get it started.

@shankari
Copy link
Contributor

@atton16 thank you so much for setting up eslint and fixing all the bugs, but this makes the code even harder to review since the linting changes are overwhelming the real changes.

There are now 71 files that are changed, and I know that the changes related to mode/purpose confirm survey only affect 5-6 at the most.

Is it possible for you to generate a PR that has only the changes required for the mode/purpose confirmation, with no additional whitespace changes?

And then generate a second PR that is basically ONLY whitespace changes and bug fixes from the linting?

Or is that too hard to do now that everything is mixed in here?

@shankari
Copy link
Contributor

For example, you could cherry-pick your initial changes and revert the whitespace changes until only semantic changes are left.

@atton16
Copy link
Contributor Author

atton16 commented May 26, 2019

I think it is too late at this stage.

@shankari
Copy link
Contributor

when I put in my comment about the spacing, I was really hoping for a clean PR to review. At this point, I have no idea what is a real change and what is not, and git blame is all messed up.

@shankari
Copy link
Contributor

shankari commented May 26, 2019

did you try cherry picking only the first set of semantic changes and removing whitespace changes? How long did it take?

@atton16
Copy link
Contributor Author

atton16 commented May 26, 2019

The set of changes before eslint is this commit.

@shankari
Copy link
Contributor

that is the last commit, but you have a set, right? You can cherry-pick a set of commits https://git-scm.com/docs/git-cherry-pick

@shankari
Copy link
Contributor

shankari commented May 26, 2019

so something like

git checkout -b rk-unsw-clean
git cherry-pick rk-unsw..rk-unsw~20 

should work

@shankari
Copy link
Contributor

shankari commented Jun 10, 2019

superceded by enketo/enketo#302 enketo/enketo#297

@shankari shankari closed this Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants