SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Rating System

  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rating System

    Hi,

    I'm designing a rating system for my cms which I will be implementing soon when my site gets a complete overhaul (read my thread in news section of my forum).

    However, before I begin to code it I need to know a few things:

    1. Should i use flat file or database?

    2. For each rating should I enter a new record or should I just update the previous?

    3. When displaying an average I want to be able to choose have a select number of decimal places. How could I do this:

    printf("<b>%s</b>", $rate, 2);

    4. Should I allow users to rate the article more than once and if not then should i use cookies to stop them or should i record their IP and Browser specs in the database?

    Thanks allot,
    Peter

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Generally use a database if you've got one - it's usually easier to maintain and it means you can easily back up the site by simply dumping the database contents.

    2. Up to you. I've got a rating system for ssLinks (see link in sig) which works by updating the record for each link whenever a new vote is cast - it adds 1 to the number of votes and then adds what they voted to a field storing the TOTAL of all votes cast. When it displays the rating for a link it just divides the total of all votes by the number of votes to get the average

    3. Yes you use printf, but not like that. Do this: printf ("%.2f", $number); Replace the 2 with the number of decimal points you want.

    4. This is again up to you. There is NO WAY of properly preventing people from voting more than once without forcing them to register a username and password, and even then they can register more than one account. Online voting is inherently flawed because of this. It depends on how desperate you are to stop cheats (remember if they are determined they will always be able to get around your defences). Personally I just set a cookie as it's the easiest way, and recording an IP doesn't work seeing as most people are on dynamic IP addresses thanks to being on a modem. Again, it's your decision.

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Skunk (may I call you that?),

    Thanks allot for your post as it has helped allot. The suggestion of how to added them to the databases help tremendously and I never thought of it that way and I'm definately going to do that way.

    It also looks like I'm just going to have to use a cookie to stop people from voting more than once, but it really isn't that importnt.

    Thanks again

  4. #4
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey petesmc, do you use a bar chart for the visualization of the ratings, as they use in the polls here in sitepointforums. If so, could you show me ore explain me how to realize it. thanx, smorb

  5. #5
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't finish it yet but I won't be using bars. But if you want to know how i'd do it is basically create a table with set with a spacer image. The image width depends on the rating.

    -Peter

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Skunk
    Personally I just set a cookie as it's the easiest way, and recording an IP doesn't work seeing as most people are on dynamic IP addresses thanks to being on a modem.
    Personally, I like to do both. Perhaps my reasoning is a bit flawed, but here goes

    Set only cookie:
    User turns off cookie, proceeds to vote 1000 times in a row.

    Set only IP:
    Dynamic IPs, one vote per connection.

    Both:
    Even if a user turns off cookies, they can still only vote once per connection. Not much you can do about that (unless you match a wide range of IPs...). But if a user doesn't turn off cookies, they can still only vote once. Best of both worlds really.

    But that's just me

  7. #7
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't this make a really big table if you had allot of visitors?

    I'd like to do it this way, but I'm trying to keep the server queries and load to a low and speed to a fast.

    -Peter

    P.S Maybe the Sitepoint developers can tell us how their rating system works as this is what I'm trying to accomplish. No code needed, just the basics.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Location
    Switzerland
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to make the rating system even more "secure", i would recommend to add a 3rd thing: log the web address (like modem193.ca.aol.com or whatever) of all voters. if you only have a few votes per topic (like for this ssLinks script), it will be an effective way to check that all the ratings are fair and your mind will be more peaceful


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •