Best approach for designing framework for badge assigning system
===

I am currently designing one education site. 
For this we need to assign some badges to user based on their activity (like stackoverflow) . 
I was looking for a framework for this. Any one have any idea ,how this can be done ? Table design etc. 

Issues which i could think of with this are :

1) We may have large number of badges ,so on each action of user we can not check all badges and check if any badge can be assigned
2) On adding a new badge and criteria for this ,i dont want to change the existing code to handle this ( can we have some generic solution. )
3.) which db should i choose ( lets say if my framework in like ,it raises the event when criteria for one badge satisfies and these rules are created in  DB(like sql) . or can i go for nosql db (like mongodb as my rest of the project is in mongodb )  

My initial search gave me following things

1) rule engine  --> will result in very tedious task  http://stackoverflow.com/questions/1049233/database-architecture-for-badge-system-arbitrary-criteria-mysql-php
2) One project  -> http://drupal.org/project/user_badges ( not able to understand it properly) 
3) people are saying ur table structure should be like this nd this ..and all ..
http://stackoverflow.com/questions/522943/best-way-to-store-badge-criteria
http://stackoverflow.com/questions/8364187/creating-badges-for-my-site-best-way-to-store-user-badges-using-php

Any help ..