PDA

View Full Version : vBA Dynamics - Enhanced Article Rating System


aproape
09-18-2008, 05:31 AM
Good morning everyone!

This is part 2 that contains a complex rating system for Dynamics.

Important Notes:

A. Please note that one field is added to the entries table and one existing field is altered.

B. This rating system only applies to articles from Dynamics - it does not modify or alter the rating behavio[u]r for the forums.

C. This modification is released to be used ONLY for Dynamics. The code/ideas/formulas from this mod cannot be used in other applications or projects without permission from myself or Maribal Inc.

Detailed description:

As we know, the rating system in VB [and Dynamics] is using the [average] function - to calculate all votes/values. This system can be abused and the average can vary greatly if someone leaves a low vote or has something against the author..

Plus, an article which is newer in the system and has 3 votes of 5 - compared to another article which is one year old - also with 3 votes of 5 - appear equal.. when in fact they should be clearly differentiated using other elements.

This mod enhances the article rating system with the addition of several new elements:

1. Number of votes for an article [total]
2. Average rating for the article
3. Average of the average rating for ALL articles in the system
4. Number of FULL [REAL] reads [all pages of an article]
5. Number of hits [displays] for an article
6. Scale of rating [variable - so we are not limited to only votes values of 1-5 we can also use 1-10 or 1, 3, 5]
7. Maximum number of hits vs max number of reads for ALL articles
8. Number of comments - for an article
9. Maximum number of comments for all articles
10. Date of the articles

The formula we've come up from all the elements above will give you a number - from 1 to 5 with 2 decimals.. 5.00 being the highest possible [and very difficult to attain..].

The result of the calculation we found it to be very fair and it is protecting the article system from exploits like 9 votes of value 5 and 2 votes of value 1 [therefore, average very low].


Installation instructions:

1. SQL table changes:

[change this to your table names if different/more instances/etc]

a. Adds a new field that will hold the _real_ number of reads of an article:

ALTER TABLE `adv_dyna_entries` ADD `reads_nr` INT NOT NULL DEFAULT '0';

b. Alters the [votetotal] field to have decimals:

ALTER TABLE `adv_dyna_entries` CHANGE `votetotal` `votetotal` DECIMAL( 10, 5 ) UNSIGNED NOT NULL DEFAULT '0'


2. Plugins

Copy the plugins folder and all its content to the ROOT of your domain - the directory of www.domainname.com, NOT domainname.com/forums/! Set permissions of debug.txt to 0666 (needed only for debugging purposes)

Using CP Admin go to Plugins & Products > Add New Plugin and enter/select in form as follows:

Product: vBulletin
Hook Location: vba_dyna_functions_saveentry_rate_entry
Title: Weighed rating
Execution Order: 1
Plugin PHP Code: include(DIR . '/../plugins/vba_dyna_functions_saveentry_rate_entry.php');
Plugin is Active: Yes

Plugins for updating articles reads number after the last page is viewed or after a printable version is requested.

Product: vBulletin
Hook Location: vba_dyna_showentry_start
Title: Increment complete reads on last page
Execution Order: 1
Plugin PHP Code: include(DIR . '/../plugins/vba_dyna_showentry_start.php');
Plugin is Active: Yes


Product: vBulletin
Hook Location: vba_dyna_misc_printerfriendly
Title: Increment complete reads on last page
Execution Order: 1
Plugin PHP Code: include(DIR . '/../plugins/vba_dyna_misc_printerfriendly.php');
Plugin is Active: Yes



Enjoy!
aproape

reddyink
09-18-2008, 08:59 AM
Thank you for rating system. You have added the most critical missing piece to vb dyna.

Our Sponsors
 

Webs961
08-07-2009, 11:02 PM
Hey! Just installed this onto a Dynamics portal.. right now, none of our articles have any posts to them (because so far all of them are admin articles that users are not allowed to post to). Line 154 causes an error because there is no check to make sure that $max_posts isn't zero. This is going to cause a problem for us because we have a Dynamics portal where users will not be allowed to reply to posted articles, but where ratings are still desired. The fix is simple (or at least the one we have decided on works for us), but I though I'd post it here as fixing it in the official release might be a good idea.

Line 154, the change we made:
$comments_factor = $max_comments > 0 ? ($comments / $max_comments) * ES_RATING_SC * $K3 : 0;

Just a suggestion.. :D