scriptygoddess

04 Apr, 2004

Script Idea: Comment rating system

Posted by: Jennifer In: Projects

This blog gets quite a number of comments. Some are just nice words of appreciation, others are kind of useful. Then there are some that are more valuable than the post itself! (For an example of this – check out my last few posts about CSS.)

I really hope that if you've been reading this blog for awhile, you've learned to comb through the comments. Sometimes the scripts get completely overhauled in there. Other times, people post other solutions, solve installation problems, etc. post helpful links.

Of course the difficult side of that request, is that some posts have A LOT of comments. Unfortunatley, in some cases you'll see the same question get posted over and over again – when it was already answered or addressed previously – but you'd never find that answer in all the comments. Quite simply, it's difficult to find the answers you really need when there's so many comments in a single post.

SO – my script idea is a "COMMENT" rating system – much like this one which was designed for POSTS (side note: Seems like some updates were added and here is the most recent version). As well, there's an update with timestamps and banning here.
It would be simple enough to modify those scripts to store ratings for comments. Additionally what I would add is this: if the comment is rated 50% or 75% (user choice) positively, then highlight it so it's easier for people to find. (This would probably be a simple div around each comment that has a php include in it – that checks the comment's rating and gives the div a background color for a hightlight) By 50 – 75% I mean this: for example if there are "10" votes on a comment and if 7 of them were + (3 of them were – – maybe from people who didn't completely agree) it would get highlighted. If it got only 3 + votes (from a total of 3 votes) – it would get hightlighted – since 3 out of 3 is 100%.

Here's why I haven't just jumped in and written the script.

1) I don't know when MT 3.0 is coming out and I don't know if maybe it already has a feature like this (My comment queue script is already going to be a waste of space – as MT 3.0 will have it baked in. For this I'm glad – because it will be better that way)

2) Since comment stuff is changing in MT 3.0 – I'm not sure what to expect and I don't want to write a script that will have to be updated/modified the day the new version comes out.

3) Since this script is specifically designed for posts with many comments – my original "design" for it meant checking the database x number of times (where x = the number of comments.) For particularly popular posts (I can't believe that one has 125 comments!!) – would this kill my database, bandwidth, and "download" speed?

So just wanted to throw this out there – I won't be writing this script before the MT 3.0 release… but I'd REALLY like to as I think it would greatly help people trying to use scripts from this site. If anyone else has any ideas – feel free to leave a comment. :)

10 Responses to "Script Idea: Comment rating system"

1 | grave digger

April 4th, 2004 at 11:35 pm

Avatar

It is kind of a responsability to post a comment here, but all I want to say is that I enjoy your work a lot. Keep up!

2 | Mad William Flint

April 4th, 2004 at 11:59 pm

Avatar

What would be extremely valuable is if you would make comments available in the rss feed itself, with page "updates" being flagged when comments are added. That way we could follow the discussions from our aggregators.

3 | Chasmyn

April 5th, 2004 at 2:37 am

Avatar

I just want to say publicly that Jennifer, you really are a goddess. You helped me so much! You are awesome. I bow to your coding skills. One day with much practice I will have a clue as to what I am doing, and I will owe it all you you!

4 | Jennifer

April 5th, 2004 at 8:00 am

Avatar

Mad William – That I can do – but one question, I have a template that has the simple feed for posts and comments, but what do you mean by ""updates" being flagged when comments are added" – is that a different RSS template? I've only copied and pasted what others have done… if there's a template you would like me to use – point the way, and I'll implement it.

5 | Tyme

April 6th, 2004 at 9:27 am

Avatar

I think it's an excellent idea. It's something that has been on forums for quite some time so I think if it is codely properly it will not be resource intensive or a bandwidth hog. Perhaps looking at the code of scripts (open source) who already have this function can give you some ideas on how to incorporate it into MT efficiently?

The thing to be cautious of is abuse – for example making sure that people can only vote once, etc.

6 | Jennifer

April 6th, 2004 at 9:46 am

Avatar

Yeah – I'm thinking that if I get impatient, I may just make a "mini" version of this script that is simply a "flag" the blog owner can turn on to highlight a comment… A little more "time intesive" for the blog owner, but personally I wouldn't mind doing it. I don't see this as a wildly popular script – probably the best use is a blog like this one.

7 | Mad William Flint

April 6th, 2004 at 3:51 pm

Avatar

Hmm… I'm not sure how the back-end works with flagging updates, especially within comments. MT already behaves nicely when a post itself is updated. (bloglines.com does a great job with this.)

The comment stream over at UCCU isn't interesting enough to put in the rss feed, so I never pursued it much.

HOWEVER, Venomous Kate does exactly what I'm thinking of (what, like the idea was MINE? Pff ;-P) I'll go ask her & report back.

8 | Mark J

April 10th, 2004 at 4:00 pm

Avatar

The problem you brought up, Jenn, about having the DB checked for each comment, might be solved this way: for each entry, one database call is made… something along the lines of

"SELECT comment_id FROM mt_comment WHERE comment_highlighted = 1 AND comment_entry_id='$this_entry_id'"

This would return the comment_ids of all "highlighted" comments as an array. Then with each comment you could just do a simple php conditional… that checks to see if the comment currently being processed exists in the returned array.

That way there would just be one database call… and I don't think the simple check of the array for each comment will adversely affect the displaying of the page.

Think that would help?

This could also work for a rating system with numbers… not just the mini system.

"SELECT comment_id, comment_rating FROM mt_comment WHERE comment_rating > 0 AND comment_entry_id='$this_entry_id'"

9 | Julik

April 15th, 2004 at 11:03 am

Avatar

You can simply substitute the MT system of displaying comments with yours, which will make an SQL query for all the comments on every post page, and a JavaScript which will call a script to change comment rating (it will be called only when the rating is assigned). The query will call the MT comments table.
As long as you keep one SQL query for all the comments at once the overhead on the database will not be that high (every SQL request requires opening a socket and authenticating into the DB, which is essentially the biggest bottleneck).
Then in a loop where you show the comments you can make a switch in PHP for checking every comment's rating and update the styles accordingly.
The variant 2 is to have a script call in your MT template, which will add ratings to MT comments when the rebuilt document is loaded – this way you can still show the comments without ratings if your database is down (or the socket is clogged)

10 | The Universal Church of Cosmic Uncertainty

April 6th, 2004 at 5:40 pm

Avatar

Comments in MT RSS feeds
No no, don't worry. I'm not going to do it. But it came up in the comment stream over on Scripty Goddess and I'm not sure how to do it. I was going to go to Venomous Kate since she does that. But when I looked I realized she's not using MT. How 'bout J…

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements