News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Showing Highest and Lowest Karma Rating in Stats Page

Started by Tristan Perry, October 24, 2004, 05:05:33 AM

Previous topic - Next topic

ozmafans

Quote from: NiXnAx on December 02, 2004, 09:40:55 PM
when you remove good karma from bad karma, you usually get negative karma. (that is supposed when you are nice on the forum), and int (the value of karma, stored in the database cannot be negative) ant that is the reason there is two karma colums. So when you substract 100 (goodkarma) from 100 (badkarma) you get, well you guessed it, 0.
okay, then the question is:

Why will person X on the forum show in the stats page a -30, but on the actual forum have a -3 ? Something here is wrong..

PLUS - The sorting is definitely out of order.

Tristan Perry

#21
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
Ahhh! I never knew you could do that! Thanks, I'll look this over and see if I can get all the problems reported here sorted out so that the mod will show the highest and lower karma totals as well  :)

Quote from: ozmafans on December 02, 2004, 09:27:15 PM
Thank you for that tip, I know very little about php/sql.

The problem seems to be that say I had -100 karma points given to me, and 100 positive karma points given to me.

karmaBad (100) - karmaGood (100) = -200, when it should really be 0. Is there an absolute value function?
That's not true. The data stored in the fields 'karmaGood' and 'KarmaBad' are both positive numbers, therefore if you had 100 good karma, and 100 bad karma, the sum would be:

100 - 100, which would equal 0, not -200.

The mistake you're making is thinking that the data stored is 'karmaBad' has a negative sign in it. You're thinking the sum would be:

-100 - 100, which would, as you say, equal -200.

Tristan Perry

Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals.  :)

NiXnAx

Quote from: Tau Online on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)

NP

But you need to add this back to the start of the karma mod of the Stats.template.php
foreach ($context['top_time_online'] as $poster)
            echo '
                                                <tr>
                                                        <td width="60%" valign="top">', $poster['link'], '</td>
                                                        <td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
                                                        <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
                                                </tr>';
        echo ' </table></td></tr>';


Because you might want to show the most users online stats ;)

Tristan Perry

Quote from: NiXnAx on December 03, 2004, 01:26:50 PM
Quote from: Tau Online on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)

NP

But you need to add this back to the start of the karma mod of the Stats.template.php
foreach ($context['top_time_online'] as $poster)
            echo '
                                                <tr>
                                                        <td width="60%" valign="top">', $poster['link'], '</td>
                                                        <td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : '&nbsp;', '</td>
                                                        <td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
                                                </tr>';
        echo ' </table></td></tr>';


Because you might want to show the most users online stats ;)
Thanks! That might be a good thing to keep  :P

Burpee

How about making the names clickable as well?
All you need to do is add this
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
to each karma-related array in Stats.php,
and replace all ltkarma[Name], $htkarma[Name], $gkarma[Name] and $bkarma[Name]
with $ltkarma[link], $htkarma[link], $gkarma[link] and $bkarma[link] in Stats.template.php.

Tristan Perry

Quote from: Burpee on December 04, 2004, 08:13:19 AM
How about making the names clickable as well?
All you need to do is add this
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
to each karma-related array in Stats.php,
and replace all ltkarma[Name], $htkarma[Name], $gkarma[Name] and $bkarma[Name]
with $ltkarma[link], $htkarma[link], $gkarma[link] and $bkarma[link] in Stats.template.php.
Thanks  :) I meant to add that, but must have forgot. I've changed my first post to reflect these changes  :)

EG

I was wondering whether it would be possible to use this mod to show the table of LLama captures..

since that uses Karma, but... doesnt rely on Karma being enabled ???

*EDIT*

yes just added this code into the stats.template.php and it shows the data without karma being enabled :) 

if( $modSettings['karmaMode'] == 0 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';

foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}

echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';


foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}


brilliant mod :)

vipmoney

hello Guys,

Nice mod, I already implemented and it works great...

Now, I ask from some extra stuf... if possible off course:  ;)

- below the Karma on the post menu, telling for example: 1st place...or 39th place (based on the total Sum off course)
- On the profile page, the same thing

Is that possible ? or is it difficult ?

I mean, its very good to have that on the stats page off course, but imagine a message board, where you have lots of old timers, with very high karma totals, and a lot of new commers, and they watch +350 or +250... but they dont know if its high or low... so showing also the position of that karma on the total users, would be just perfect.

best regards,
VipMoney

Tristan Perry

Quote from: vipmoney on January 20, 2005, 10:03:30 PM
hello Guys,

Nice mod, I already implemented and it works great...

Now, I ask from some extra stuf... if possible off course:  ;)

- below the Karma on the post menu, telling for example: 1st place...or 39th place (based on the total Sum off course)
- On the profile page, the same thing

Is that possible ? or is it difficult ?

I mean, its very good to have that on the stats page off course, but imagine a message board, where you have lots of old timers, with very high karma totals, and a lot of new commers, and they watch +350 or +250... but they dont know if its high or low... so showing also the position of that karma on the total users, would be just perfect.

best regards,
Your welcome, I'm glad it's working for you  :) As for the rank thing, I'm fairly busy right now and so won't be able to make the changes I'm afraid..

vipmoney

VipMoney

redone


Tristan Perry


Alisha


redone

Thank you for that mod. I installed it too and it works really well.


NukeWorker.com

It would be nice to have thebar graph next to it, like the rest of the page.  It would fit in better.

HaVaNa7

Quote from: NukeWorker.com on April 17, 2005, 03:27:30 PM
It would be nice to have thebar graph next to it, like the rest of the page.  It would fit in better.
???
Anybody knows how?

Dannii

I've got the graph working, and I'll post it once it's perfect.

The <table> stuff should be moved outside of the foreach.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Xarcell

I installed the mod using teh directions from the first post. It works, however top karma guy is -10. How's that? What do I need to do tto fix that. I know nothing about php...

-Xarcell

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Advertisement: