P2Dpro
JoomlaXT!
Welcome, Guest
Please Login or Register.    Lost Password?
calculating average
(1 viewing) 1 Guest
Go to bottom
TOPIC: calculating average
#7782
ognjenko
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
calculating average 7 Months ago Karma: 0
Hello! Thank you for this great joomla component!

I have one question: if all options in my poll are numbers, how do I calculate and display average result below results commonly displayed? I understand it has to be done in pollxtresult.class.php but I am not so good php coder.

Thank you very much
 
Logged Logged
  The administrator has disabled public write access.
#7793
omerten
Moderator
Posts: 2711
graph
User Offline Click here to see the profile of this user
Re:calculating average 7 Months ago Karma: 63
Hi,

the average is already calculated, because it's needed for the rating functionality (of course that only works properly for numbers) you just have to include to the results display... find the following lines in the file you mentioned:
Code:


if ($this->conf->sh_abs) $ret .= " ".$count;
if ($this->conf->sh_abs && $this->conf->sh_perc) $ret.= " ("; 
if ($r->data->type == "7") 
$ret .= $rdes;
else 
         if ($this->conf->sh_perc) $ret .= " ".$percVal."%";
if ($this->conf->sh_abs && $this->conf->sh_perc) $ret.= ")"; 


These lines are responsible for displaying (depending on the settings) something like "x (y%)". You could now add e.g.:
Code:


$ret .= $avg;


This is not really beautiful, but it should work (and I guess you can beautify it yourself?)
regards,
Oli
 
Logged Logged
  The administrator has disabled public write access.
#7811
ognjenko
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:calculating average 6 Months, 4 Weeks ago Karma: 0
Ok I need average of all the votes, if I put $avg where you say it gets displayed after each of the questions. Can you maybe think of quick function that will calculate it and display it maybe?

Thank you
 
Logged Logged
  The administrator has disabled public write access.
#7843
ognjenko
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:calculating average 6 Months, 2 Weeks ago Karma: 0
any update on this please?

Thank you
 
Logged Logged
  The administrator has disabled public write access.
Go to top

Donation

Development and Maintenance of Joomla extensions is time consuming. Webspace and Server cost money. With a small donation you can help that we're able to pay the bills and can continue developing free extensions.

Make payments with payPal - it's fast, free and secure!

Featured Products


Get in touch

Search

This site is hosted by


Copyright © 2003-2009 by JoomlaXT! Template based on afterburner by Rockettheme
Joomla!(TM) is the trademark of Open Source Matters, Inc in the United States and other countries. The Joomla! name and variations on it utilizing shortforms for it such as J, Joo, Joom, etc, used on this site, is used under a limited license granted by Open Source Matters. JoomlaXT! is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.