DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:multipoll

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:multipoll [2010-04-12 16:18] 195.220.94.78plugin:multipoll [2023-12-17 21:13] (current) – new download url Aleksandr
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Lets you add slightly extended polls to a wiki page(from poll plugin by Gina Häußge, Michael Klier and previously Esther Brunner)+description: Lets you add slightly extended polls to a wiki page (from poll plugin by Gina Häußge, Michael Klier and previously Esther Brunner)
 author     : Etienne MELEARD author     : Etienne MELEARD
 email      : etienne.meleard@free.fr email      : etienne.meleard@free.fr
 type       : syntax type       : syntax
 lastupdate : 2010-04-12 lastupdate : 2010-04-12
-compatible : >=2006-11-06+compatible : Detritus, Greebo, !Hogfather
 depends    :  depends    : 
 conflicts  conflicts 
 similar    : poll, userpoll similar    : poll, userpoll
 tags       : extended poll, poll, !experimental tags       : extended poll, poll, !experimental
 +
 +downloadurl: https://trello.com/1/cards/5afdce92c41a16189740888e/attachments/5afdcec570defdb9b490bfcb/download/multipoll.zip
 +bugtracker : 
 +sourcerepo : 
 +donationurl: 
 +
 +screenshot_img: 
 ---- ----
  
-**This plugin is the result of an attempt of mine to make the original poll plugin meet my requirements, I heavily hacked into its code, thus it looks very similar ... I do not attempt to "steal" the original work, but the code I ended with was too much different to just propose a patch ... If the authors of the poll plugin are interested in a merge, they are welcome !!!**+> :!: This plugin is the result of an attempt of mine to make the original poll plugin meet my requirements, I heavily hacked into its code, thus it looks very similar... I do not attempt to "steal" the original work, but the code I ended with was too much different to just propose a patch... If the authors of the poll plugin are interested in a merge, they are welcome!
  
-^ Download | [[http://dokuwiki.yent.eu/multipoll.zip|multipoll.zip]] |+:!: **Animated** version, adopted from [[http://cssdeck.com/labs/animated-progress-bar|cssdeck.com]] can be downloaded [[http://comicslate.org/_media/wiki/dokuplug/multipoll1.tgz|here]] **(MD5 sum 392d7a5075aaf36c6f49feecdb67bd15)** 
 + 
 +:!: Animated version with **conf[width of poll bars]** can be downloaded [[http://comicslate.org/_media/wiki/dokuplug/multipoll2.tgz|here]] **(MD5 sum 4cbf093a456e6414cb9960e626f06f70)** 
 + 
 +:!: Universal bug (at least in Binky) - __nonregistered users can press F5 for reload page and automatically adding votes for first answers in all questions__. That crush all.
  
 ===== Syntax ===== ===== Syntax =====
  
-Use this [[plugins|plugin]] to add a poll to a wiki page. The syntax looks like this:+Use this plugin to add a poll to a wiki page. The syntax looks like this:
  
-  <multipoll [id]>+  <multipoll [hideresults] [hideifvoted] [showresultsto]=user,@grp,... | [id]>
     [question 1]     [question 1]
     * [option]     * [option]
Line 37: Line 48:
   </multipoll>   </multipoll>
  
-^ [id]       | the ID of the poll; must be unique((If it is not, metadata of the polls with the same id gets mixed up, i.e. users with IPs who have voted for a previous poll with that id can't vote again.)); appears as title required | +^[hideresults]   | hides the results of the poll to users who don't have write access on the page, displays a "You already voted" message instead | optional | 
-^ [question] | the question you'd like to ask | optional | +^[hideifvoted]   | completly hides the poll once the user voted, only users with write access on the page can see the results | optional | 
-^ [option]   | a possible answer to the immediately above question required |+^[showresultsto] | comma separated list of users or @groups which can see the results without the need to vote or to have editing rights | optional | 
 +^[id]       | the ID of the poll; must be unique((If it is not, metadata of the polls with the same id gets mixed up, i.e. users with IPs who have voted for a previous poll with that id can't vote again.)); appears as title required | 
 +^[question] | the question you'd like to ask | optional | 
 +^[option]   | a possible answer to the immediately above question required |
  
 The poll title is converted to a md5sum. This is used as the filename in data/meta: md5sum.multipoll - so all polls in the whole wiki must be unique. As a result you can move your poll around and the poll data is accessible. If you remove the poll you must remove the poll data with "rm". The poll title is converted to a md5sum. This is used as the filename in data/meta: md5sum.multipoll - so all polls in the whole wiki must be unique. As a result you can move your poll around and the poll data is accessible. If you remove the poll you must remove the poll data with "rm".
  
 ===== Installation Notes ===== ===== Installation Notes =====
 +
 When the [[blog]] plugin is also installed, you need to turn ''$conf['plugin']['blog']['useifmodifiedsince']'' off. I will try to eliminate this incompatibility. When the [[blog]] plugin is also installed, you need to turn ''$conf['plugin']['blog']['useifmodifiedsince']'' off. I will try to eliminate this incompatibility.
  
 ===== Discussion ===== ===== Discussion =====
  
 +Following patch provides:
 +  * Fix - poll results percentage indicators are accurate even in case when user votes for some questions while not choosing any radio-button for other questions
 +  * Feature - IP can vote again after one hour time limit expires
 +  * Feature - After vote, return user to $ID.'#anketa', that means his browser is pointed to poll results
 +  * Feature - More space is added between two questions so they can be easily distinguished
 +
 +<file diff syntax.diff>
 +--- syntax.orig.php 2010-04-12 18:08:48.000000000 +0200
 ++++ syntax.php 2010-06-06 21:48:50.000000000 +0200
 +@@ -151,6 +151,8 @@
 +  if($save) {
 +  $poll['votes']++;
 +  $poll['ips'][] = $ip;
 ++ // CHANGE
 ++ $poll['time'] = time();
 +  if($_SERVER['REMOTE_USER']) $poll['users'][] = $_SERVER['REMOTE_USER'];
 +  if($fh = fopen($pfile, 'w')) {
 +  fwrite($fh, serialize($poll));
 +@@ -158,7 +160,7 @@
 +  }
 +  $voted = true;
 +  }
 +- }elseif(in_array($ip, $poll['ips']) || ($_SERVER['REMOTE_USER'] && in_array($_SERVER['REMOTE_USER'], $poll['users']))) {
 ++ }elseif( (in_array($ip, $poll['ips']) /*CHANGE - one hour limit*/ && time()-$poll['time'] <= 60*60) || ($_SERVER['REMOTE_USER'] && in_array($_SERVER['REMOTE_USER'], $poll['users']))) {
 +  $voted = true;
 +  }
 + 
 +@@ -188,11 +190,20 @@
 +  foreach($questions as $question) {
 +  $ret .= ' <div class="multipoll_question" id="poll_question_'.$q.'">'.$renderer->_xmlEntities($question['q']).'</div>'."\n";
 +  $ret .= ' <table class="blind">'."\n";
 ++ // CHANGE - Find total number of votes for this question; note this might be different from $poll['votes'],
 ++ // since user might vote only for some questions and not for others
 ++ $total = 0;
 ++ foreach($question['a'] as $a) {
 ++ $s = isset($poll['results'][$q]) ? (isset($poll['results'][$q][$a]) ? $poll['results'][$q][$a] : 0) : 0;
 ++ $total += $s;
 ++ }
 +  foreach($question['a'] as $a) {
 +  $ret .= ' <tr>'."\n";
 +  $a = $renderer->_xmlEntities($a);
 +  $s = isset($poll['results'][$q]) ? (isset($poll['results'][$q][$a]) ? $poll['results'][$q][$a] : 0) : 0;
 +- $pct = sprintf('%3.1f', 100 * $s / $poll['votes']);
 ++ // CHANGE
 ++ // $pct = sprintf('%3.1f', 100 * $s / $poll['votes']);
 ++ $pct = sprintf('%3.1f', 100 * $s / $total);
 +  $ret .= ' <td>'.$a.'</td>'."\n";
 +  $ret .= ' <td><div class="multipoll_bar">'.($s ? '<div class="multipoll_full" style="width:'.($pct * 2).'px">&nbsp;</div>' : '').'</div></td>'."\n";
 +  $ret .= ' <td class="rightalign">'.$pct.'% ('.$s.')</td>'."\n";
 +@@ -209,7 +220,9 @@
 +  global $lang;
 +  global $ID;
 + 
 +- $ret = '<form id="multipoll__form" method="post" action="'.script().'" accept-charset="'.$lang['encoding'].'">'."\n";
 ++ // CHANGE
 ++ // $ret = '<form id="multipoll__form" method="post" action="'.script().'" accept-charset="'.$lang['encoding'].'">'."\n";
 ++ $ret = '<form id="multipoll__form" method="post" action="'.$ID.'#anketa" accept-charset="'.$lang['encoding'].'">'."\n";
 +  $ret .= ' <div class="no">'."\n";
 +  $ret .= ' <input type="hidden" name="do" value="show" />'."\n";
 +  $ret .= ' <input type="hidden" name="id" value="'.$ID.'" />'."\n";
 +@@ -225,7 +238,8 @@
 +  $ret .= ' <input type="checkbox" name="multipoll_question_'.$q.'[]" value="'.$a.'" /> <span>'.$a.'</span><br />'."\n";
 +  }else $ret .= ' <input type="radio" name="multipoll_question_'.$q.'" value="'.$a.'" /> <span>'.$a.'</span><br />'."\n";
 +  }
 +- $ret .= ' <hr />'."\n";
 ++ // CHANGE
 ++ $ret .= ' <br><hr><br>'."\n";
 +  $q++;
 +  }
 +  $ret .= ' <input class="button" type="submit" name="multipoll_vote" value="'.$this->getLang('btn_vote').'" />'."\n";
 +</file>
plugin/multipoll.1271081939.txt.gz · Last modified: 2010-04-12 16:18 by 195.220.94.78

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki