Page MenuHomePhabricator

SPIKE [38hrs] Display an info pop-up button next to the survey question
Closed, ResolvedPublic5 Estimated Story PointsSpike

Assigned To
Authored By
AAlhazwani-WMF
Oct 26 2021, 2:34 PM
Referenced Files
F34946770: image.png
Feb 9 2022, 4:39 PM
F34946772: image.png
Feb 9 2022, 4:39 PM
F34946768: image.png
Feb 9 2022, 4:39 PM
F34712966: image.png
Oct 27 2021, 2:10 PM
F34712037: image.png
Oct 26 2021, 2:34 PM
F34712038: image.png
Oct 26 2021, 2:34 PM
F34712035: image.png
Oct 26 2021, 2:34 PM

Description

Jobs to be done

When I see a survey on a wiki project I want to be able to understand if this survey is from the Foundation and why it is being shown So I can safely reply or dismiss it.

Background info

Right now a user has no context on how or why a survey is being displayed in their experience. This task wants to explore a possible solution to address this issue.

We are evaluating if we are able to work on this feature. If not we are going to fallback to T294363: Link to additional information and resources in the thank you message.

Design proposal

image.png (1×2 px, 1 MB)

Additional specs can be provided if we decide to follow up on this feature.

Technical information

In terms of implementation, we should avoid implementing our own popups, given WVUI doesn't have a popup component. We should probably try to integrate the OOUI popup or other existing popups in the Vue component to re-use it.

Testing and QA steps

  • TBD e.g. beta cluster

Original Acceptance Criteria

  • When a user clicks the info "i" button the popup dialog is displayed
  • When a user navigates with their keyboard/TAB navigation, she can focus the "i" button and press ENTER to open the popup dialog
  • When a user clicks on any of the links inside the popup dialog a new tab is open and the popup dialog is dismissed
  • When a user clicks the close "x" of the popup dialog the dialog is dismissed
  • When a user clicks outside of the popup dialog the dialog is dismissed

Questions for Spike

  • Is Option A the best for the user (as the info window obscures the questions)?
  • I am not sure about this as it seems to be a designer question. The ability to place window will be dependent on library script library used
  • See also https://phabricator.wikimedia.org/T294354#7671610
  • How do we signify the tooltip should be included (maybe a span class), and then also how to add the translation key (likely as a config value)?
  • Several options suggested. Mainly focused on backend and needing to update WikimediaMessages, en.json file. Feel like this should be determined by the developer, but the data for front end for the JavaScript to display data should follow what has happened in previous additions to QuickSurvey
  • How do we use OOUI.js when we aren't currently using it in QuickSurvey?
  • We are not sure, may be able to just add it after other JavaScript libraries, but this would need to be tested. We may need to rewrite the view layer, and perhaps some to make the buttons correct size.
    • Jason, Essex and Ellen discussed and believe that this is probably another spike, concerning what would need to happen to bring in OOUI.js and the ramifications on the code base

Analysis for Spike

IDProposalProsCons
AAdd an additional link to the meta page of the survey next to the link to the privacy statement.
image.png (285×197 px, 47 KB)
Easy implementation engineering-wise. Survey authors do not need to be concerned with how additional information may impact survey layout. Reduced QA required per survey, leading to more sustainable deployments. Additional info on meta will not need to go through the slow i18n deployment process with wikimediamessages and translatewiki. Please read https://phabricator.wikimedia.org/T300293Users need to leave the page to find out more. Smaller text at the bottom is usually identified as not so useful legal text. The working might also need to be more self explanatory: what am I going to find on this "meta page"?
BDisplay an info button next to the survey question
image.png (183×283 px, 43 KB)
Additional information is immediately accessible and contextual.Interaction might not be explicit even if the info button is an established design pattern. Implementation is more complex, eg. hover vs touch interaction with a small input area. Additional info embedded in popup will require additional QA for each survey to ensure that the message does not break survey layout or rendering. Additional info on meta must go through the slow i18n deployment process with wikimediamessages and translatewiki. Please read https://phabricator.wikimedia.org/T300293
CDisplay an info button next to the privacy
image.png (125×221 px, 24 KB)
Secondary information is provided as a secondary interaction.Interaction is less obvious as the info icon can feel like a simple signifier for the footer text. Additional info embedded in popup will require additional QA for each survey to ensure that the message does not break survey layout or rendering. Additional info on meta must go through the slow i18n deployment process with wikimediamessages and translatewiki. Please read https://phabricator.wikimedia.org/T300293

Assumptions Choice A

It is assumed that the string to display the display data will be of unknown length. There would be no limit on the amount of text in the display data due to look/feel issues.
It is assumed that the display data will be located on a stand alone page.
It is assumed that the display data will have translations prior to implementation.

Assumptions Choice B and C

It is assumed that the string to display the display data will be of limited length. The display text in examples B and C are approximately 245 characters long.

It is assumed that the string to display the display data header will be of limited length. The header text in examples B and C are approximately 20 characters long.

NOTE - If the data set (content or text) is to be larger, recommend that example A be followed.

Files which may be touched in code changes for options B and C:

extension.json 
includes/Hooks.php 
includes/Rest/SurveyMessagesHandler.php (NEW file from https://gerrit.wikimedia.org/r/c/mediawiki/extensions/QuickSurveys/+/745947)
resources/ext.quicksurveys.lib/lib.js 
resources/ext.quicksurveys.lib/vue/QuickSurvey.vue 
resources/ext.quicksurveys.lib/vue/render.js 
resources/ext.quicksurveys.lib/vue/utils.js 
tests/jest/render.test.js 
tests/phpunit/unit/Rest/SurveyMessagesHandlerTest.php ---- test file

Changes will most likely need to be made to the view
extensions/QuickSurveys/resources/ext.quicksurveys.lib/vue/QuickSurvey.vue
And perhaps additional css values

OOUI JavaScript library with B and C

If option B or C is used, AND it is decided to bring in the OOUI javascript library, then the library will need to be brought into the codebase. More information is located here:
https://www.mediawiki.org/wiki/Vue.js/OOUI_migration_guide?useskin=vector-2022
https://www.mediawiki.org/wiki/OOUI?useskin=vector-2022
Please note: There is a folder, located at resources/lib/ooui
The reader is encouraged to read resources/lib/ooui/README.md, in case the library must be installed.

Conclusion/Recommendations

If the data on meta is to be over a specific length, then option A would be the most appropriate selection. If the additional information needs to be updated on an ongoing basis, then option A would also be a good choice. Otherwise, B or C would be more inline with current web standards. Option C is basically the same as option B, with the exception of the Z index.

The OOUI library seems to be needed to be brought into the code base to accomplish the popup or tooltip - this library also includes all the css and images which would go with the code change.

How about JavaScript stand alone with B or C

From https://www.educba.com/javascript-tooltip/
Examples of JavaScript Tooltip
Below are some of the examples for tooltip in javascript:

Tooltip feature with toggle () function:
HTML Code:

<!DOCTYPE html>
<html lang="en">
<head>
<title>JS Example</title>
<link rel="stylesheet" href="ToolTip.css" >
</head>
<body>
<h2>ToolTip</h2>
<div class="class" onclick="getMyToolTipFunction()">Hey Click Me to Open ToolTip
<span class="displayText" id="displayText">Hi I am ToolTip</span>
</div>
<script src="script.js"></script>
</body>
</html>

CSS Code: 

body {
background: green;
text-align: center;
color: blue;
}
.class {
-webkit-user-select: none;
position: relative;
}
.displayText {
position: absolute;
bottom: -230%;
left: 50%;
margin-left: -80px;
width: 160px;
background-color: aqua;
color: #fff;
color: red;
text-align: center;
border-radius: 6px;
padding: 8px 0;
visibility: hidden;
}
.displayText::before {
content: "";
border-width: 5px;
border-style: solid;
top: -28%;
left: 45%;
border-color: transparent transparent yellow transparent;
position: absolute;
}
.show {
visibility: visible;
}

JavaScript Code:

function getMyToolTipFunction () {
var popup = document.getElementById("displayText");
popup.classList.toggle("show");
}

Event Timeline

We could do this by adding the link in the message for the privacy policy. We designate which message key to use in the 'privacyPolicy' value within config.

Hey @aminalhazwani who do you need review from in this task?

From the engineering standpoint all of them should be feasible.

For the pop-up I would reuse an OOUI popup if that is a thing rather than making a new one.

The first one where the link is in the footer text is the easiest since I believe it would not need any changes to the code base. That text and link are a message you configure when deploying the survey.

Hey @aminalhazwani who do you need review from in this task?

I was looking for general feedback on the proposals but know that you ask it was worth being more precise with my request, thank you for being proactive and sharing your input on engineering feasibility.

I did a second iteration on the proposals and I am going to summarize the pros and cons.

ProposalProsCons
Add an additional link to the meta page of the survey next to the link to the privacy statement
image.png (1×964 px, 686 KB)
Easy implementation engineering-wise.Users need to leave the page to find out more. Smaller text at the bottom is usually identified as not so useful legal text. The working might also need to be more self explanatory: what am I going to find on this "meta page"?
Display an info button next to the survey question
image.png (1×2 px, 1 MB)
Additional information is immediately accessible and contextual.Interaction might be not be explicit even if the info button is an established design pattern. Implementation is more complex, eg. hover vs touch interaction with a small input area.
Display an info button next to the privacy statement
image.png (778×1 px, 440 KB)
Secondary information is provided as a secondary interaction.Interaction is less obvious as the info icon can feel like a simple signifier for the footer text.

With all things consider I would lean for the second option, which is adding a second button next to the survey title/question. Is this feasible in the current scope @Madalina? If yes we could create a shared task with the GDI team for this additional texts.

Option A: I have a small concern around the "meta page". Will this be translated in multiple languages? If the users leave the page, is there a risk of them not taking the survey?
Option B: This looks like best option depending on the complexity of the implementation
Option C: Also concerned that users might not understand what to do with the info button

To answer your question @aminalhazwani, we should estimate/investigate how complex implementation of Option B might be from an engineering point of view.
Push come to shove, my instinct is to go for Option A with just the privacy statement and get some user feedback.

Thoughts/question on Option A: Do the links pop open a new window or link within the current window?

If it links within the current window, we could experience loss of respondents; However, if they return to the language-sitename they were originally on while the survey is still running it should reappear on whatever page they visit next (unless they opted out by clicking X, which is fine, or cleared their browser cookies between getting the survey, visiting the link, and returning to the site, but we can't control for that). If they choose to opt out after reading the meta page, then that is okay - we don't want someone responding who wouldn't have consented to respond if they were informed of the details of the survey.

The meta page will need to be translated; GDI will send it for community translation as soon as the text is complete and we figure out which languages we're baseline/piloting with.

My tendency would be to try and include the meta page if we can, as that's where we'll get user feedback through the Talk page, specifically if someone does not want to answer the survey but does want to comment on it, and have information about what we mean by unsafe/uncomfortable. The privacy page is required but is usually a legal form that does not provide much detail (see example: https://foundation.wikimedia.org/wiki/Legal:Performance_Perception_Survey_Privacy_Statement)

Madalina triaged this task as Medium priority.Nov 3 2021, 1:56 PM

Push come to shove, my instinct is to go for Option A with just the privacy statement and get some user feedback.

@Madalina I agree, let's go for option A for now.

Regarding your question on users potentially leaving the page, yes there's a risk of them not taking the survey. To answer also @TAndic's question the current link behavior lets user decide if they want to open a link in the same page or in a new tab (we don't force links to be open in a new tab with code via the target="_blank" attribute). So if they would simply click or tap the link it would open the destination in the same tab. If they ctrl/cmd+click, right click+open in a new tab/window, or long press to open in a new tab on mobile, then yes, the destination would be in a different tab.

I updated the description on T292416: Safety Perception Survey: in-product experience with QuickSurvey so that we can see the full user flow. If we all agree we could put this task back to the backlog and do a second evaluation after having collected some user feedback.

Thanks @aminalhazwani ! Agreed on my side.

@Madalina we can move this task back to the backlog, cheers!

AAlhazwani-WMF raised the priority of this task from Medium to Needs Triage.

We had a couple more conversations about this and it looks like option B might be doable. So let's go ahead with B.

Madalina renamed this task from Display or link to additional information about the survey to Display an info pop-up button next to the survey question.Nov 16 2021, 10:10 AM
Jhernandez lowered the priority of this task from High to Medium.Nov 29 2021, 4:11 PM
ERayfield renamed this task from Display an info pop-up button next to the survey question to SPIKE 8 hours box Display an info pop-up button next to the survey question.Dec 7 2021, 4:09 PM
jsn.sherman renamed this task from SPIKE 8 hours box Display an info pop-up button next to the survey question to SPIKE [8hrs] Display an info pop-up button next to the survey question.Dec 7 2021, 4:20 PM
jsn.sherman added a project: Spike.
Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptDec 7 2021, 4:20 PM

We are discussing this task in the engineering meeting. Some outstanding questions:

  • Whether Option A is the best for the user as the info window obscures the questions.
  • How we would signify the tooltip should be included (maybe a span class), and then also how to add the translation key (likely as a config value).
  • How to use OOUI.js when we aren't currently using it in QuickSurvey.

@Madalina mentioned that with option B we'd need translation for the meta page, and risk losing the uer.

What happens with the translation? Could use tooltip [do we have access to jquery ?] - Is there a generic default? The privacy page is required but is usually a legal form that does not provide much detail (see example: https://foundation.wikimedia.org/wiki/Legal:Performance_Perception_Survey_Privacy_Statement)
Is there a generic default for 'meta page' OR SHOULD THERE BE ONE?
Is this meta page optional or required for each quick survey?
maybe something like

name: 'meta-page-test-survey',
	answers: [
		{ key: 'yes', label: 'Yes' },
		{ key: 'maybe', label: 'maybe' },
                { key: 'no', label: 'no' }
	],
	thankYouMessage: 'thank you come again',
	shuffleAnswersDisplay: false,
	freeformTextLabel: 'something',
	instanceTokenParameterName: 'uniquetoken',
	question: 'Is this gonna work?',
	isMobileLayout: false,
	surveySessionToken: 'ss',
	pageviewToken: 'pv',
         // default is false -if false, go to default meta page if available 
        // OR is no qsMetaPageData, then show default - just depends                               
        qsMetaPageRequired: 'false', 
       // string containing display, not sure if html/css markup available
        qsMetaPageData: 'Now is the time for all good folk to come to the aid of their country'

With qsMetaPageRequired - that is probably overkill, but don't know how granular we need to be on this
qsMetaPageData would contain the meta page text

title and body text - nice if can use html tags...

cannot use html tags in string values of keys
qsMetaPageTitle: 'Meta Title' if bold title becomes <strong>30 days</strong>
qsMetaPageData: "Now is the time for <span style='color: red;'>all good folk</span>to come to the aid of their country"

Maggie Epps 10:11 AM
we might want to add a config value that, when true, adds this popup html,
re: qsMetaPageRequired: 'false',
Jason Sherman 10:11 AM
the other thing we could do is add additional optional strings and update the template to use it conditionally


extensions/QuickSurveys/includes/Survey.php -> add key for metaPageHead and metaPageBody saying that page present or not, parameter in __construct( add metaPageHead and metaPageBody with default of empty string), add $this->metaPageHead = qsmetaPageHead to construct title, and $this->metaPageBody for string containing message body
in Survey.getMessages()

	/**
	 * Gets the list of i18n message keys that the survey uses
	 *
	 * @return string[]
	 */
	public function getMessages(): array {
		$messages = [
			$this->question,
		];

		if ( !empty( $this->description ) ) {
			$messages[] = $this->description;
		}

		if ( !empty( $this->privacyPolicy ) ) {
			$messages[] = $this->privacyPolicy;
		}

               // new section
               if ( !empty( $this->metaPageHead ) ) {
			$messages[] = $this->metaPageHead ;
		}

                if ( !empty( $this->metaPageBody ) ) {
			$messages[] = $this->metaPageBody ;
		}
		return $messages;
	}

extensions/QuickSurveys/includes/Survey.php

remember - add metaPageHead and metaPageBody to class, or maybe no:

	/**
	 * @var string|null header or title to meta page
	 */
	private $metaPageHead ;

	/**
	 * @var string|null string containing body of metaPage text
	 */
	private $metaPageBody ;

extensions/QuickSurveys/includes/Survey.php

public function toArray(): array {
	return [
		'audience' => $this->audience->toArray(),
		'name' => $this->name,
		'question' => $this->question,
		'description' => $this->description,
		'module' => $this->getResourceLoaderModuleName(),
		'coverage' => $this->coverage,
		'platforms' => $this->platforms,
		'privacyPolicy' => $this->privacyPolicy,
                        
                 //new
                 'metaHead' =>$this->metaPageHead,
                 'metaBody' = >$this->metaPageBody
	];
}

extensions/QuickSurveys/i18n/en.json

add keys and values, example:

"ext-quicksurveys-metaPageHead": "Meta Title",
"ext-quicksurveys-metaPageBody": "String containing meta page body",

Whether Option A is the best for the user as the info window obscures the questions.

How we would signify the tooltip should be included (maybe a span class), and then also how to add the translation key (likely as a config value).

How to use OOUI.js when we aren't currently using it in QuickSurvey.

Is Option A the best for the user (as the info window obscures the questions)?
maybe, really I am not sure about this as it seems to be a designer question - but ability to place window will be dependent on library script library used

How do we signify the tooltip should be included (maybe a span class), and then also how to add the translation key (likely as a config value)?
need image for clicking (in ooui library) update WikimediaMessages, en.json file, then playing with the front end for the JavaScript to display data

How do we use OOUI.js when we aren't currently using it in QuickSurvey?
we are not sure, may be able to just add it after other JavaScript libraries, would have to test. maybe will need to rewrite the view layer, some css to make the buttons correct size - Jason, Essex and Ellen discussed and believe that this is probably another spike, concerning what would need to happen to bring in OOUI.js and the ramifications on the code base

Is Option A the best for the user (as the info window obscures the questions)?

Happy to chime in here. In order to build an argument we have to take context into consideration. What is the context in which a user might open this pop-up dialog? They probably already read through the survey, but they are still unsure about the intent and scope of such survey. They want to learn more, but without having to leave the page for finding an answer on their own. We have to acknowledge that the survey is being displayed to them hence potentially interrupting their original intent and navigation flow. That's where the info button comes into play. It's a standard pattern that is being used to incrementally reveal more contextual information only when users want to. If a user is purposely opening the dialog we can assume that is fair if some of the survey content is hidden behind it.

Greetings, I would like to provide some feedback here based on the meeting Ellen, Jason and I had regarding the same. From what I recall, we all agreed that we would

  1. Need to find out if OOUI could work alongside our current library -> thus making a refactor minimal. We would/could create a new component that imports the tooltip library.
  2. Perhaps create a POC to flesh look at the usability and complexities of implementing Option A or B. The POC could also verify the aforementioned bullet point.
  3. Mock up pseudo-code of the Vue component
  4. Verify what pages would/will be impacted by this effort.

from @jsn.sherman and @essex

  1. Library in question is wvui
  2. Proposal to make a new component and try including it.

@Scardenasmolinar says OOUI does server side rendering. wvui will be deprecated eventually.

@jsn.sherman Not much wvui code to begin with, as it mostly uses pure vue. Would it be a small migration from wvui to OOUI?

@ERayfield there may be a tooltip availalble.

Review: This looks like a thorough investigation to me!

ERayfield renamed this task from SPIKE [8hrs] Display an info pop-up button next to the survey question to SPIKE [38hrs] Display an info pop-up button next to the survey question.Feb 9 2022, 4:46 PM
ERayfield updated the task description. (Show Details)

@aminalhazwani this should be ready for you to look at!

If we would decide to add the pop-up dialog I would also lean towards adding the OOUI component since it already includes styles for RTL languages, accessible markup and keyboard navigation. While if we decide to pursue stand alone JS I would rather make a contribution to Codex instead of developing a bespoke component for QuickSurvey only.

Onto you @Madalina!

This looks good to me, marking this as resolved.