How to implement challenges with prizes in a Drupal site? I've been working on a Drupal Commerce site where you can buy goods with points. Users gain those points with a system I already implemented. Everything is fine, but now I have to implement challenges.

Basically, the users will need to "follow" the challenge, then every point they gain from that moment will fill their point meter of the challenge. Every user who reaches the point limit (specified when the challenge is created) will win a prize.

How can I do this? I was told that I could use the Flag module for the following part, but I'm really clueless.
Your question seems like a perfect usecase for the Goals module (disclosure: I'm its maintainer). It can be used in combination with the User Points module, though you'd use that combination by granting user points "after a goal is completed". 
Read on for a possible configuration for your specific case.

Configure the goals

Define some goals, with a description (say) like so:


Challenge 1
Challenge 2
Challenge 3


For each goal you may optionally associated some image with it, which are typically used to visualize the goals completed by a user.

And after a goal is completed, you can (optionally) automatically grant a predefined amount of user points to the user who completed the goal.

Configure the tasks


To achieve goal "Challenge 1", define the Task(s) to be completed. E.g.:


Publish 1 (or some other amount of) articles.
Post 1 (or some other amount of) comments.

To achieve goal "Challenge 2", define the Task(s) to be completed. E.g. publish 10 articles and post 20 comments.
To achieve goal "Challenge 3", define the Task(s) to be completed. E.g. publish 25 articles and post 50 comments.


Advanced task configuration

A more advanced way to use (configure) Goals, is to configure tasks like so:


there could be multiple tasks to be completed for a single goal.
some tasks might have to be repeated multiple times.
some tasks might have to happen within a given timeframe.
some tasks may require some amount of time to expire in between any 2 similar tasks.


Track progress while performing tasks

To track the progress made by a single user to complete some task, you only have to write the appropriate rules, using the Rules module, to record relevant events happening in your site, which are related to the completion of the various tasks.

For the goals/tasks described above as an example, you'd only need 2 (extremely basic) rules, which would be triggered like so:


After publishing an article.
After posting a comment.


Note that these 2 rules can be re-used to measure progress on each of the 3 goals.

Moreover, the above challenges are pretty straight forward (basic) as examples of Challenges. But you can do this for virtually any entity for which you can think of a way to track them via the rules module.

Process completed goals

After all tasks specific to a goal are completed by a user, the goal is automagically marked as completed. And the user points related to completing that goal will be rewarded.

If you want, you can also create additional rules that will be triggered (Rules Event) when a goal is completed by a user.

More info

Refer to my answer to "How to implement gamification in a Drupal site and award incentives?" for additional details about the Goals module.

Note: Using Goals only requires typical administration tasks (configuration), though it does come with various hooks also for custom module development (if you want to).