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

New school info interstitial #20390

Merged
merged 15 commits into from
Feb 9, 2018
Merged

New school info interstitial #20390

merged 15 commits into from
Feb 9, 2018

Conversation

islemaster
Copy link
Contributor

@islemaster islemaster commented Feb 2, 2018

Replace the existing, HAML-and-jQuery School Info Interstitial with a React one that reuses the new SchoolInfoInputs component that has school autocomplete and other flow we want to replicate.

image

Guidance on this feature:

  • Spec for the old School Info Interstitial
  • Teacher should be able to save/dismiss the interstitial in any partially-complete state - no required fields.
  • Any previously entered info should be loaded the next time the teacher is shown the interstitial.
  • We should pop up this interstitial again every 7 days unless one of the following is true:
    • The teacher already filled out all the fields
    • They chose “Homeschool,” “After School”, "Organization" or “Other” for school type
    • Teacher chose a country that’s not “United States”
  • Metrics:
    • Interstitial seen
    • Clicked 'save' with metadata about whether enough info was filled out.
      • “enough info” is the same logic as when we decide to show the interstitial again vs. not
    • Clicked 'save' without "enough info"
    • Save failed on first attempt.
    • Save failed on second attempt.
    • On all of above, mark users who have a 'last seen date' of February 21st.
      • "So basically we cleared out the interstitial for a ton of people b/c we were storing their data incorrectly, so we moved their last seen date to Feb 21. Hence us trying to get this UI changed before then so that teachers didn’t see a dialog they finished filling out like a week after they filled it out and ideally the next time they did see it, it was a better UI."

TODO:

  • Track down "US" vs "United States" weirdness
  • Test code that manages when we re-display the interstitial Doing in a separate PR.
  • UI test for end-to-end coverage.
  • Metrics
  • Possibly deduplicate with work Drew's been doing elsewhere.
  • Check that partial input is also allowed on the sign-up page.
  • Localize text

New unit tests:

    SchoolInfoInterstitial
      ✔ renders an uncloseable dialog with school info inputs and a save button
      ✔ passes empty school info if created with no existing school info
      ✔ passes existing school info if it is provided
      initial NCES ID
        ✔ is the provided ID if it is provided
        ✔ is blank if country is not US
        ✔ is blank if school type is not public/private/charter
        ✔ is blank if none of school name/state/zip have been entered
        ✔ is "-1" if country is US and schoolType is public and school_name was provided
        ✔ is "-1" if country is US and schoolType is public and state was provided
        ✔ is "-1" if country is US and schoolType is public and zip was provided
        ✔ is "-1" if country is US and schoolType is private and school_name was provided
        ✔ is "-1" if country is US and schoolType is private and state was provided
        ✔ is "-1" if country is US and schoolType is private and zip was provided
        ✔ is "-1" if country is US and schoolType is charter and school_name was provided
        ✔ is "-1" if country is US and schoolType is charter and state was provided
        ✔ is "-1" if country is US and schoolType is charter and zip was provided
      form submission
        ✔ submits with no info
        ✔ submits with only a country
        ✔ submits with a country and a school type
        ✔ submits with a country, school type, and school id
        ✔ submits with a country, school type, and school name
        ✔ submits with a country, school type, name, state
        ✔ submits with a country, school type, name, state, zip
        ✔ closes the dialog on successful submission
        ✔ shows an error message on first failed submission
        ✔ closes the dialog on a second failed submission

@islemaster islemaster changed the title [WIP] New school info interstitial New school info interstitial Feb 8, 2018
>
<div style={styles.container}>
<div style={styles.heading}>
We want to bring Computer Science to every student - help us track our progress!
Copy link
Contributor

@ewjordan ewjordan Feb 8, 2018

Choose a reason for hiding this comment

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

Does this need to be localized? (Sim. other text)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks for the reminder. Added to the TODO list in the PR description.

const initialNcesSchoolId = existingSchoolInfo.school_id ?
existingSchoolInfo.school_id :
(
existingSchoolInfo.country === 'United States'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure that you also need to check existingSchoolInfo.country === 'US'
We seem to be inconsistent about how we specify the country in school_info. Sometimes it is set to a two-character country code and sometimes to the country name. The validation logic doesn't check this and the column is longer than two characters.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, it looks like you actually map 'US' to 'United States' in _school_info_interstitial.html.haml.
Perhaps add a comment here to call that out. Also, if we are doing that mapping in the haml then why not also do the mapping of school_id to "-1" there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point.

I added this code because I discovered a funny edge case for partial entry: We never send/save a school id of "-1" to the database, so there's nothing to differentiate a form submitted where there's been no interaction with the school autocomplete dropdown (school_id is null) and one where the user has checked "I can't find my school" but hasn't entered any details yet (school_id is "-1") - in essence, we don't serialize the state of that checkbox.

As much as possible, I'd like all the business logic around this component to live in one layer, and the checkbox state in particular seems like a UI concern so I think it should live with the React component. So I'm leaning toward moving the US/United States logic into the React component as well. Does that sound okay to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably easier to test that stuff in the React layer than in a HAML file, too.

// TODO (bbuchanan): Gather metrics on this.
this.props.onClose();
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this unknown error because we don't expect any validation to run on the submission?

Copy link
Contributor Author

@islemaster islemaster Feb 9, 2018

Choose a reason for hiding this comment

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

This is a a fallback in case of an unexpected error response on submission - likely caused by the service being temporarily unavailable, so we ask the teacher to try again at least once. Based on this handler in the Census Teacher Banner:

updateSchoolInfoError= () => {
// It isn't clear what could cause an error here since none of the fields are required.
this.setState({
showSchoolInfoUnknownError: true,
});
};

};

static defaultProps = {
onClose: function () {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it actually make sense to use this component without providing a meaningful onClose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only in a storybook/test context. I'll clear this out.

schoolZip={this.state.schoolZip}
schoolLocation={this.state.schoolLocation}
useGoogleLocationSearch={false}
showErrors={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the schoolLocation value even get used if useGoogleLocationSearch is false?

"user[school_info_attributes][school_state]": this.state.schoolState,
"user[school_info_attributes][school_zip]": this.state.schoolZip,
"user[school_info_attributes][full_address]": this.state.schoolLocation,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like this.state.schoolLocation ever gets updated from the original value. Since you aren't using the google location search this should probably get set to null here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually don't know whether we want the google location search or not - I'll check with Poorva. What's the potential harm in keeping this wired up, to minimize the work to enable it later?

Copy link
Contributor

Choose a reason for hiding this comment

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

In the case that the user entered new info, you will be keeping the old full_address resulting in a mashup of the old and new data. If they are submitting the form then the old data ought to be cleared out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh - the guidance I got was that this dialog should be like the school info on the signup page as much as possible, and that one uses Google Location search. So instead of removing this I'm going to enable that feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

Keep in mind the note here about including the google maps script.

@islemaster islemaster merged commit a387d55 into staging Feb 9, 2018
@islemaster islemaster deleted the school-info-interstitial branch February 9, 2018 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants