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

Add activeWhen callback for small surveys and use for 9th/10th of August #815

Merged
merged 3 commits into from
Aug 1, 2016

Conversation

kalleth
Copy link
Contributor

@kalleth kalleth commented Jul 25, 2016

Trello card

Please review commit by commit.

Adding activeWhen callback

This allows surveys to take place only on certain pages, superseding the default survey.

Now the survey code has reached this level of complexity, let's provide some documentation on it (in doc/surveys.md) so people can read about what we support.

Remove survey that has now completed

ronseal

Add new small survey to run 9th/10th of August

See commit message for reasoning.

@kalleth kalleth changed the title Add activeWhen callback for small surveys [Do not merge] Add activeWhen callback for small surveys Jul 25, 2016
@kalleth kalleth force-pushed the add-activewhen-callback-for-smallsurveys branch 2 times, most recently from 99ceb4a to 9af2f57 Compare July 25, 2016 15:45
activeWhen: function() {
function breadcrumbMatches() {
var text = $('#global-breadcrumb').text() || "";
return (/Education and learning/.test(text) || /Schools and education/.test(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.

Im not wild about this mechanism of detecting "education content". I'm going to push back and see if the logic below in sectionMatches() will match enough to make this a worthwhile test.

OTOH, this specific callback is only temporary and will be removed in a couple of weeks after the test has run.

@kalleth kalleth force-pushed the add-activewhen-callback-for-smallsurveys branch 3 times, most recently from 0acd961 to 19f4e69 Compare August 1, 2016 11:14
function organisationMatches() {
var orgMatchingExpr = /<D6>|<D106>|<D109>|<EA243>|<EA86>|<EA242>|<EA541>/;
var metaText = $('meta[name="govuk:analytics:organisations"]').attr('content') || "";
return orgMatchingExpr.test(metaText);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will return false (and not error) when the meta tag is not present on the page.

@kalleth kalleth changed the title [Do not merge] Add activeWhen callback for small surveys Add activeWhen callback for small surveys and use for 9th/10th of August Aug 1, 2016
return orgMatchingExpr.test(metaText);
}

return (sectionMatches() || breadcrumbMatches() || organisationMatches());
Copy link
Contributor

Choose a reason for hiding this comment

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

Like the readability here

@neilvanbeinum
Copy link
Contributor

Well done for finding a path through the taxonomy detection. LGTM

kalleth added 2 commits August 1, 2016 14:21
This allows surveys to take place only on certain pages.

Now the survey code has reached this level of complexity, let's provide
some documentation on it (in `doc/surveys.md`) so people can read about
what we support.
@kalleth kalleth force-pushed the add-activewhen-callback-for-smallsurveys branch from 19f4e69 to 093d361 Compare August 1, 2016 13:21
The same content as the main survey, but shown 5x more frequently on
education content.

This survey is only active when:

  * The breadcrumb contains 'Education' OR 'Schools' OR 'Childcare',
    case insensitive.
  * The `govuk:section` metatag equals "education and learning" OR
    "childcare and parenting" -- i.e. the content is given this section
    in panopticon.
  * The `govuk:analytics:organisations` tag contains one of
    `<D6>|<D106>|<D109>|<EA243>|<EA86>|<EA242>|<EA541>`, meaning the
    organisation is DfE, Ofsted, Ofqual, STA, SFA, EFA, or NCTL.
@kalleth kalleth force-pushed the add-activewhen-callback-for-smallsurveys branch from 093d361 to de312ee Compare August 1, 2016 14:18
@kalleth
Copy link
Contributor Author

kalleth commented Aug 1, 2016

I've done some checks locally on static and this has passed PR review. Merging.

@kalleth kalleth merged commit e0ce6fe into master Aug 1, 2016
@kalleth kalleth deleted the add-activewhen-callback-for-smallsurveys branch August 1, 2016 14:24
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.

2 participants