-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
99ceb4a
to
9af2f57
Compare
activeWhen: function() { | ||
function breadcrumbMatches() { | ||
var text = $('#global-breadcrumb').text() || ""; | ||
return (/Education and learning/.test(text) || /Schools and education/.test(text)); |
There was a problem hiding this comment.
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.
0acd961
to
19f4e69
Compare
function organisationMatches() { | ||
var orgMatchingExpr = /<D6>|<D106>|<D109>|<EA243>|<EA86>|<EA242>|<EA541>/; | ||
var metaText = $('meta[name="govuk:analytics:organisations"]').attr('content') || ""; | ||
return orgMatchingExpr.test(metaText); |
There was a problem hiding this comment.
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.
return orgMatchingExpr.test(metaText); | ||
} | ||
|
||
return (sectionMatches() || breadcrumbMatches() || organisationMatches()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the readability here
Well done for finding a path through the taxonomy detection. LGTM |
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.
19f4e69
to
093d361
Compare
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.
093d361
to
de312ee
Compare
I've done some checks locally on static and this has passed PR review. Merging. |
Trello card
Please review commit by commit.
Adding
activeWhen
callbackThis 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.