PDA

View Full Version : Averaging Data held in 3 User profile fields


Aceman
11-02-2005, 11:16 AM
I currently am developing a system on my forums that will help establish a users experience level as it relates to 3D graphics.

I will be using three custom proflie fields for base values. They are:

Modeling
Texturing
Animation

I would like to average these three values (1-10 scale for each) and establish an overall experience value that I can display.

This is a photoshop mockup:
http://www.scifi-meshes.com/sample_gold5.gif

The OVERALL (3D) bar will be a value based on the values entered in the MTA areas. (M + T + A / 30 * 10 = Value)

Example:
M(4) + T(8) + A(8) / 30 * 10 = 6.6 Rounded up would be a 7

Assume:

M = Field10 (Number from 1 - 10)
T = Field11 (Number from 1 - 10)
A = Field12 (Number from 1 - 10)
Overall = the average of these fields

Is it possible to average data held in the Custom Profile Fields to a whole value (1 - 10).

1. I am unsure how to code so the value is rounded to a whole value. (1,2,3, etc)
2. I then want to display an image (see example) that corresponds to the averaged value.

Can anyone help me?
Aceman

Marco van Herwaarden
11-02-2005, 12:54 PM
Not tested but try something like:

Add a new plugin on postbit_display_complete hook with teh following code:
$post['overall'] = round(($post['field10'] + $post['field11'] + $post['field12']) / 3);
Then use $post[overall] in your postbit template.

This is not tested, so you might have to tweak it a little.

Aceman
11-02-2005, 03:47 PM
This worked PERFECTLY!

THANK YOU!

Aceman

Marco van Herwaarden
11-02-2005, 03:49 PM
Glad to be able to help you.