Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+22 votes
10.5k views
in Plugins by
edited by
Just wondering whether someone else has already made headway on a badges plugin.  I've created a working prototype with a single badge that creates two databases, one for badge types, one for user-earned badges, checks for whether a badge is warranted on an event, awards the badge, and stores a notify flag, giving a notice when the recipient loads a page.  It also implements a table on the user profile page to show which badges have been earned, and number of each.
by
Badge widget not displaying correctly at two places

Plugin Options:
1- Show badge widget beside points in user meta
(does not show up)
2- Show badge widget beside points in question list
gives an error something like Undefined index:  .......qa-include/qa-app-format.php(1466) : eval()'d code - at user profile in recent activity questions.
Also page for badges is not displaying correctly.

I am using latest version of this plugin with Q2A 1.5.4.

Great great plugin but needs fixes.

Thanks
by
same here in 1.5.4

27 Answers

0 votes
by

Hi  NoahY,

I saw that you created a Badge Plugin, with a lot of features. I am required to develop a similar functionality for our site running Q2A (http://answerit.in/).

I have two queries:

  1. What about the Licensing information? Can we use your Plugin and/or modify its code to suit our requirements?
  2. If yes, Can you tell me which version can we use for the same?

It will be a great help if we can use your plugin, rather than designing one from the scratch for our purpose. The purpose is very simple. We wanted an Admin interface to award Points to User, depending on the quality of their answer (not the flat way it is done automatically). But since it would have meant changing the Q2A code at some level, we decided to make a separate plugin for that. Seeing similar facilities on some other sites, we decided to make a Badge Plugin instead.

I guess your plugin suit our requirements to a great deal. So I am waiting for a reply from your side.

Thanks and Regards,

Saurabh

by
The README states it is Copyleft which means yes you can modify it to your requirements. See http://en.wikipedia.org/wiki/Copyleft for more details.
by
edited by
Thanks a lot :)

I saw all the badges present in the current version, but my problem is a bit different. Can you explain if its possible to add a Custom Badge, which say, uses information from a new Table (with two columns, User Id and say some integer value). I may assign it a Level (Gold, Silver or Bronze), and the rest is just the same.
by
Of course, what good would code be if people couldn't use it?  Do what you like :)

I'm moving towards using the ^usermeta table for the kinds of thing you talk about; I think Gideon is going to make it an official part of Q2A 1.5, and I've already implemented it in two plugins (bookmarks and theme-switcher).  For now, though, the badges has an "achievements" table that collects various info like that.

Adding custom badges is pretty straightforward, but you have to know where to put the check in; is it on an event that you want to check?  Then use qa-badge-check.php.  If it is on every page view, then my checks are in qa-badge-layer.php.  You should include a custom copy of the check in qa-badge-admin.php as well in order to allow for manual (site-wide) badge re-awarding.  Then all you have to do is add the new badge to the list in qa-plugin.php including your integer variable, and it should integrate well.  

Another thing I would say, since this has been mentioned by Scott as well, is that it would be great if when people did come up with neat ideas for new badges, they shared them with the rest of us (i.e. me) and we put them in this plugin as well, since all badges are optional (you can disable them one by one).
by
Thanks a lot NoahY,
Actually we want to implement badges on automatic as well as Manual Basis.
So, the Badges you've already implemented are all great, and I think we can use most of them. But suppose the Moderator is interested in awarding an Answerer, that may not have received too many Vote Ups, but is actually a very nice and to-the-point answer !!
For this, we should have a hook somewhere in the Code, that can allow, awarding of Extra Badges Manually.
Of course, the Current Point System in Q2A and the Badge Awarding system in your plugin, do this automatically, by doing some calculations on the Votes, Comments and Questions. How about having a Table, just like you mentioned, where we have a UserId -> {Set of Manual Badges} mapping, which can be added to the actually calculated badges (we may call them as "Offsets").
I was looking through your code yesterday and understood most of the part. I'll continue with the same. If I manage to implement what I am thinking about, I'll share the code with you, so that anyone wishing to do  the same is benefited.
+2 votes
by
edited by
Hi

Thanks a lot for making this badge plugin. It really rocks
+2 votes
by
Please don't stop developing this plugin. I have a few questions:

Is there a way to check if the user added an avatar, or has filled out all fields on profile page?

Thank you very much for your hard work that you did on this plugin.
by
Yes, it looks like both are possible, via the u_save check.  Have to figure out where these values are saved... I use WP integration, so I am not familiar with the profile fields.
by
Okay, you want to try the latest code and let me know if it works?  Try two ways, first by filling in the profile fields and adding an avatar manually, and second by going to admin/plugins and press "Recheck Badge Awarding".  Both ways should award the badges.

(also, make sure you activate the two new badges first...)
by
reshown by
It works fine when I add avatar manually, but when I do "mass recheck badge awarding" it doesn't award them for avatar and completed fields. the function doesn't seem to get called when i click rechek badges.
by
edited by
Ok I have no idea why the function doesn't work, everything looks good but it doesn't work from the admin page.

Update :

Ok I managed to fix this:

in qa-badge-admin.php line 835-839 move that list  stuff into the while loop so that $userid id would be defined.
by
Thanks, nice catch :) fixed now.
+2 votes
by

Update:

added gradient to default css:

if you don't want to reset the options, just replace the following css declarations:

.badge-bronze {
    background-color: #CB9114;

    background-image: -webkit-linear-gradient(left center , #CB9114, #EDB336, #CB9114, #A97002, #CB9114);
    background-image:    -moz-linear-gradient(left center , #CB9114, #EDB336, #CB9114, #A97002, #CB9114);
    background-image:     -ms-linear-gradient(left center , #CB9114, #EDB336, #CB9114, #A97002, #CB9114);
    background-image:      -o-linear-gradient(left center , #CB9114, #EDB336, #CB9114, #A97002, #CB9114);
    background-image:         linear-gradient(left center , #CB9114, #EDB336, #CB9114, #A97002, #CB9114); /* standard, but currently unimplemented */

    border:2px solid #6C582C;
}                
.badge-silver {
    background-color: #CDCDCD;
    background-image: -webkit-linear-gradient(left center , #CDCDCD, #EFEFEF, #CDCDCD, #ABABAB, #CDCDCD);
    background-image:    -moz-linear-gradient(left center , #CDCDCD, #EFEFEF, #CDCDCD, #ABABAB, #CDCDCD);
    background-image:     -ms-linear-gradient(left center , #CDCDCD, #EFEFEF, #CDCDCD, #ABABAB, #CDCDCD);
    background-image:      -o-linear-gradient(left center , #CDCDCD, #EFEFEF, #CDCDCD, #ABABAB, #CDCDCD);
    background-image:         linear-gradient(left center , #CDCDCD, #EFEFEF, #CDCDCD, #ABABAB, #CDCDCD); /* standard, but currently unimplemented */
    border:2px solid #737373;
}                
.badge-gold {
    background-color: #EEDD0F;
    background-image: -webkit-linear-gradient(left center , #EEDD0F, #FFFF2F, #EEDD0F, #CCBB0D, #EEDD0F);
    background-image:    -moz-linear-gradient(left center , #EEDD0F, #FFFF2F, #EEDD0F, #CCBB0D, #EEDD0F);
    background-image:     -ms-linear-gradient(left center , #EEDD0F, #FFFF2F, #EEDD0F, #CCBB0D, #EEDD0F);
    background-image:      -o-linear-gradient(left center , #EEDD0F, #FFFF2F, #EEDD0F, #CCBB0D, #EEDD0F);
    background-image:         linear-gradient(left center , #EEDD0F, #FFFF2F, #EEDD0F, #CCBB0D, #EEDD0F); /* standard, but currently unimplemented */
    border:2px solid #7E7B2A;
}

Update:

added badge widget (requires event logging to database):

 

by
My badges don't look that pretty (no gradient). What am I doing wrong? I tried to copy paste the CSS above into the admin panel, no change.
+2 votes
by

UPDATE:

added ability to add custom badges via plugins.  see the github readme for more information on how to create custom badge awarding within your plugin:

https://github.com/NoahY/q2a-badges/tree/#readme

0 votes
by
edited by

Is anyone tester badge plugin with 1.5 beta 1 ? Is it should work properly ?

By the way i know it's not harmfull but i getting notice after turining error reporting on:

 

Notice: Undefined offset: 2 in /x/x/x/xl/qa-include/qa-app-format.php(1264) : eval()'d code on line 60
 
Notice: Undefined offset: 2 in /x/x/x/xl/qa-include/qa-app-format.php(1264) : eval()'d code on line 60
 
Notice: Undefined offset: 2 in /x/x/x/xl/qa-include/qa-app-format.php(1264) : eval()'d code on line 60
 
Notice: Undefined offset: 2 in /x/x/x/xl/qa-include/qa-app-format.php(1264) : eval()'d code on line 60
 
In every question in answer. Don't know if it's badge plugin's foult.
by
hehe.  it's not an error message, it's a debug notice.  better to turn them off, they're just to let developers know in case the index had to be set for the function to work.  I'll edit it to suppress that.

The widget was an actual bug... fixed now in latest code, thanks for catching that.
by
ok the bug - do i just upload all the files again, one file, change some code... I don't want to screw it up.. Oh how to turn debug off
by
thanks soooo much for this plugin :) its so cool! i have added to my site :) why is this not in the q2answer plugin area yet?
by
That's funny, I'm not sure why it is not there... maybe I never asked Gideon to add it.  I've sent word to him now.  Thanks for the feedback.
0 votes
by
Hi, NoahY

I used your Badge Plugin and feel so happy with this. Anyway, I just want to report a small bug: I have more than 100 badges (on my own Q2A website) but I don't receive the badges for that. I should have: Medalist, Champian & Olympian badges instead.
+2 votes
by
Just on a side-note, I don't know if anyone said this already, but Noah, YOU'RE DA MAN!!!!
0 votes
by

I am getting an error on the "Recent Badge Widget"

The name of the Badge in Widget are not showing properly.

 

I am using the latest Badges v3.6

by
But when I use the version 3.3  is working fine.
0 votes
by
Wonderful Plug in ! ! !

There is a way to have a list of users classified in order to the amount of badges..

in this oltmpic time it would be intersting to have this list on our sites that use this great plug in.

It would be PERFECT if we can add others badges related to others actions.

Thanks to ALL those has developed and perfected this
0 votes
by

Hi NoahY, I've just tryed installing your badges plugin, and it looks great, except the names all have "badges/" as a prefix.

I have the very latest Q2A and cloned the badges folder from GitHub, and placed it in my qa-plugin folder. Not sure if it's a bug or I've somehow done it wrong. How can I fix this?


by
I'm getting the exact same problem.
by
Try resetting badge names in admin...
by
That done the trick, thank you very much.
by
Works for me too, thanks
0 votes
by

*Show badge widget beside points in user meta
*Show badge widget beside points in question list

options won't work if a username contains space.

example: "test user"

url of user's profile: example.com/qa/user/test+user

The line below should be modified to include spaces (or +) in usernames as well (qa-badge-layer.php):

$handle = preg_replace('|.+user/([^"]+)".+|','$1',$post['who']['data']);

 Can you please provide a fix?

Thanks

...