I want to be able to say, for a specific decision (or system wide): a decision is not valid until X out of Y users have voted.

Comments

tatien’s picture

Assigned: Unassigned » tatien

Picking it up.

tatien’s picture

Title: quorum » Quorum
Status: Active » Needs work
StatusFileSize
new455 bytes

Patched the install file to add a quorum column to the decisions table.

tatien’s picture

StatusFileSize
new968 bytes

Added a quorum section to the form.

tatien’s picture

Please take a note that all the patches posted here are dependent on the patches 1 to 8 that I submitted here: http://drupal.org/node/93520.

tatien’s picture

Oops. Please ignore patch #1 on the .install file: column 'quorum' already existed.

tatien’s picture

We should actually have two fields for quorum:

The first field should be a percentage field (let's call it P).

The second field should be a value field (call it V).

The minimum number of votes needed for a decision to be legitimate would then be:
P * size_of_the_electoral_list + V

This allows to set quroums such as 50%+1, that would be P = 50% and V = 1.

tatien’s picture

StatusFileSize
new6.86 KB

This patch verifies if the quorum is met or not and prints a message in the node view regarding its validity.

I also adds a bit of general cleanup in the code.

anarcat’s picture

Ok... a few things here:

1. I think I would prefer to have a single big patch for this, or "thematic patches": e.g. one for implementing the _valid() function, one for implementing the quorum itself, etc.
2. there should be a decisions_valid_hook() if modes or external module want to "validate a decision", and maybe that quorum could be completely split into a seperate module
3. the fields in the database should be named quorum_procent and quorum_abs, imho. the .install file will need to be fixed to rename the current field if this path is taken.

Until then, I wouldn't commit this patch just yet... :)

tatien’s picture

Status: Needs work » Needs review
StatusFileSize
new13.19 KB

WARNING: This patch should be applied instead of patches 1-3.

The following patch adds the following features to decisions:

  • Support quorum percentage + absolute value
  • Computes quorum with a notion of "eligible voters" that includes decisions without electoral list (in that case "eligible" refers to everyone with the "view decisions" permission
  • Does not allow a user to see the results of a decision until the quorum is met.

The _valid functions have been removed for now, because:

  • The name "valid" was a bit confusing (... with "validate")
  • We didn't needed it for quorum (since for now valid just meant meeting the quorum) (I suggest we open a new issue for this "valid" notion.
anarcat’s picture

Status: Needs review » Needs work

Okay, I have an SQL error here after submitting a decision with N = 1 and P = 50:

Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS num FROM users_roles ur JOIN permission p ON ur.rid = p.rid WHERE FIND_IN_' at line 1 query: _decisions_count_eligible SELECT COUNT(DISTINCT *) AS num FROM users_roles ur JOIN permission p ON ur.rid = p.rid WHERE FIND_IN_SET(' view decisions', p.perm) AND ur.uid != 0 in /var/www/drupal-cvs/core/includes/database.mysql.inc on line 167

So I won't commit the patch just yet. :)

anarcat’s picture

Status: Needs work » Fixed

Patch has been applied, after fixing a few issues (the SQL error, the name of the electoral_list function, namely). A few usability issues remain.

Anonymous’s picture

Status: Fixed » Closed (fixed)