Skip to content

Commit

Permalink
Feat: Make 'limittoenrolled' for course_select_form configurable (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel authored and Syxton committed Oct 24, 2022
1 parent ae0cca1 commit a207ad9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions classes/form/course_select_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public function definition() {

$mform->addElement('header', 'choosetargetcourse', get_string('choosetargetcourse', 'block_massaction'));

$limittoenrolled = !empty(get_config('block_massaction', 'limittoenrolled'));
$mform->addElement('course', 'targetcourseid', get_string('choosecoursetoduplicateto', 'block_massaction'),
['limittoenrolled' => true, 'exclude' => $sourcecourseid,
['limittoenrolled' => $limittoenrolled, 'exclude' => $sourcecourseid,
'requiredcapabilities' => ['moodle/restore:restoretargetimport']]);

$this->add_action_buttons(true, get_string('confirmcourseselect', 'block_massaction'));
}

}
2 changes: 2 additions & 0 deletions lang/en/block_massaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
$string['invalidcoursemodule'] = 'Invalid course module';
$string['invalidcourseid'] = 'Invalid course ID';
$string['jsonerror'] = 'Error coding: Invalid JSON format';
$string['limittoenrolled'] = 'Limit target course list to courses in which the user is enrolled';
$string['limittoenrolled_description'] = 'If enabled the course selection of the feature "Duplicate to another course" will be limited to courses in which the user is enrolled. Enabling this is recommended for instances with many courses, because not limiting the courses is likely to result in performance issues and timeouts. Disabling this option is at one own\'s risk.';
$string['keepsectionnum'] = 'Keep original section number';
$string['modulename'] = 'Activity name';
$string['moduletype'] = 'Activity type';
Expand Down
7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,12 @@
$supportedformatsbydefault,
$plugins)
);

$settings->add(new admin_setting_configcheckbox(
'block_massaction/limittoenrolled',
new lang_string('limittoenrolled', 'block_massaction'),
new lang_string('limittoenrolled_description', 'block_massaction'),
1)
);
}
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2022041703;
$plugin->version = 2022041704;
$plugin->requires = 2020061500;
$plugin->supported = [39, 311];
$plugin->incompatible = 400;
Expand Down

0 comments on commit a207ad9

Please sign in to comment.