Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of max_modules setting #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions block_completion_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@ protected function prepare_dashboard_content(&$barinstances) {
protected function prepare_course_content(&$barinstances) {
global $USER, $COURSE, $CFG, $OUTPUT;

$moduleinfo = get_fast_modinfo($COURSE);

$maxmodules = (int)get_config('block_completion_progress', 'max_modules');
$modules = count($moduleinfo->get_cms());
if ($maxmodules !== 0 && $modules > $maxmodules) {
$this->content->text .= get_string('too_many_modules', 'block_completion_progress', (object)[
'maxmodules' => $maxmodules,
'modules' => $modules,
]);
return false;
}

$output = $this->page->get_renderer('block_completion_progress');

// Check if user is in group for block.
Expand Down
3 changes: 3 additions & 0 deletions lang/en/block_completion_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
$string['completed_colour'] = '#73A839';
$string['completed_colour_descr'] = 'HTML Colour code for elements that have been completed';
$string['completed_colour_title'] = 'Completed colour';
$string['too_many_modules'] = '<i class="fa fa-exclamation-circle text-danger fa-fw"></i>Too many modules to display.<br> {$a->maxmodules} modules are allowed, this course has {$a->modules}.';
$string['max_modules'] = 'The amount of modules allowed in a course for the block to show completion progress';
$string['max_modules_desc'] = 'If the course has more modules than this, the block will not show completion progress. <strong>By setting this setting to 0, the block will always show completion progress.</strong>';
$string['completion_not_enabled'] = 'Completion tracking is not enabled on this site.';
$string['completion_not_enabled_course'] = 'Completion tracking is not enabled in this course.';
$string['completion_progress:addinstance'] = 'Add a new Completion Progress block';
Expand Down
15 changes: 12 additions & 3 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,17 @@
defaults::SHOWLASTINCOURSE)
);
$settings->add(new admin_setting_configcheckbox('block_completion_progress/forceiconsinbar',
get_string('forceiconsinbar', 'block_completion_progress'),
'',
defaults::FORCEICONSINBAR)
get_string('forceiconsinbar', 'block_completion_progress'),
'',
defaults::FORCEICONSINBAR)
);
$settings->add(
new admin_setting_configtext(
'block_completion_progress/max_modules',
get_string('max_modules', 'block_completion_progress'),
get_string('max_modules_desc', 'block_completion_progress'),
0,
PARAM_INT
)
);
}
5 changes: 3 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2023110100;
/** @var object $plugin */
$plugin->component = 'block_completion_progress';
$plugin->version = 2023110101;
$plugin->requires = 2022112800;
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'Version for Moodle 4.1 onwards';
$plugin->component = 'block_completion_progress';
Loading