├── .travis.yml ├── CHANGES.md ├── LICENSE ├── README.md ├── block_game.php ├── classes ├── output │ ├── block.php │ ├── profile.php │ ├── profilecourse.php │ └── renderer.php ├── privacy │ └── provider.php └── task │ └── cleargame.php ├── db ├── access.php ├── install.xml ├── tasks.php └── upgrade.php ├── download.php ├── edit_form.php ├── game.php ├── help_game.php ├── lang ├── en │ └── block_game.php └── pt_br │ └── block_game.php ├── lib.php ├── perfil_gamer.php ├── pix ├── .DS_Store ├── a0.svg ├── a1.svg ├── a10.svg ├── a11.svg ├── a12.svg ├── a13.svg ├── a14.svg ├── a15.svg ├── a16.svg ├── a17.svg ├── a18.svg ├── a19.svg ├── a2.svg ├── a20.svg ├── a21.svg ├── a22.svg ├── a23.svg ├── a24.svg ├── a25.svg ├── a26.svg ├── a27.svg ├── a28.svg ├── a29.svg ├── a3.svg ├── a30.svg ├── a31.svg ├── a32.svg ├── a33.svg ├── a34.svg ├── a35.svg ├── a36.svg ├── a37.svg ├── a38.svg ├── a39.svg ├── a4.svg ├── a40.svg ├── a41.svg ├── a42.svg ├── a43.svg ├── a44.svg ├── a45.svg ├── a46.svg ├── a47.svg ├── a48.svg ├── a49.svg ├── a5.svg ├── a50.svg ├── a51.svg ├── a52.svg ├── a53.svg ├── a54.svg ├── a55.svg ├── a56.svg ├── a57.svg ├── a58.svg ├── a59.svg ├── a6.svg ├── a60.svg ├── a61.svg ├── a62.svg ├── a63.svg ├── a64.svg ├── a65.svg ├── a66.svg ├── a67.svg ├── a68.svg ├── a7.svg ├── a8.svg ├── a9.svg ├── badge.svg ├── badgex.svg ├── help.svg ├── help_progress_level.svg ├── icon.svg ├── info.svg ├── level.svg ├── lv0.svg ├── lv1.svg ├── lv10.svg ├── lv11.svg ├── lv12.svg ├── lv13.svg ├── lv14.svg ├── lv15.svg ├── lv2.svg ├── lv3.svg ├── lv4.svg ├── lv5.svg ├── lv6.svg ├── lv7.svg ├── lv8.svg ├── lv9.svg ├── rank.svg ├── rank_group_list.svg ├── rank_list.svg ├── reset.svg └── score.svg ├── rank_game.php ├── rank_group_game.php ├── reset_points_course.php ├── set_avatar_form.php ├── settings.php ├── templates ├── block.mustache ├── profile.mustache └── profilecourse.mustache └── version.php /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | os: linux 4 | dist: xenial 5 | sudo: false 6 | 7 | services: 8 | - mysql 9 | - postgresql 10 | - docker 11 | 12 | cache: 13 | directories: 14 | - $HOME/.composer/cache 15 | - $HOME/.npm 16 | - $HOME/.nvm 17 | 18 | jobs: 19 | include: 20 | - php: 7.4 21 | env: MOODLE_BRANCH=master DB=pgsql 22 | - php: 7.4 23 | env: MOODLE_BRANCH=master DB=mysqli 24 | - php: 7.4 25 | env: MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql 26 | - php: 7.4 27 | env: MOODLE_BRANCH=MOODLE_39_STABLE DB=mysqli 28 | - php: 7.4 29 | env: MOODLE_BRANCH=MOODLE_38_STABLE DB=pgsql 30 | 31 | - php: 7.3 32 | env: MOODLE_BRANCH=master DB=pgsql 33 | - php: 7.3 34 | env: MOODLE_BRANCH=master DB=mysqli 35 | - php: 7.3 36 | env: MOODLE_BRANCH=MOODLE_37_STABLE DB=pgsql 37 | - php: 7.3 38 | env: MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli 39 | 40 | - php: 7.2 41 | env: MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql 42 | - php: 7.2 43 | env: MOODLE_BRANCH=MOODLE_39_STABLE DB=mysqli 44 | - php: 7.2 45 | env: MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql 46 | 47 | - php: 7.1 48 | env: MOODLE_BRANCH=MOODLE_38_STABLE DB=pgsql 49 | - php: 7.1 50 | env: MOODLE_BRANCH=MOODLE_37_STABLE DB=mysqli 51 | - php: 7.0 52 | env: MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli 53 | - php: 7.0 54 | env: MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql 55 | 56 | # Cannot test with Moodle 3.2 and 3.3 any more because the new composer 2 57 | # does require all components to be named properly (case-sensitively) and 58 | # those branches have phpunit/Dbunit, failing. See MDL-64725. 59 | 60 | # Cannot test with PHP 7.0 any more because we are now using the :void return type. 61 | # Note that, still, the plugin will work ok, it's just the phpunit tests which cannot 62 | # be executed with that PHP versions. 63 | 64 | before_install: 65 | - phpenv config-rm xdebug.ini 66 | - cd ../.. 67 | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 68 | - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" 69 | - export IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs 70 | - > 71 | if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_TOKEN" ]; then 72 | echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USER" --password-stdin 73 | echo "Using authenticated connection (no pull limits)" 74 | else 75 | echo "Using unauthenticated docker (pull limits may apply). Setup DOCKER_USER and DOCKER_TOKEN if needed." 76 | fi 77 | install: 78 | - moodle-plugin-ci install 79 | 80 | script: 81 | - moodle-plugin-ci phplint 82 | - moodle-plugin-ci phpcpd 83 | - moodle-plugin-ci phpmd 84 | - moodle-plugin-ci codechecker 85 | - moodle-plugin-ci validate 86 | - moodle-plugin-ci savepoints 87 | - moodle-plugin-ci mustache 88 | - moodle-plugin-ci grunt 89 | - moodle-plugin-ci phpdoc 90 | - moodle-plugin-ci phpunit 91 | - moodle-plugin-ci behat -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | moodle-block_game 2 | ======================== 3 | 4 | Changes 5 | ------- 6 | ### Changes Version 1.32 Version for Moodle 3.5 onwards 7 | 8 | * 2023-05-31 - Adaptations to support Moodle 4.1 9 | 10 | Changes 11 | ------- 12 | ### Changes Version 1.31 Version for Moodle 3.5 onwards 13 | 14 | * 2022-04-04 - **Score by badges issued by moodle** 15 | * 2022-04-04 - **Changing player profile layout** 16 | * 2022-04-04 - **increased from 12 to 15 levels** 17 | * 2022-11-10 - **configure the score for completion within the activity/resource form** 18 | * 2022-11-10 - Fix in function in lib 19 | 20 | ### Changes Version 1.30 Version for Moodle 3.5 onwards 21 | 22 | * 2021-06-14 - **Allow changing avatar images in plugin settings** 23 | * 2021-06-14 - **Allow changing images of levels in plugin settings** 24 | * 2021-06-14 - **Allow scoring completion of features/activities in block settings** 25 | * 2021-06-14 - Changes in the layout of the ranking list 26 | * 2021-06-14 - Update of the game help 27 | * 2021-07-20 - **Possibility of download the ranking list** 28 | * 2021-07-27 - **Fixed section completion with group restriction** 29 | * 2021-08-06 - **Task to clear deleted users and courses from the block game** 30 | 31 | ### Changes Version 1.20 Version for Moodle 3.5 onwards 32 | 33 | * 2021-05-12 - Check compatibility for Moodle 3.11, no functionality change 34 | * 2021-05-12 - Changes in the layout of the block 35 | * 2021-05-12 - Changes in the layout of the player's profile 36 | * 2021-05-12 - Changes in the layout of the ranking list 37 | * 2021-05-12 - **Reordering avatars by level of interest** 38 | * 2021-05-12 - Update of the game help 39 | * 2021-05-12 - Replacement of all images and .png format to .svg, 75% reduction in the size of the end of the plugin 40 | 41 | ### Changes Version 1.15 Version for Moodle 3.4 onwards (2021033031) 42 | 43 | * 2021-04-20 - Check compatibility for Moodle 3.10 44 | * 2021-04-20 - General configuration of the plugin 45 | * 2021-04-20 - Ranking by group 46 | * 2021-04-20 - Option to change the avatar within the course 47 | * 2021-04-20 - Scoring option when completing section activities 48 | * 2021-04-20 - Option to reset the game points in the course 49 | * 2021-04-20 - Changes in the layout of the block 50 | * 2021-04-20 - Bugfix: Incompatibility of the keyword "rank" with the database 51 | * 2021-04-25 - Bugfix: Missing sesskey check - CSRF vulnerability. 52 | 53 | ### Changes Version 1.13 for Moodle 3.2 onwards (2019112101) 54 | 55 | * 2020-07-08 - Change plugin version and release scheme to the scheme promoted by moodle.org, no functionality change 56 | * 2019-11-21 - Initial version 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Moodle block Game repository 2 | =========================== 3 | VERSION 1.31 4 | ------------ 5 | The goal of the Block Game plugin is to apply gamification techniques to the moodle platform in a simple and uncomplicated way. 6 | 7 | The plugin uses the following possible and configurable aspects: 8 | 9 | **Use Avatar:** 10 | Allows the user to choose or change their avatar at any time. When the dotted icon appears it means the user has not yet chosen yours by clicking on it, or your avatar, it takes you to the selection page, just click on the desired avatar to make the choice. 11 | Selecting some avatars will require the user to reach a certain level to unlock them. 12 | 13 | **Allow avatar change in course:** 14 | Allows the user to choose yours in whatever course the block is added! This option makes the plugin more flexible and can be used in only one or more courses, without the need to include the block in the general area of ​​the platform! 15 | 16 | **Show Player Information:** 17 | Allows the user to access an area that consolidates the information of the same in the game, if accessed in the context of the platform presents information of all courses that the user participates using the block. 18 | 19 | **Scoring system:** 20 | The game has scoring system because the player's score will define his rating and the level he is at. 21 | - Score Activity Notes - Allows notes (numeric scale) to be converted to game points. 22 | - Bonus of the Day - Allows you to set a score that the player will receive daily if they access the platform and / or course. 23 | - Badge Bonus - Allows you to set a score the player will receive upon completing a course. It will also receive a badge as a reward. 24 | 25 | **Show Ranking:** 26 | Allows you to show either the individual student rating on the platform or course and the classified list. 27 | - Preserve User Identity - If showing the rating, lets you preserve the identity of users in the classified list. 28 | 29 | **Show Group Ranking:** 30 | Allows you to show the group classified list of students on a course. 31 | - Possibility to calculate the score by sum or average. 32 | 33 | **Show Points:** 34 | Allows you to display or not the user score. 35 | 36 | **Show Level:** 37 | Allows you to display or not the level system. If configured to display you can configure the number of levels and the score required to reach each level. 38 | Still regarding the level the block has a progress bar that shows the user how much is left to reach the next level. 39 | 40 | *All images used in the plugin are under the Creative Commons license.* 41 | 42 | Installation 43 | ------------ 44 | ***Important: Compatible with MySQL and PostgreSQL only*** 45 | 46 | **First way** 47 | 48 | - Download this repository 49 | - Access the administration area-> plugins-> install plugin, upload the file and click install. 50 | 51 | **Second way** 52 | 53 | - Download this repository 54 | - Extract the content 55 | - Put the folder into the folder blocks of your moodle 56 | - Access the notification area in moodle and install 57 | 58 | Post instalation 59 | ---------------- 60 | 61 | After installing the block, simply add it to the course and / or in the main page of moodle. 62 | 63 | The entire configuration of the plugin is in the configuration of the block. 64 | -------------------------------------------------------------------------------- /block_game.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block definition 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | defined('MOODLE_INTERNAL') || die(); 25 | 26 | require_once($CFG->dirroot . '/blocks/game/lib.php'); 27 | require_once($CFG->libdir . '/filelib.php' ); 28 | 29 | /** 30 | * Block Game config form definition class 31 | * 32 | * @package block_game 33 | * @copyright 2019 Jose Wilson 34 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 | */ 36 | class block_game extends block_base { 37 | 38 | /** 39 | * Sets the block title 40 | * 41 | * @return none 42 | */ 43 | public function init() { 44 | $this->title = get_string('game_title_default', 'block_game'); 45 | } 46 | 47 | /** 48 | * Controls the block title based on instance configuration 49 | * 50 | * @return bool 51 | */ 52 | public function specialization() { 53 | global $course; 54 | 55 | // Need the bigger course object. 56 | $this->course = $course; 57 | 58 | // Override the block title if an alternative is set. 59 | if (isset($this->config->game_title) && trim($this->config->game_title) != '') { 60 | $this->title = format_string($this->config->game_title); 61 | } 62 | } 63 | 64 | /** 65 | * Defines where the block can be added 66 | * 67 | * @return array 68 | */ 69 | public function applicable_formats() { 70 | return array( 71 | 'course-view' => true, 72 | 'site-index' => true, 73 | 'mod' => true, 74 | 'my' => true 75 | ); 76 | } 77 | 78 | /** 79 | * Controls global configurability of block 80 | * 81 | * @return bool 82 | */ 83 | public function instance_allow_config() { 84 | return false; 85 | } 86 | 87 | /** 88 | * Controls global configurability of block 89 | * 90 | * @return bool 91 | */ 92 | public function has_config() { 93 | return true; 94 | } 95 | 96 | /** 97 | * Controls if a block header is shown based on instance configuration 98 | * 99 | * @return bool 100 | */ 101 | public function hide_header() { 102 | return isset($this->config->show_header) && $this->config->show_header == 0; 103 | } 104 | 105 | /** 106 | * Creates the block's main content 107 | * 108 | * @return string 109 | */ 110 | public function get_content() { 111 | global $USER, $COURSE; 112 | if ($this->content !== null) { 113 | return $this->content; 114 | } 115 | 116 | $this->content = new \stdClass; 117 | $this->content->text = ''; 118 | $this->content->footer = ''; 119 | 120 | $renderer = $this->page->get_renderer('block_game'); 121 | 122 | $contentrenderable = new \block_game\output\block($this->config, $USER, $COURSE); 123 | 124 | $this->content->text = $renderer->render($contentrenderable); 125 | 126 | return $this->content; 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /classes/output/renderer.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block renderer. 19 | * 20 | * @package block_game 21 | * @copyright 2018 Willian Mano http://conecti.me 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | namespace block_game\output; 26 | 27 | use plugin_renderer_base; 28 | use renderable; 29 | 30 | /** 31 | * Ranking block renderer. 32 | * 33 | * @package block_game 34 | * @copyright 2020 Willian Mano http://conecti.me 35 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 | */ 37 | class renderer extends plugin_renderer_base { 38 | 39 | /** 40 | * Defer the block instance in course to template. 41 | * 42 | * @param renderable $page 43 | * 44 | * @return bool|string 45 | * 46 | * @throws \moodle_exception 47 | */ 48 | public function render_block(renderable $page) { 49 | $data = $page->export_for_template($this); 50 | 51 | return parent::render_from_template('block_game/block', $data); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /classes/task/cleargame.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Block Game config task definition class 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | namespace block_game\task; 25 | 26 | /** 27 | * Task to clear course deleted game 28 | * 29 | * @package block_game 30 | * @copyright 2019 Jose Wilson 31 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 | */ 33 | class cleargame extends \core\task\scheduled_task { 34 | 35 | /** 36 | * Task to clear deleted users and courses from the block game. 37 | * 38 | * @return string 39 | * 40 | * @throws \coding_exception 41 | */ 42 | public function get_name() { 43 | return get_string('cleargametask', 'block_game'); 44 | } 45 | 46 | /** 47 | * Execute the task. 48 | */ 49 | public function execute() { 50 | global $CFG; 51 | require_once($CFG->dirroot . '/blocks/game/lib.php'); 52 | block_game_clear_course_deleted_game(); 53 | block_game_clear_user_deleted_game(); 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /db/access.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | 18 | /** 19 | * Block Game capabilities definition 20 | * 21 | * @package block_game 22 | * @copyright 2019 Jose Wilson 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | defined('MOODLE_INTERNAL') || die(); 27 | 28 | $capabilities = array( 29 | 'block/game:myaddinstance' => array( 30 | 'captype' => 'write', 31 | 'contextlevel' => CONTEXT_SYSTEM, 32 | 'archetypes' => array( 33 | 'user' => CAP_ALLOW 34 | ), 35 | 'clonepermissionsfrom' => 'moodle/my:manageblocks' 36 | ), 37 | 'block/game:addinstance' => array( 38 | 'riskbitmask' => RISK_SPAM | RISK_XSS, 39 | 'captype' => 'write', 40 | 'contextlevel' => CONTEXT_BLOCK, 41 | 'archetypes' => array( 42 | 'editingteacher' => CAP_ALLOW, 43 | 'manager' => CAP_ALLOW 44 | ), 45 | 'clonepermissionsfrom' => 'moodle/site:manageblocks' 46 | ), 47 | ); 48 | -------------------------------------------------------------------------------- /db/install.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 |
52 |
53 | -------------------------------------------------------------------------------- /db/tasks.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Block Game config form definition class 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die(); 26 | 27 | $tasks = [ 28 | [ 29 | 'classname' => 'block_game\task\cleargame', 30 | 'blocking' => 0, 31 | 'minute' => '30', 32 | 'hour' => '*', 33 | 'day' => '*', 34 | 'month' => '*', 35 | 'dayofweek' => '*', 36 | ], 37 | ]; 38 | -------------------------------------------------------------------------------- /db/upgrade.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block language strings 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | /** 26 | * Update block_game 27 | * 28 | * @param int $oldversion 29 | * @return bool always true 30 | */ 31 | function xmldb_block_game_upgrade($oldversion) { 32 | global $CFG, $DB; 33 | $dbman = $DB->get_manager(); 34 | 35 | if ($oldversion < 2020012905) { 36 | // Add field 'score_bonus_day' to 'block_game'. 37 | $table = new xmldb_table('block_game'); 38 | $field = new xmldb_field('score_bonus_day', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'score_activities'); 39 | if (!$dbman->field_exists($table, $field)) { 40 | $dbman->add_field($table, $field); 41 | } 42 | // Define table block_xp_filters to be created. 43 | $table = new xmldb_table('block_game_completed_atv'); 44 | // Adding fields to table block_game_completed_atv. 45 | $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); 46 | $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); 47 | $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); 48 | $table->add_field('moduleid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); 49 | $table->add_field('score', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); 50 | $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, null); 51 | // Adding keys to table block_game_completed_atv. 52 | $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); 53 | $table->add_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); 54 | $table->add_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); 55 | // Conditionally launch create table for block_game_completed_atv. 56 | if (!$dbman->table_exists($table)) { 57 | $dbman->create_table($table); 58 | } 59 | // Block_game savepoint reached. 60 | upgrade_block_savepoint(true, 2020012905, 'game'); 61 | } 62 | if ($oldversion < 2020042983) { 63 | // Add field 'score_bonus_day' to 'block_game'. 64 | $table = new xmldb_table('block_game'); 65 | $field = new xmldb_field('score_section', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'score_badges'); 66 | if (!$dbman->field_exists($table, $field)) { 67 | $dbman->add_field($table, $field); 68 | } 69 | // Block_game savepoint reached. 70 | upgrade_block_savepoint(true, 2020042983, 'game'); 71 | } 72 | if ($oldversion < 2020042996) { 73 | // Add field 'score_bonus_day' to 'block_game'. 74 | $table = new xmldb_table('block_game'); 75 | $field = new xmldb_field('ranking', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'level'); 76 | if (!$dbman->field_exists($table, $field)) { 77 | $dbman->add_field($table, $field); 78 | } 79 | // Block_game savepoint reached. 80 | upgrade_block_savepoint(true, 2020042996, 'game'); 81 | } 82 | if ($oldversion < 2021051022) { 83 | // Add field 'score_bonus_day' to 'block_game'. 84 | $table = new xmldb_table('block_game'); 85 | $field = new xmldb_field('score_module_completed', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'score_activities'); 86 | if (!$dbman->field_exists($table, $field)) { 87 | $dbman->add_field($table, $field); 88 | } 89 | // Block_game savepoint reached. 90 | upgrade_block_savepoint(true, 2021051022, 'game'); 91 | } 92 | if ($oldversion < 2022042725) { 93 | // Define table block_game_completed_atv to be dropped. 94 | $table = new xmldb_table('block_game_completed_atv'); 95 | // Conditionally launch drop table for role_sortorder. 96 | if ($dbman->table_exists($table)) { 97 | $dbman->drop_table($table); 98 | } 99 | // Block_game savepoint reached. 100 | upgrade_block_savepoint(true, 2022042725, 'game'); 101 | } 102 | return true; 103 | } 104 | -------------------------------------------------------------------------------- /download.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block caps. 19 | * 20 | * @package block_game 21 | * @copyright José Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | require_once(dirname(__FILE__) . '/../../config.php'); 25 | require_once($CFG->dirroot . '/blocks/game/lib.php'); 26 | require_once($CFG->libdir . "/dataformatlib.php"); 27 | 28 | require_login(); 29 | 30 | $id = required_param('id', PARAM_INT); 31 | $op = optional_param('op', '', PARAM_ALPHA); 32 | $dataformat = optional_param('dataformat', '', PARAM_ALPHA); 33 | 34 | if ($op === "ranking") { 35 | $columns = [get_string('order', 'block_game'), 36 | get_string('name', 'block_game'), 37 | get_string('score_atv', 'block_game'), 38 | get_string('score_mod', 'block_game'), 39 | get_string('score_section', 'block_game'), 40 | get_string('score_bonus_day', 'block_game'), 41 | get_string('score_total', 'block_game')]; 42 | $rs = block_game_rank_list($id); 43 | $ord = 1; 44 | $rows = array(); 45 | foreach ($rs as $gamer) { 46 | $ordtxt = $ord; 47 | $usertxt = $gamer->firstname . ' ' . $gamer->lastname; 48 | $scoreatv = $gamer->sum_score_activities; 49 | $scoremod = $gamer->sum_score_module_completed; 50 | $scoresection = $gamer->sum_score_section; 51 | $scorebonusday = $gamer->sum_score_bonus_day; 52 | $scoretxt = $gamer->pt; 53 | $rows[] = [$ordtxt, $usertxt, $scoreatv, $scoremod, 54 | $scoresection, $scorebonusday, $scoretxt]; 55 | 56 | $ord++; 57 | } 58 | 59 | download_as_dataformat('ranking', $dataformat, $columns, $rows); 60 | } 61 | -------------------------------------------------------------------------------- /perfil_gamer.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block config form definition 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | require_once(dirname(__FILE__) . '/../../config.php'); 25 | require_once($CFG->dirroot . '/blocks/game/lib.php'); 26 | require_once($CFG->libdir . '/completionlib.php'); 27 | require_once($CFG->libdir . '/filelib.php' ); 28 | require_once($CFG->libdir . '/badgeslib.php'); 29 | 30 | global $USER, $COURSE, $OUTPUT, $CFG; 31 | 32 | $courseid = required_param('id', PARAM_INT); 33 | $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 34 | 35 | require_login($course); 36 | 37 | $PAGE->set_pagelayout('course'); 38 | $PAGE->set_url('/blocks/game/perfil_gamer.php', array('id' => $courseid)); 39 | $PAGE->set_context(context_course::instance($courseid)); 40 | $PAGE->set_title(get_string('perfil_gamer_title', 'block_game')); 41 | $PAGE->set_heading(get_string('perfil_gamer_title', 'block_game')); 42 | 43 | echo $OUTPUT->header(); 44 | if ($courseid == SITEID) { 45 | $renderer = $PAGE->get_renderer('block_game'); 46 | 47 | $contentrenderable = new \block_game\output\profile($USER, $courseid); 48 | 49 | echo $renderer->render($contentrenderable); 50 | } else { 51 | $renderer = $PAGE->get_renderer('block_game'); 52 | 53 | $contentrenderable = new \block_game\output\profilecourse($USER, $courseid); 54 | 55 | echo $renderer->render($contentrenderable); 56 | } 57 | echo $OUTPUT->footer(); 58 | -------------------------------------------------------------------------------- /pix/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JotaDF/moodle-block_game/6eb9380959877d9a19ab1c57d04459456f433540/pix/.DS_Store -------------------------------------------------------------------------------- /pix/a0.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 14 | 15 | -------------------------------------------------------------------------------- /pix/a1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 15 | 17 | 19 | 21 | 22 | 23 | 26 | 27 | 30 | 33 | 34 | 35 | 36 | 42 | 43 | 45 | 47 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /pix/a11.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a18.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a19.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a26.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a29.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a30.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a31.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a33.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a35.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a42.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a47.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a49.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a5.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 10 | 14 | 15 | 16 | 18 | 24 | 31 | 34 | 37 | 38 | 39 | 40 | 41 | 43 | 46 | 48 | 49 | 51 | 53 | 54 | 57 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /pix/a50.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a52.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a58.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a62.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a68.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/a8.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 11 | 13 | 15 | 16 | 17 | 18 | 21 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 36 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | 49 | 52 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /pix/a9.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/badgex.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 64 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /pix/help.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/help_progress_level.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 72.3% 11 | 12 | 13 | -------------------------------------------------------------------------------- /pix/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 20 | 22 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /pix/info.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 23 | 24 | -------------------------------------------------------------------------------- /pix/level.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 24 | 25 | 27 | 30 | 32 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /pix/lv0.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 24 | 25 | 27 | 30 | 32 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /pix/lv1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /pix/lv10.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 34 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /pix/lv11.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /pix/lv12.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 34 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /pix/lv13.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 30 | 31 | 33 | 3 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /pix/lv14.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 30 | 31 | 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /pix/lv15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 30 | 31 | 33 | 5 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /pix/lv2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /pix/lv3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /pix/lv4.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /pix/lv5.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /pix/lv6.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /pix/lv7.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /pix/lv8.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /pix/lv9.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 21 | 22 | 24 | 27 | 29 | 31 | 32 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /pix/rank.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /pix/rank_group_list.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /pix/rank_list.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pix/reset.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pix/score.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 19 | 20 | 21 | 23 | 25 | 27 | 29 | 31 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 46 | 48 | 50 | 51 | 53 | 55 | 57 | 58 | 59 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /rank_group_game.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block config form definition 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | require_once(dirname(__FILE__) . '/../../config.php'); 25 | require_once($CFG->dirroot . '/blocks/game/lib.php'); 26 | require_once($CFG->libdir . '/filelib.php'); 27 | 28 | require_login(); 29 | 30 | global $USER, $COURSE, $OUTPUT, $CFG; 31 | 32 | $courseid = required_param('id', PARAM_INT); 33 | 34 | $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 35 | 36 | require_login($course); 37 | $PAGE->set_pagelayout('course'); 38 | $PAGE->set_url('/blocks/game/rank_game.php', array('id' => $courseid)); 39 | $PAGE->set_context(context_course::instance($courseid)); 40 | $PAGE->set_title(get_string('rank_group_game_title', 'block_game')); 41 | $PAGE->set_heading(get_string('rank_group_game_title', 'block_game')); 42 | 43 | echo $OUTPUT->header(); 44 | $game = new stdClass(); 45 | $cfggame = get_config('block_game'); 46 | if ($courseid == SITEID) { 47 | $game->config = $cfggame; 48 | } else { 49 | $game->config = block_game_get_config_block($courseid); 50 | } 51 | $limit = 0; 52 | if (isset($game->config->show_rank) && $game->config->show_rank == 1) { 53 | $outputhtml = '
'; 54 | if ($courseid != SITEID) { 55 | $outputhtml .= '

( ' . $course->fullname . ' )


'; 56 | 57 | $outputhtml .= ''; 58 | if (isset($game->config->rank_group_calc) && $game->config->rank_group_calc == 1) { 59 | $rs = block_game_ranking_group_md($courseid); 60 | } else { 61 | $rs = block_game_ranking_group($courseid); 62 | } 63 | $ord = 1; 64 | foreach ($rs as $group) { 65 | $ordtxt = $ord . 'º'; 66 | $grouptxt = $group->name; 67 | $groupcount = $group->members; 68 | $scoretxt = number_format($group->pt, 2); 69 | if (isset($game->config->rank_group_calc) && $game->config->rank_group_calc == 1) { 70 | $scoretxt = number_format($group->md, 2); 71 | } 72 | $group = $DB->get_record('groups', array('id' => $group->id), '*', MUST_EXIST); 73 | 74 | $outputhtml .= ''; 75 | $outputhtml .= ''; 76 | $outputhtml .= ''; 78 | $outputhtml .= ''; 79 | $outputhtml .= ''; 81 | $outputhtml .= ''; 82 | 83 | $outputhtml .= ''; 84 | 85 | $ord++; 86 | } 87 | $outputhtml .= '
' . $ordtxt . '' 77 | . print_group_picture($group, $courseid, false, true, false) . ' ' . $grouptxt . '(' . $groupcount . ') ' . $scoretxt; 80 | $outputhtml .= get_string('abbreviate_score', 'block_game') . '

'; 88 | } 89 | $outputhtml .= '
'; 90 | } else { 91 | $outputhtml = "..."; 92 | $context = context_course::instance($courseid, MUST_EXIST); 93 | if (has_capability('moodle/course:update', $context, $USER->id)) { 94 | $outputhtml = get_string('not_initial_config_game', 'block_game'); 95 | } 96 | } 97 | echo $outputhtml; 98 | 99 | echo $OUTPUT->footer(); 100 | -------------------------------------------------------------------------------- /reset_points_course.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | 18 | /** 19 | * Game block config form definition 20 | * 21 | * @package block_game 22 | * @copyright 2019 Jose Wilson 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | require_once(dirname(__FILE__) . '/../../config.php'); 26 | require_once($CFG->dirroot . '/blocks/game/lib.php'); 27 | require_once($CFG->libdir . '/completionlib.php'); 28 | 29 | require_login(); 30 | 31 | global $USER, $OUTPUT, $CFG; 32 | 33 | $confirm = optional_param('c', 0, PARAM_INT); 34 | $courseid = required_param('id', PARAM_INT); 35 | $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 36 | 37 | require_login($course); 38 | 39 | $PAGE->set_pagelayout('course'); 40 | $PAGE->set_url('/blocks/game/reset_points_course.php', array('id' => $courseid)); 41 | $PAGE->set_context(context_course::instance($courseid)); 42 | $PAGE->set_title(get_string('reset_points_title', 'block_game')); 43 | $PAGE->set_heading(get_string('reset_points_title', 'block_game')); 44 | 45 | echo $OUTPUT->header(); 46 | $outputhtml = '
'; 47 | 48 | if ($courseid != SITEID) { 49 | $context = context_course::instance($courseid, MUST_EXIST); 50 | if (has_capability('moodle/course:update', $context, $USER->id)) { 51 | $outputhtml .= '
'; 52 | 53 | $outputhtml .= '

( ' . get_string('reset_points_title', 'block_game') . ': ' 54 | . $course->fullname . ' )


'; 55 | 56 | $outputhtml .= '
'; 57 | if ($confirm > 0) { 58 | require_sesskey(); 59 | if (block_game_reset_points_game($courseid)) { 60 | $outputhtml .= '' . get_string('reset_points_sucess', 'block_game') 61 | . '

' . get_string('ok', 'block_game') . ''; 63 | } else { 64 | $outputhtml .= '' . get_string('reset_points_error', 'block_game') . '
'; 65 | } 66 | } else { 67 | $outputhtml .= '' . get_string('label_confirm_reset_points', 'block_game') . '

'; 68 | $outputhtml .= '' 69 | . get_string('no', 'block_game') . '' . ' ' . get_string('yes', 'block_game') . '' . '
'; 71 | } 72 | $outputhtml .= '
'; 73 | $outputhtml .= '
'; 74 | } else { 75 | $outputhtml .= '' . get_string('reset_points_not_permission', 'block_game') . '
'; 76 | } 77 | } 78 | $outputhtml .= '
'; 79 | echo $outputhtml; 80 | echo $OUTPUT->footer(); 81 | -------------------------------------------------------------------------------- /settings.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Block Game config form definition class 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | defined('MOODLE_INTERNAL') || die(); 25 | 26 | if ($ADMIN->fulltree) { 27 | $settings->add(new admin_setting_heading('block_game/displaysettings', 28 | get_string('defaultdisplaysettings', 'block_game'), '')); 29 | 30 | $settings->add(new admin_setting_configcheckbox('block_game/use_avatar', 31 | get_string('config_avatar', 'block_game'), '', 1)); 32 | 33 | $settings->add(new admin_setting_configstoredfile( 34 | 'block_game/imagens_avatar', 35 | new lang_string('imagemavatar', 'block_game'), 36 | new lang_string('imagemavatardesc', 'block_game'), 37 | 'imagens_avatar', 38 | 0, 39 | ['subdirs' => 0, 'maxfiles' => 68, 'accepted_types' => array('.svg')] 40 | )); 41 | 42 | $settings->add(new admin_setting_configcheckbox('block_game/change_avatar_course', 43 | get_string('config_avatar_course', 'block_game'), '', 0)); 44 | 45 | $settings->add(new admin_setting_configcheckbox('block_game/show_info', 46 | get_string('config_info', 'block_game'), get_string('config_info_help', 'block_game'), 1)); 47 | 48 | $settings->add(new admin_setting_configcheckbox('block_game/score_activities', 49 | get_string('config_score_activities', 'block_game'), '', 1)); 50 | 51 | $bonusdayoptions = array(0 => 0, 1 => 1, 3 => 3, 5 => 5, 10 => 10, 15 => 15, 20 => 20, 50 => 50, 100 => 100); 52 | $settings->add(new admin_setting_configselect('block_game/bonus_day', 53 | get_string('config_bonus_day', 'block_game'), '', -2, $bonusdayoptions)); 54 | 55 | $bonusbadgeoptions = array(0 => 0, 50 => 50, 100 => 100, 200 => 200, 500 => 500, 1000 => 1000, 2000 => 2000); 56 | $settings->add(new admin_setting_configselect('block_game/bonus_badge', 57 | get_string('config_bonus_badge', 'block_game'), '', -2, $bonusbadgeoptions)); 58 | 59 | $settings->add(new admin_setting_configcheckbox('block_game/show_rank', 60 | get_string('config_rank', 'block_game'), '', 1)); 61 | 62 | $settings->add(new admin_setting_configcheckbox('block_game/show_identity', 63 | get_string('config_identity', 'block_game'), '', 1)); 64 | 65 | $settings->add(new admin_setting_configcheckbox('block_game/show_score', 66 | get_string('config_score', 'block_game'), '', 1)); 67 | 68 | $settings->add(new admin_setting_configcheckbox('block_game/show_level', 69 | get_string('config_level', 'block_game'), '', 1)); 70 | 71 | $settings->add(new admin_setting_configstoredfile( 72 | 'block_game/imagens_levels', 73 | new lang_string('imagemlevels', 'block_game'), 74 | new lang_string('imagemlevelsdesc', 'block_game'), 75 | 'imagens_levels', 76 | 0, 77 | ['subdirs' => 0, 'maxfiles' => 16, 'accepted_types' => array('.svg')] 78 | )); 79 | 80 | // Options controlling level up. 81 | $leveloptions = array(4 => 4, 6 => 6, 8 => 8, 10 => 10, 12 => 12, 13 => 13, 14 => 14, 15 => 15); 82 | $settings->add(new admin_setting_configselect('block_game/level_number', 83 | get_string('config_level_number', 'block_game'), '', 15, $leveloptions)); 84 | 85 | $leveluppoints = array(1 => 300, 2 => 500, 3 => 1000, 4 => 2000, 86 | 5 => 4000, 6 => 6000, 7 => 10000, 8 => 20000, 87 | 9 => 30000, 10 => 50000, 11 => 70000, 12 => 100000, 13 => 150000, 14 => 250000, 15 => 500000); 88 | for ($i = 1; $i <= 15; $i++) { 89 | $settings->add(new admin_setting_configtext('block_game/level_up' . $i, 90 | get_string('config_level_up' . $i, 'block_game'), '', $leveluppoints[$i], PARAM_INT)); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /templates/profile.mustache: -------------------------------------------------------------------------------- 1 | {{! 2 | This file is part of Moodle - http://moodle.org/ 3 | 4 | Moodle is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | Moodle is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with Moodle. If not, see . 16 | }} 17 | {{! 18 | @template block_game/profile 19 | 20 | This template renders the profile user. 21 | }} 22 |
23 |
24 | {{{imgavatar}}} 25 | {{username}} 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {{#courses}} 42 | {{#awarded}} 43 | 44 | 45 | 50 | 53 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | {{/awarded}} 70 | {{/courses}} 71 | 72 |
{{courselabel}}{{ranklabel}}{{labellevel}}{{nextlevellabel}}{{scoreatvlabel}}{{scoremodlabel}}{{scoresectionlabel}}{{scorebonuslabel}}{{scorebadgelabel}}{{scorelabelfull}}
{{{coursename}}} 46 | {{#rank}} 47 | {{rank}}º / {{fullrank}} 48 | {{/rank}} 49 | 51 | {{{imglevel}}} 52 | 54 | {{#imglevel}} 55 |
56 |
57 | {{percent}}% 58 |
59 |
60 | {{/imglevel}} 61 |
{{{scoreatv}}}{{{scoremod}}}{{{scoresection}}}{{{scorebonus}}}{{{scorbadge}}}{{scorefull}}
73 |
74 |

{{labelbadges}}

75 |
76 | {{{outputbadges}}} 77 | {{#badgedisabled}} 78 | {{badgedisabled}} 79 | {{/badgedisabled}} 80 |
81 |
-------------------------------------------------------------------------------- /templates/profilecourse.mustache: -------------------------------------------------------------------------------- 1 | {{! 2 | This file is part of Moodle - http://moodle.org/ 3 | 4 | Moodle is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | Moodle is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with Moodle. If not, see . 16 | }} 17 | {{! 18 | @template block_game/profilecourse 19 | 20 | This template renders the profile user in the course. 21 | }} 22 |
23 |

({{coursename}})

24 |
25 |
26 | {{{imgavatar}}} 27 | {{username}} 28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | {{{imgrank}}} 36 |
37 |
38 |
{{labelrank}}
39 | {{rank}}º / {{fullrank}} 40 |
41 |
42 |
43 |
44 |
45 |
46 | {{{imgscore}}} 47 |
48 |
49 |
{{labelscore}}
50 | {{score}} 51 |
52 |
53 |
54 |
55 |
56 |
57 | {{{imglevel}}} 58 |
59 |
60 |
{{labellevel}}
61 | {{level}} 62 |
63 |
64 |
65 |
66 |
67 | {{scorelabeldetail}} 68 |
69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |
{{scoreatvlabel}}:{{scoreatv}}
{{scoremodlabel}}:{{scoremod}}
{{scoresectionlabel}}:{{scoresection}}
{{scorebonuslabel}}:{{scorebonus}}
{{scorebadgelabel}}:{{scorbadge}}
93 |
94 |
95 | {{percent}}% 96 |
97 |
98 |
99 | {{nextlevel}} 100 |
101 |
102 |
103 |
104 |
105 |

{{labelbadges}}

106 |
107 | {{{outputbadges}}} 108 | {{#badgedisabled}} 109 | {{badgedisabled}} 110 | {{/badgedisabled}} 111 |
112 |
113 |
114 |
-------------------------------------------------------------------------------- /version.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Game block version identification 19 | * 20 | * @package block_game 21 | * @copyright 2019 Jose Wilson 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die(); 26 | 27 | $plugin->version = 2023053101; 28 | $plugin->requires = 2018051700; 29 | $plugin->maturity = MATURITY_STABLE; 30 | $plugin->release = '1.32 Version for Moodle 3.5 onwards'; 31 | $plugin->component = 'block_game'; 32 | --------------------------------------------------------------------------------