Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4605258
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:24:27+00:00 2026-05-22T00:24:27+00:00

So I’m wanting to setup an achievements system on my site. People perform tasks

  • 0

So I’m wanting to setup an achievements system on my site. People perform tasks and upload this information which is then stored in a database (think ‘time’, ‘date’, ‘task’, etc.). What would be the best method of checking their information and awarding achievements? Would I just have like an achievement.php that once information is uploaded it would trigger this document to run through all the checks to determine if the user needs to be awarded an achievement? Or is there something server side I should set up to award the user?

Thanks for any help or suggestions, comments, etc. 😀

EDIT: I currently have the achievements listed in the database, (id, name, class)

Tasks are stored as (‘date_time’,’time’,’device’,’user_id[fk]’)

EDIT 2: Also many achievements will be calculated based on not only the tasks the user is currently submitting but takes into account previous tasks in addition to the newly added task. EX: If the user has completed 3 tasks within 3 consecutive days, then they will be awarded for it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:24:28+00:00Added an answer on May 22, 2026 at 12:24 am

    it really depends on where your preference for business logic placement lies, and how real time you want acheivements to be. if you’re looking to offload a bunch of business logic on you sql server, put it in a stored procedure, otherwise, class out the calculations into a class in php, and use that class to determine what new achievements have been.

    i would definitely suggest doing the processing outside of the normal page response. perhaps kick off a server-side call to the php cli, or set up a cron job to run all individuals through a check for achievements at a certain interval.

    edit:

    as for the actual methods of awarding achievements, i would think you’re most flexible and simple implementation (you will find more simple/less flexible and more flexible/less simple options i’m sure) would be to create an AwardRunner class, an IAward interface and a bunch of individual implementations of IAward for each award you have. the basic idea would be something like:

    <?php
        class AwardRunner {
            var $UserId = 0;
    
            function AwardRunner($userId) {
                $this->UserId = $userId;
    
                $dir = "/path/to/your/folder/full/of/IAwards/";
                $includes = read_dir($dir);
    
                //include all files that exist
                foreach($includes as $include)
                {
                    if (is_file($include))
                    {
                      require($include);
                    }
                }
            }
    
            public function Run() {
                $classList = get_declared_classes();
    
                foreach($classList as $key => $className)
                {
                    if (in_array('IAward', class_implements($className))) {
                        $award = $className();
                        $award->UserId = $this->UserId; 
                        $award->GrantIfUserQualifies();
                    }
                }
    
            }
    
            //function for reading all files in a directory.
            //this is recursive, so any files in subfolders will also make it in
            function read_dir($dir) 
            {
                $array = array();
                $d = dir($dir); 
                while (false !== ($entry = $d->read())) {
                    if($entry!='.' && $entry!='..') {
                        $entry = $dir.'/'.$entry;
                        if(is_dir($entry)) {
                            $array = array_merge($array, read_dir($entry));
                        } else {
                            $array[] = $entry;
                        }
                    }
                }
                $d->close();
                return $array;
            }   
    }
    ?>
    

    i would think the idea of what the IAward interface would look like would be pretty clear from the usage, though you’d probably add to it the Id field from your table so it would be able to insert itself into the database, as would the way to call the AwardRunner class.

    this idea should work whether you have something batching the awards process looping through all your users, or just fire it off after every task submission.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.