Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: M-DVD on April 21, 2009, 12:07:34 PM

Title: Weighted Votes in Polls
Post by: M-DVD on April 21, 2009, 12:07:34 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1763)




MOD Weighted Votes in Polls v1.0
=======================







  • Autor:
M-DVD (http://custom.simplemachines.org/mods/index.php?action=profile;u=148997)
  • Version:
1.0
  • Release:
08th April 2009
  • Languages:
(http://www.simplemachines.org/site_images/lang/english.gif) (http://www.simplemachines.org/site_images/lang/english_british.gif) (http://www.simplemachines.org/site_images/lang/spanish.gif) (http://www.simplemachines.org/site_images/lang/spanish_latin.gif)
  • Compatible With:
SMF 1.1.1 - 1.1.8
SMF 2 Beta 3 & 4 & RC1




(http://www.simplemachines.org/community/Themes/smsite/images/star.gif)(http://www.simplemachines.org/community/Themes/smsite/images/star.gif)(http://www.simplemachines.org/community/Themes/smsite/images/star.gif)(http://www.simplemachines.org/community/Themes/smsite/images/star.gif)(http://www.simplemachines.org/community/Themes/smsite/images/star.gif) (http://www.simplemachines.org/community/index.php?action=post;topic=305945.0)
Comment this Mod (http://www.simplemachines.org/community/index.php?action=post;topic=305945.0)
(http://www.simplemachines.org/site_images/modtitlebar.png)(http://www.simplemachines.org/site_images/modtitlebar.png)(http://www.simplemachines.org/site_images/modtitlebar.png) (http://custom.simplemachines.org/mods/index.php?action=profile;u=148997)
My MODs (http://custom.simplemachines.org/mods/index.php?action=profile;u=148997)
(http://www.simplemachines.org/community/Themes/smsite/images/bbc/img.gif)(http://www.simplemachines.org/community/Themes/smsite/images/bbc/img.gif)(http://www.simplemachines.org/community/Themes/smsite/images/bbc/img.gif) (http://custom.simplemachines.org/mods/index.php?mod=1763)
Images (http://custom.simplemachines.org/mods/index.php?mod=1763)
(https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif) (https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4587421)Help support my MODs (https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4587421)

Features:




IMPORTANT RECOMENDATION: You shouldn't change the "weight vote" while a poll is active (no finished). The weighted result will be "false".
Example: before use this MOD, you should close and finish all the poll (old poll) in your forum.

Thanks to donjoe (http://www.simplemachines.org/community/index.php?action=profile;u=110975).

Example:

In Board 1: Senator (7), Secretary (5), Normal (1)
In Board 2: Senator (2), Secretary (2), Normal (7)
In Board 3: Senator (1), Secretary (5), Normal (7)







MemberGroupBoard 1Board 2Board 3
==============================
Senator
x 7
x 2
x 1
Secretary
x 2
x 2
x 5
Normal
x 1
x 7
x 7
==========================

Languages (normal & utf-8)


$txt['mboards_weight_groups'] = 'Weighted Vote in Polls';
$txt['mboards_weight_groups_desc'] = 'Each vote will have worth by <i>Weight</i> voter group.<br />
<i>Note: Weight = 1 by default</i>';

$txt['show_title'] = 'Results Normal';
$txt['show_title_weighted'] = 'Results Weighted';
$txt['votes_weighted'] = 'weighted votes';

$txt['weightedvotes_mode'] = 'Poll Results mode';
$txt['weightedvotes_mode01'] = 'Show Results Normal';
$txt['weightedvotes_mode02'] = 'Show Results Weighted';
$txt['weightedvotes_mode03'] = 'Show Both Results';

I welcome new translations here (http://www.simplemachines.org/community/index.php?action=post;topic=305945.0)

==========================

Características:




RECOMENDACIÓN IMPORTANTE: No debes cambiar los pesos de los votos mientras una encuesta esté activa. El Resultado Ponderado será "falso".
Ejemplo: antes de usar el MOD, debes cerrar y finalizar todas las encuestas existentes.

Fin.
Title: Re: Weighted Votes in Polls
Post by: Sudhakar Arjunan on April 23, 2009, 03:17:15 PM
Good Mod M-DVD.
Title: Re: Weighted Votes in Polls
Post by: M-DVD on April 25, 2009, 12:50:12 PM
Thanks for your comment :D
Title: Re: Weighted Votes in Polls
Post by: shanksta13 on April 25, 2009, 01:44:53 PM
Looks like a great mod, I just installed it.  One small problem, I'd like to weight the results based on post-count groups, but most of my members are also members of other groups.  I left the "other groups" set to 1, and increased the post-count groups to more weight as the post-count group increased.  However, the weighted poll seems to be using the other groups as an overwrite for the post-count groups.  Any way to solve this?  If it's not clear what I'm saying, I can probably explain it a little better.
Title: Re: Weighted Votes in Polls
Post by: M-DVD on April 25, 2009, 02:14:11 PM
Quote from: shanksta13 on April 25, 2009, 01:44:53 PMI can probably explain it a little better.

Yes :P

But maybe this answer your question.

The Weigth Vote is decided as:

    If the user is Moderator Local
    Then
          Use this weight.
    Else
          If the user have Primary Group
          Then
                    Use this weight.
          Else
                    Use the weigth for Group Post Count.
Title: Re: Weighted Votes in Polls
Post by: shanksta13 on April 25, 2009, 02:19:26 PM
Quote from: M-DVD on April 25, 2009, 02:14:11 PM
Quote from: shanksta13 on April 25, 2009, 01:44:53 PMI can probably explain it a little better.

Yes :P

But maybe this answer your question.

The Weigth Vote is decided as:

    If the user is Moderator Local
    Then
          Use this weight.
    Else
          If the user have Primary Group
          Then
                    Use this weight.
          Else
                    Use the weigth for Group Post Count.

Perfect, now is there any way I can make a custom modification to make Post-Count group the first option?  Or can you add this setting into the admin panel?  It sounds like maybe it's just a matter of switching that last else statement into the first if statement.
Title: Re: Weighted Votes in Polls
Post by: M-DVD on April 25, 2009, 09:11:17 PM
Quote from: shanksta13 on April 25, 2009, 02:19:26 PM
Perfect, now is there any way I can make a custom modification to make Post-Count group the first option?  Or can you add this setting into the admin panel?  It sounds like maybe it's just a matter of switching that last else statement into the first if statement.

I feel the current way is the most correct. A user can be "group charter" (example) and he can vote as a "charter" in all the forum. But he is a 'Moderator Local' in a Board. Then his vote would weigh as a Moderator Local here.

But, it's your decision. No problem :)

Seach in Sources/Poll.php

$ind = empty($user_info['is_mod']) ? (empty($user_settings['id_group']) ? $user_info['groups'][1] : $user_settings['id_group']) : '3';


Replace:

$ind = empty($user_settings['id_group']) ? (empty($user_info['is_mod']) ? $user_info['groups'][1] : '3') : $user_settings['id_group'];
Title: Re: Weighted Votes in Polls
Post by: shanksta13 on April 26, 2009, 04:11:30 PM
Quote from: M-DVD on April 25, 2009, 09:11:17 PM
Quote from: shanksta13 on April 25, 2009, 02:19:26 PM
Perfect, now is there any way I can make a custom modification to make Post-Count group the first option?  Or can you add this setting into the admin panel?  It sounds like maybe it's just a matter of switching that last else statement into the first if statement.

I feel the current way is the most correct. A user can be "group charter" (example) and he can vote as a "charter" in all the forum. But he is a 'Moderator Local' in a Board. Then his vote would weigh as a Moderator Local here.

But, it's your decision. No problem :)

Seach in Sources/Poll.php

$ind = empty($user_info['is_mod']) ? (empty($user_settings['id_group']) ? $user_info['groups'][1] : $user_settings['id_group']) : '3';


Replace:

$ind = empty($user_settings['id_group']) ? (empty($user_info['is_mod']) ? $user_info['groups'][1] : '3') : $user_settings['id_group'];

That didn't seem to have any effect.  I think that's the right line of code, but just to clarify in case, I want the order to be:

1. Post-Count Group
2. Member Group
3. Local Moderator
Title: Re: Weighted Votes in Polls
Post by: M-DVD on April 26, 2009, 05:09:01 PM
Quote from: shanksta13 on April 26, 2009, 04:11:30 PM
That didn't seem to have any effect.  I think that's the right line of code, but just to clarify in case, I want the order to be:

1. Post-Count Group
2. Member Group
3. Local Moderator

Ok, I thought you wanted:
1. Primary Group
2. Local Moderator
3. Post-Count Group

In your case:
1. Post-Count Group
2. Member Group
3. Local Moderator

All member has a Post-Count Group, then never will be use the Weight primary group/moderator local.
Title: Re: Weighted Votes in Polls
Post by: shanksta13 on April 27, 2009, 01:36:51 AM
Quote from: M-DVD on April 26, 2009, 05:09:01 PM
Quote from: shanksta13 on April 26, 2009, 04:11:30 PM
That didn't seem to have any effect.  I think that's the right line of code, but just to clarify in case, I want the order to be:

1. Post-Count Group
2. Member Group
3. Local Moderator

Ok, I thought you wanted:
1. Primary Group
2. Local Moderator
3. Post-Count Group

In your case:
1. Post-Count Group
2. Member Group
3. Local Moderator

All member has a Post-Count Group, then never will be use the Weight primary group/moderator local.

Okay, so is there any easy way to modify the code then to get this effect?
Title: Re: Weighted Votes in Polls
Post by: M-DVD on May 02, 2009, 07:01:14 PM
Quote from: shanksta13 on April 27, 2009, 01:36:51 AM
Okay, so is there any easy way to modify the code then to get this effect?

Ok, in this case, only use it:

$ind = $user_info['groups'][1]
Title: Re: Weighted Votes in Polls
Post by: emanuele on September 12, 2009, 08:56:44 AM
Quote from: M-DVD on April 21, 2009, 12:07:34 PM
IMPORTANT RECOMENDATION: You shouldn't change the "weight vote" while a poll is active (no finished). The weighted result will be "false".
Example: before use this MOD, you should close and finish all the poll (old poll) in your forum.
Hi, I would like to use this mod on my forum, just one question to have everything clear in my mind.

I would like to weight the votes in only one board.
Should I close anyway all the current polls in the entire forum?
Title: Re: Weighted Votes in Polls
Post by: shadowfax82 on January 26, 2010, 05:17:24 PM
Hello everybody,

I'm the admin of clubfordpuma.com/foro.  I have a secondary group (members of the club).  What I want to do is to asign weight "2" to the members of the club, and weight "1" to the non-members.

I have just changed the weights in the desired board (previously, I did close all the polls inside it!), but the mod doesn't respond as required.

I need some help to put weighted polls in my forum.

Thanks to everybody :)
Title: Re: Weighted Votes in Polls
Post by: Sapinho® on July 18, 2011, 04:20:59 AM
*-* this is the mod i remember... u are the man, m-dvd, i hope u update son this :) congrantz