Hello,

on my site I'd like to implement a feature that'd allow me to collect votes on a poll but to hide the results until the poll is finished. I figured that the best way would be to add "hide results" as an option (admin only) to the poll creation menu. I tried to add it myself but I've started PHP programming not long ago so I've reached a point where I'm stuck. I've managed to add the feature "hide results" to the poll creation page but I'm not managing to actually use the value later on in the code to really hide the results.

For this to work I added an additional field to the poll table, called "hide".

I've attached the poll.module file to this post along with the changes that I've made.

Comments

killes@www.drop.org’s picture

Version: 4.7.3 » x.y.z
Status: Needs work » Active

not a proper patch, new features go into HEAD.

lilou’s picture

Version: x.y.z » 7.x-dev
gpk’s picture

amateescu’s picture

Version: 7.x-dev » 8.x-dev
alexpott’s picture

Project: Drupal core » Poll
Version: 8.x-dev » 8.x-1.x-dev
Component: poll.module » Code

Poll has been removed from core

adammalone’s picture

Assigned: Unassigned » adammalone
tbonomelli’s picture

Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new3 KB

Added the field for the option to hide the result.
Work still in progress

tbonomelli’s picture

Assigned: adammalone » tbonomelli
tbonomelli’s picture

Assigned: tbonomelli » Unassigned
dom.’s picture

+++ b/src/Form/PollViewForm.php
@@ -188,6 +191,9 @@ class PollViewForm extends FormBase {
+      if ($poll->getHideResult()) {
+        ¶
+      }

Why this useless statement ?

+++ b/src/Form/PollViewForm.php
@@ -143,6 +143,9 @@ class PollViewForm extends FormBase {
+        return TRUE;

I think this should return FALSE

Also the patch misses a hook_update_N() for applying the basedfieldefinitions changes. Eventually some tests too.

Patch fails if the module have already been installed because of the lack of update path.

dom.’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#3007808: Fine grain control over results display

Marking this duplicate of #3007808: Fine grain control over results display since this new issue will take this into consideration among other possibilities.