Page MenuHomePhabricator

Support new "embedded" survey type
Closed, ResolvedPublic2 Estimated Story Points

Description

In the context of T253112: Create survey for TechWish prototype announcements on dewiki and metawiki, WMDE Technical Wishes decided that we want to run a survey but only display on a single page. We planned to mostly reuse the QuickSurveys visual design and response connection mechanisms. After experimenting with a single-file Javascript implementation, I realized that "upstreaming" and attempting to integrate our new feature directly into QuickSurveys would be the most effective use of resources.

Please consider our submitted patches for your codebase :-)

  • patch - Gracefully degrade when survey configuration is invalid. This allows for safe migration and potential rollback.
  • patch - Add a new survey type for embedding in a page

The basic idea is that, "embedded" surveys are only available on pages which include a matching embedding element. All other selection criteria remain the same. If selected for display--which will be the usual case, as we expect to run them at 100% for those pages--the survey will replace the embedding element.

Another new behavior is that we currently want to offer an arbitrarily long list of multi-select answers. I've implemented so that the embedded surveys will always have this format, but I can imagine that in future (unplanned) work we would want to abstract the survey format so that either format can be used with either the floating "internal" survey, or the positioned "embedded" survey type.

Screenshot:

image.png (619×744 px, 74 KB)

Event Timeline

Change 599809 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/QuickSurveys@master] Add a new survey type for embedding in a page

https://gerrit.wikimedia.org/r/599809

Change 602031 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/QuickSurveys@master] Split survey choice from rendering

https://gerrit.wikimedia.org/r/602031

Change 602032 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/QuickSurveys@master] Support multiple embedded surveys

https://gerrit.wikimedia.org/r/602032

Jdlrobson subscribed.

I think this is a duplicate or overlaps in some way with T213696

I think this is a duplicate or overlaps in some way with T213696

Thanks, I hadn't seen it until now! I wish I'd followed a normal process here rather than jumping in prototype-first, but my initial plan wasn't to integrate, I sort of fell into this... Anyway, now that I'm doing so I think our "embedded" survey fits very well with a title filter.

What I'd like to do next is to split apart the features I've added, so that each piece is more reusable. Specifically,

  • embedSelector survey configuration, which causes the survey to appear at a specific location in the page. If the embedding element is missing, treat the survey as disabled.
  • Multiple embedded surveys can be present on a single page.
  • A new answer format with multiple-select checkboxes.

In addition, I'll add the pageId filter to the audience structure, and will attach that code to T213696. Please correct me if I should use wgPageName or "Wikidata Q ID" instead, but I don't see a consensus for how to implement in the other task, only a statement from @Isaac that Research would prefer page ID.

only a statement from @Isaac that Research would prefer page ID.

I don't always stand by things I said a year ago, but in this case, yeah, I would still advocate strongly for using page ID as the preferred identifier for articles. Because QuickSurveys is language-specific, I see no value to using QID and it would add an additional place where things could go wrong (e.g., Wikidata item changes). Titles aren't stable enough as page moves would break the survey logic (pretty common in breaking news topics) and introduce all the standard issues with getting the right normalization, special characters, etc. I think the main challenge with page IDs was that Special pages do not have unique page IDs so could not be sampled under that approach.

Change 602373 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/QuickSurveys@master] [WIP] Configuration to filter by page ID

https://gerrit.wikimedia.org/r/602373

I think the main challenge with page IDs was that Special pages do not have unique page IDs so could not be sampled under that approach.

Thank you for the confirmation! Acknowledged--fortunately, we can't show QuickSurveys on Special pages anyway. So I'd suggest we start with page ID, then find a way to tackle the various issues around Special pages in separate work. From my naive perspective, whatever we do at that point won't run into much of a migration / breaking change obstacle, since surveys are centrally administered and short-lived, hopefully my understanding is correct?

Yeh the downside of page id was it doesn't work with special pages - T213696#4949123 we could circumvent that by having an additional configuration option for those or maybe even supporting both. You have all the information so I would advise addressing your use case as best as possible :)

+1 to moving forward with page IDs and addressing the Special pages when the need actually arises. It's exciting to see this functionality be added and I will pass back the information to my team!

Yeh the downside of page id was it doesn't work with special pages - T213696#4949123 we could circumvent that by having an additional configuration option for those or maybe even supporting both. You have all the information so I would advise addressing your use case as best as possible :)

Thanks, I can imagine use cases for surveying on Special pages, but there are no open tasks about this so it can probably wait until the distant future. Special pages have the translation alias issue anyway, so targeting these will require something fancy like matching against wgCanonicalSpecialPageName. Similarly, I don't think regular article title-matching will end well unless we can take namespace aliasing into account and convert to a wgCanonicalNamespace. Baby steps!

awight triaged this task as Medium priority.Jun 10 2020, 8:45 AM
awight added a project: WMDE-TechWish.

We've decided that an embedding element selector might be an attractive nuisance and prone to misuse, so changing to an embedElementId which must use ID matching. A namespace is also recommended.

Change 599809 merged by jenkins-bot:
[mediawiki/extensions/QuickSurveys@master] Add a new survey configuration for embedding in a page

https://gerrit.wikimedia.org/r/599809

Change 602373 merged by jenkins-bot:
[mediawiki/extensions/QuickSurveys@master] Configuration to filter by page ID

https://gerrit.wikimedia.org/r/602373

Change 602031 merged by jenkins-bot:
[mediawiki/extensions/QuickSurveys@master] Split survey choice from rendering

https://gerrit.wikimedia.org/r/602031

@Lena_WMDE @ecohen
Ersatz development decision: embedded and randomized surveys should never be displayed on the same page. Pinging you because I said I would allow this but then became convinced to do it the other way...

Change 604732 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/QuickSurveys@master] Fix field reference

https://gerrit.wikimedia.org/r/604732

I support this decision. I don't think they should be shown other surveys - I think it's asking too much of users and we'd like to prioritize the embedded survey (and I think anyone else in the future using this tool would also)

Change 604732 merged by jenkins-bot:
[mediawiki/extensions/QuickSurveys@master] Fix field reference

https://gerrit.wikimedia.org/r/604732

Change 602032 merged by jenkins-bot:
[mediawiki/extensions/QuickSurveys@master] Support multiple embedded surveys

https://gerrit.wikimedia.org/r/602032

Change 605155 had a related patch set uploaded (by Awight; owner: Awight):
[operations/mediawiki-config@master] [beta] Enable a test survey to exercise new features

https://gerrit.wikimedia.org/r/605155

Change 605155 merged by jenkins-bot:
[operations/mediawiki-config@master] [beta] Enable a test survey to exercise new features

https://gerrit.wikimedia.org/r/605155

Lena_WMDE moved this task from Demo to Done on the WMDE-QWERTY-Sprint-2020-06-10 board.