';
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 .= '' . $ordtxt . ' | ';
76 | $outputhtml .= ''
77 | . print_group_picture($group, $courseid, false, true, false) . ' | ';
78 | $outputhtml .= ' ' . $grouptxt . '(' . $groupcount . ') | ';
79 | $outputhtml .= ' ' . $scoretxt;
80 | $outputhtml .= get_string('abbreviate_score', 'block_game') . ' | ';
81 | $outputhtml .= '
';
82 |
83 | $outputhtml .= '
|
';
84 |
85 | $ord++;
86 | }
87 | $outputhtml .= '
';
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
23 |
24 | {{{imgavatar}}}
25 | {{username}}
26 |
27 |
28 |
29 |
30 | {{courselabel}} |
31 | {{ranklabel}} |
32 | {{labellevel}} |
33 | {{nextlevellabel}} |
34 | {{scoreatvlabel}} |
35 | {{scoremodlabel}} |
36 | {{scoresectionlabel}} |
37 | {{scorebonuslabel}} |
38 | {{scorebadgelabel}} |
39 | {{scorelabelfull}} |
40 |
41 | {{#courses}}
42 | {{#awarded}}
43 |
44 | {{{coursename}}} |
45 |
46 | {{#rank}}
47 | {{rank}}º / {{fullrank}}
48 | {{/rank}}
49 | |
50 |
51 | {{{imglevel}}}
52 | |
53 |
54 | {{#imglevel}}
55 |
56 |
57 | {{percent}}%
58 |
59 |
60 | {{/imglevel}}
61 | |
62 | {{{scoreatv}}} |
63 | {{{scoremod}}} |
64 | {{{scoresection}}} |
65 | {{{scorebonus}}} |
66 | {{{scorbadge}}} |
67 | {{scorefull}} |
68 |
69 | {{/awarded}}
70 | {{/courses}}
71 |
72 |
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