ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

[amp-story-interactive] Allow for not displaying results #32544

Open cpauwels opened 3 years ago

cpauwels commented 3 years ago

Describe the new feature or change to an existing feature you'd like to see

There are some cases for polls or quizes where the story publisher might not want to show the results. A simple case would be one of polling for customer satisfaction. If customers are not satisfied, the publisher might not want to show the results or make them public.

I think simply removing the response percentage text should do the trick, and having the visualisation similar to just one person having responded (100% for the selected option, 0% for all others)

newmuis commented 3 years ago

@mszylkowski I know if no backend is specified, we (obviously) don't aggregate the results; is it possible to trigger that state while still sending data to the backend?

mszylkowski commented 3 years ago

On our v1 launch we designed components to always show the responses but I think this is a completely valid use-case.

Currently the way I see this working in this way would be to have the backend return an invalid JSON (but still record the vote), so the percentages don't show but they get recorded in the backend. This requires some development from the backend owner but I think is the more robust/secure solution (and the format can gracefully catch this error, but it should currently work as you detailed).

We can also introduce an attribute to hide the results in the component, but anyone would be able to know the customer responses with the right HTTP request. It should be relatively easy to make this change and we can add it to our roadmap.

newmuis commented 3 years ago

Good point about changing the endpoint's response. Sounds reasonable to launch an attribute to disable the result state and provide documentation on the shape of the JSON response in that case.

/cc @raovs @hongcatlover to ensure this sounds reasonable to them

raovs commented 3 years ago

LGTM from my side