Ranking block

Blocks ::: block_ranking
Maintained by Willian Mano Araújo
A ranking block to improve the gamification into the course.
Latest release:
1664 sites
96 fans
Current versions available: 3

Moodle Ranking block repository


This block is and will remain free, but your donation allows me to continue the development, and any amount is greatly appreciated.

Imagem com link para doação

This block improves gamefication into the moodle plataform.

This new version is more simpler and easy to use, but, with more visual.

The plugin works listening moodle events, so now, the points are added in real time.

The ranking works with the activity completion tracking, so you need to enable that and configure the criterias for all activities you want to monitor. The plugin only add points to activities with completion criterias. The method to add points remains the same.

There are different ways to gain points.

For example:

  • If a student completes a html page the ranking adds 2 points.
  • If a student completes an assignment and it is ended only when the student receive a grade. The ranking add 2 points plus the grade points to the student. You can configure the default points in the block configuraion.

NOTE: All the activities that needs grade to be finished will add the activity points (default 2) more the activity grade. For example: If the course has one assignment and it's configured to be completed only after the grade is received by the student and let's say a random student received by the end of the assignment 10(ten) as his grade. In this case that student will obtain 12(twelve) points, the 2(two pre-configured) from finishing the activity plus 10(ten) from his grade.

This only occurs with activities that have grades. ex: foruns, assignments, lessons, etc...

For Moodle version 3.2+ 

With the new chart api in moodle version 3.2 i added some graphs to see the groups performance. Enjoy and feel free to send me your feedback.

Update Notes

  • Added graphs page
  • Added event listeners to add point
  • Removed cron dependency
  • Added a weekly ranking
  • Added a monthly ranking
  • Added a tiny report with top 100 students in general ranking
  • Added filter the tiny report by groups (the course group mode needs to be "separeted groups" or "visible groups")
  • Now you don't need configure the course completion tracking, only the activities completion criterias. Again, the plugin only monitors the activities with completion criteria
  • The table ranking_cmc_mirror was removed.


First way

  • Clone this repository into the folder blocks.
  • Access the notification area in moodle and install

Second way

  • Download this repository
  • Extract the content
  • Put the folder into the folder blocks of your moodle
  • Access the notification area in moodle and install

Post instalation

After you have installed the block you just add it into the moodle course.

The ranking block works together with the activity completion, so you need to enable that and configure the criterias for all activities you want to monitor. The ranking block monitors these activities and add points to the students based on accomplishing the activities.

Enabling completion tracking

  • Go to: Site administration / Advanced features
  • Turn on the item "Enable completion tracking"
  • Inside the course go to: Course administration / Edit settings
  • In the section Completion tracking set "Completion tracking" to yes
  • Save


Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4
Screenshot #5
Screenshot #6


Willian Mano Araújo (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS


  • Thu, Jun 11, 2015, 8:33 PM
    Thank you for your reply Willian. Yes, it makes perfect sense in terms of engagement after course is completed. However, one of the situations might be is that student who understood all the material well and have passed a quiz, for example, 100/100 from the first attempt might be not interested in passing the same quiz again, as they already great in this material.

    However, those who failed to gain 100 in the quiz for the first time would attempt it again, and, as a result, gain more points than those, who have done great from the first attempt. And as a result those, who failed first attempt and took another one would be higher in a ranking than those who performed better.

    Hope I made myself clear :D

    But thanks again for the great plugin!


  • Thu, Jun 11, 2015, 9:10 PM
    Yeah, i understood you. This is a good debate. In the first release of the version 2, the block added points only one time for each quizz, i changed to add multiple times.

    I can implement a global configuration to enable/disable add points for multiple attempts.
  • Thu, Jun 11, 2015, 9:40 PM
    Oh that would be just perfect! Thank you so much! You're the best smile
  • Wed, Jun 17, 2015, 10:00 PM
    Does the multiple attempts also apply to SCORM packages and Games? When I tested it about a month ago, it only gave points the first time a student attempted a SCORM or game. I would want it to grant points every time they attempt it. Since SCORMS and games don't really grant points, the only points students can accumulate from them are through the "attempts" (Playing them). Having students playing the games (either Moodle games or SCORM packages), they reinforce their formal learning and should be able to earn points. If they want more points, they can play the games over and over again. Currently, you can set a minimal score in the SCORM / Game before it is marked as complete, to prevent kids from just guessing through them to get the points.
  • Fri, Aug 14, 2015, 5:11 AM
    Hey maxim, i implemented a global configuration to allow or disallow add points to multiple attempts in quizzes.
  • Fri, Aug 14, 2015, 5:12 AM
    I've solved a very important BUG in how to save grades. Download the newest version to fix it.
  • Sudeep
    Tue, Sep 22, 2015, 5:41 PM
    I've solved a very important BUG, how to take the actual rank set from admin/settings.php .

    Issue was: No matter what you set for each activity, it takes the default point hard coded in the source ie 2.
    File: classes/manager.php
    Method: add_default_points
    Change: trim($points) != ' ' ... to ... trim($points) == ' '
  • Thu, Sep 24, 2015, 11:14 AM
    Help please.
    The Ranking Block isn't working on my site 2.6. Installed fine without errors but doesn't update when assessments are graded.
    Have I missed a step?
  • Fri, Sep 25, 2015, 8:12 AM
    I've checked the cron job and it doesn't appear to be running the Ranking Block. This must be the problem, but I can't see how to fix this. I've enabled completion tracking, set up assessments as per video on youtube and no success. I install, uninstalled, going around in circles...
  • Wed, Sep 30, 2015, 1:27 AM
    Hey tanya, sorry for not answer before.

    The new version of the plugin uses the events of moodle. The cron is not necessary anymore. I will remove the video from youtube.

    Are you using moodle 2.6, can send me more information about your server enviroment, like database, php version...
  • Wed, Sep 30, 2015, 8:06 PM
    Hi William,

    I have the same problem as Tanya. My moodle version is 2.6.11+, my server works with database Mysql version 5.1.56 and PHP version 5.6.5. I installed the last version of your plugin and I followed all the instructions you indicate above.

    Best regards
  • Sat, Oct 3, 2015, 1:47 AM
    Great work, Willian! One question:

    I installed the Ranking Block this week (works perfectly).

    However, it seems to only recognize tasks completed SINCE it was installed. Is there a way to update the rankings with ALL of the course data, or to refresh the course data to register on the ranking block?

    Thank you,
    William Michael
    Classical Liberal Arts Academy
  • Thu, Nov 5, 2015, 5:19 AM
    Hi, Looks like a great plug-in. Thanks for this and all of the follow up. I was wondering if there is any plug-in that would show a team's aggregate points in a leader board. So rather than individual grades and points placing one person at top of the class (or the bottomsad ) a team could be working together to beat another team. This could still have the motivation of gamification but not the negative of reinforcing the negative experiences.
  • Fri, Nov 13, 2015, 1:12 AM
    Hi there,
    It works like a charm, my students love it. Thank you. Can I make a ranking block for several certain courses? If so, how can I make it?
    Thank you,
  • Thu, Nov 19, 2015, 1:19 AM
    Quando adiciono o bloco na página do curso simplesmente gera um erro ao ler base de dados.
    No debug deu o seguinte:

    Debug info: ERRO: coluna "u.picture" deve aparecer na cláusula GROUP BY ou ser utilizada em uma função de agregação
    LINE 2: DISTINCT u.id,u.picture,u.firstname,u.lastna...
    DISTINCT u.id,u.picture,u.firstname,u.lastname,u.imagealt,u.email,u.username,
    sum(rl.points) as points
    mdl_user u
    INNER JOIN mdl_role_assignments a ON a.userid = u.id
    INNER JOIN mdl_ranking_points r ON r.userid = u.id AND r.courseid = $1
    INNER JOIN mdl_ranking_logs rl ON rl.rankingid = r.id
    INNER JOIN mdl_context c ON c.id = a.contextid
    WHERE a.contextid = $2
    AND a.userid = u.id
    AND a.roleid = $3
    AND c.instanceid = $4
    AND r.courseid = $5
    AND rl.timecreated BETWEEN $6 AND $7
    GROUP BY u.id
    ORDER BY points DESC, u.firstname ASC
    LIMIT 10
    [array (
    0 => '5',
    1 => '1346',
    2 => 5,
    3 => '5',
    4 => '5',
    5 => 1447545600,
    6 => 1447852189,
    Error code: dmlreadexception
    Stack trace:

    line 407 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 239 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
    line 708 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
    line 135 of /blocks/ranking/lib.php: call to pgsql_native_moodle_database->get_records_sql()
    line 83 of /blocks/ranking/block_ranking.php: call to block_ranking_get_students_by_date()
    line 281 of /blocks/moodleblock.class.php: call to block_ranking->get_content()
    line 232 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
    line 937 of /lib/blocklib.php: call to block_base->get_content_for_output()
    line 989 of /lib/blocklib.php: call to block_manager->create_block_contents()
    line 352 of /lib/blocklib.php: call to block_manager->ensure_content_created()
    line 5 of /theme/ftecflorense/layout/default.php: call to block_manager->region_has_content()
    line 768 of /lib/outputrenderers.php: call to include()
    line 715 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
    line 232 of /course/view.php: call to core_renderer->header()

    O que posso fazer pra resolver?
Please login to post comments