Notes with Ravinder on Badging System Development Part II


 
Thread Tools Search this Thread
Top Forums Web Development Notes with Ravinder on Badging System Development Part II
# 1  
Old 01-02-2019
Another one bites the dust.... prototype badge "discussions started in the last month" ...

Code:
<?php
$monthtq = "SELECT COUNT(threadid) AS threadcount from thread where firstpostid=" . $uid . " and  dateline > " . $one_month_ago;
$monththreads = $vbulletin->db->query_first($monthtq);
if ($monththreads['threadcount'] >= 4) {
    $color['faterminal'] = 'black';
} elseif ($monththreads['threadcount'] >= 5) {
    $color['faterminal'] = 'indigo';
} elseif ($monththreads['threadcount'] >= 2) {
    $color['faterminal'] = 'blue';
} elseif ($monththreads['threadcount'] >= 1) {
    $color['faterminal'] = 'limegreen';
} else {
    $color['faterminal'] = 'lightgray';
}

$badgejs .= 'badge["faterminal"] = "' . $color['faterminal'] . '";';
$badgejs .= 'badge["faterminalval"] = "' . number_format($monththreads['threadcount']) . '";';

jQuery:

Code:
$('.fa-terminal').css("color",badge["faterminal"]);
$('.fa-terminal').css("cursor","pointer").attr("title",  badge["faterminalval"] + " Discussions Started in the Last Month");
$('.fa-terminal').closest('div').find('.fa-circle').css("color",badge["faterminal"]);

9 out of 48 protos left .. Smilie
# 2  
Old 01-02-2019
OK... prototype "thanks per month" badge is done:

Code:
$thanksmq = "SELECT SUM(post_thanks_amount) AS monthlythanks from post where userid=" . $uid . " and  dateline > " . $one_month_ago; 
$monththanks = $vbulletin->db->query_first($thanksmq); 
if ($monththanks['monthlythanks'] >= 10) { 
    $color['farocket'] = 'black'; 
} elseif ($monththanks['monthlythanks'] >= 5) { 
    $color['farocket'] = 'indigo'; 
} elseif ($monththanks['monthlythanks'] >= 2) { 
    $color['farocket'] = 'blue'; 
} elseif ($monththanks['monthlythanks'] >= 1) { 
    $color['farocket'] = 'limegreen'; 
} else { 
    $color['farocket'] = 'lightgray'; 
} 

$badgejs .= 'badge["farocket"] = "' . $color['farocket'] . '";'; 
$badgejs .= 'badge["farocketval"] = "' . number_format($monththanks['monthlythanks']) . '";';

jQuery:

Code:
$('.fa-rocket').css("color",badge["farocket"]);
$('.fa-rocket').css("cursor","pointer").attr("title",  badge["farocketval"] + " Thanks in the Last Month");
$('.fa-rocket').closest('div').find('.fa-circle').css("color",badge["farocket"])

I think that leaves 7 proto-badges to go ... Smilie
# 3  
Old 01-02-2019
Also, light press on mobile gives info on each badge:

Image
# 4  
Old 01-02-2019
Ravinder,

Please write the logic for the "current number of consecutive days active on the forums" ....

If you need a new MySQL table please specific the table definition and I will create it.

Thanks!
# 5  
Old 01-02-2019
Quote:
Originally Posted by Neo
Ravinder,
Please write the logic for the "current number of consecutive days active on the forums" ....
If you need a new MySQL table please specific the table definition and I will create it.
Thanks!
Thanks a TON Neo for coding all these badges,sorry I am not having proper access in office(only IE is there so not able to perform anything).

For writing logic for consecutive days one,is it ok if I first present logic rather than code(as I know php which I learnt from you in last few days, I know I could write logic for it. Please do give me an hour or so I will write it here.

EDIT: Also request you to edit string so that it will be clear that people received THANKS from others, may be as follows. Ahhh if I would have access in office today I would have tried to write 1 of them.

Code:
$('.fa-rocket').css("cursor","pointer").attr("title",  badge["farocketval"] + " Thanks received in the Last Month");


Thanks,
R. Singh

Last edited by RavinderSingh13; 01-02-2019 at 08:51 AM..
This User Gave Thanks to RavinderSingh13 For This Post:
# 6  
Old 01-02-2019
Quote:
Originally Posted by RavinderSingh13
For writing logic for consecutive days one,is it ok if I first present logic rather than code(as I know php which I learnt from you in last few days, I know I could write logic for it. Please do give me an hour or so I will write it here.
No. Hurry.

Take your time. Glad you like the three new badges... Smilie
# 7  
Old 01-02-2019
Quote:
Originally Posted by Neo
No. Hurry.
Take your time. Glad you like the three new badges... Smilie
Hey Neo,

Following will be my approach in order to get consecutive days BADGE's creation.

Step 1st: Create a field named daily_login_count in user TABLE(mysql).
Step 2nd: Now whenever user logs in to forum then check condition if (TODAY's date-1)==lastvisit(fied value) then add 1 in daily_login_count.(I know this method should be invoked when user is clicking on LOGIN button and able to successfully login Smilie )
Step 3rd:
i- Now check if value of daily_login_count>=1 && daily_login_count<14 then BADGE color should be orangered.
ii- Check if value of daily_login_count>=14 && daily_login_count<30 then BADGE color should be darkorange.
iii- Check if value of daily_login_count>=30 && daily_login_count<60 then BADGE color should be lightgray.
iv- Check if value of daily_login_count>=60 && daily_login_count<90 then BADGE color should be limegreen.
v- Check if value of daily_login_count>=90 && daily_login_count<120 then BADGE color should be blue.
vi- Check if value of daily_login_count>=120 && daily_login_count<150 then BADGE color should be indigo.
vii- Check if value of daily_login_count>=150 && daily_login_count<180 then BADGE color should be black.

Step 4th: In case condition 2nd is NOT TRUE means user is logging after some days then make daily_login_count=1 and change BADGE color to red.

Thanks,
R. Singh

Last edited by RavinderSingh13; 01-02-2019 at 10:22 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

Badging System: UNIX.COM Bug Hunter Badge (New)

I have moved the bug badge out of reserve and into the main stream. Basically, I will assign a color level like the others, based on who has made a good actionable bug report for UNIX.COM. "Good" means screenshots, links, and even details from web dev tools our the HTML source code. So far,... (0 Replies)
Discussion started by: Neo
0 Replies

2. What is on Your Mind?

Status of Badging System - Beta 1

Dear All, Here is the current status of the badging system: The Beta 1 phase of the new badging system is close to completion. 42 prototype badges have been "allocated" 6 prototype badge slots are held in reserve The "alert you have new badges" prototype is running and is currently... (4 Replies)
Discussion started by: Neo
4 Replies

3. What is on Your Mind?

New Badging System - Badges Prototype Beta 1 (Badges Only)

Today I mapped out the new badging system using FA icons, Beta 1 in no particular order except a 6 x 8 grid: https://www.unix.com/members/1-albums215-picture991.png The prototype HTML code for this layout: <style> .fa-badge-grid { font-size: 1.5em; } .row { ... (38 Replies)
Discussion started by: Neo
38 Replies
Login or Register to Ask a Question