Skip to content

Commit

Permalink
Merge branch 'MDL-68928' of https://github.com/Chocolate-lightning/mo…
Browse files Browse the repository at this point in the history
…odle into master
  • Loading branch information
stronk7 committed Aug 18, 2020
2 parents 63364b9 + b412197 commit 089a3ac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
26 changes: 26 additions & 0 deletions admin/settings/courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
// Add a category for the Activity Chooser.
$ADMIN->add('courses', new admin_category('activitychooser', new lang_string('activitychoosercategory', 'course')));
$temp = new admin_settingpage('activitychoosersettings', new lang_string('activitychoosersettings', 'course'));
// Tab mode for the activity chooser.
$temp->add(
new admin_setting_configselect(
'activitychoosertabmode',
Expand All @@ -197,6 +198,31 @@
]
)
);

// Build a list of plugins that use the footer callback.
$pluginswithfunction = get_plugins_with_function('custom_chooser_footer', 'lib.php');
$pluginsoptions = [];
$pluginsoptions[COURSE_CHOOSER_FOOTER_NONE] = get_string('activitychooserhidefooter', 'course');
if ($pluginswithfunction) {
foreach ($pluginswithfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginname => $pluginfunction) {
$plugin = $plugintype.'_'.$pluginname;
$pluginsoptions[$plugin] = get_string('pluginname', $plugin);
}
}
}

// Select what plugin to show in the footer.
$temp->add(
new admin_setting_configselect(
'activitychooseractivefooter',
new lang_string('activitychooseractivefooter', 'course'),
new lang_string('activitychooseractivefooter_desc', 'course'),
COURSE_CHOOSER_FOOTER_NONE,
$pluginsoptions
)
);

$ADMIN->add('activitychooser', $temp);
$ADMIN->add('activitychooser',
new admin_externalpage('activitychooserrecommended', new lang_string('activitychooserrecommendations', 'course'),
Expand Down
13 changes: 4 additions & 9 deletions course/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4381,15 +4381,10 @@ public static function get_activity_chooser_footer(int $courseid, int $sectionid
$coursecontext = context_course::instance($courseid);
self::validate_context($coursecontext);

$pluginswithfunction = get_plugins_with_function('custom_chooser_footer', 'lib.php');
if ($pluginswithfunction) {
foreach ($pluginswithfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$footerdata = $pluginfunction($courseid, $sectionid);
break; // Only a single plugin can modify the footer.
}
break; // Only a single plugin can modify the footer.
}
$activeplugin = get_config('core', 'activitychooseractivefooter');

if ($activeplugin !== COURSE_CHOOSER_FOOTER_NONE) {
$footerdata = component_callback($activeplugin, 'custom_chooser_footer', [$courseid, $sectionid]);
return [
'footer' => true,
'customfooterjs' => $footerdata->get_footer_js_file(),
Expand Down
3 changes: 3 additions & 0 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
/** Searching for all courses that have no value for the specified custom field. */
define('COURSE_CUSTOMFIELD_EMPTY', -1);

// Course activity chooser footer default display option.
define('COURSE_CHOOSER_FOOTER_NONE', 'hidden');

function make_log_url($module, $url) {
switch ($module) {
case 'course':
Expand Down
3 changes: 3 additions & 0 deletions lang/en/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
$string['activitychoosercategory'] = 'Activity chooser';
$string['activitychooserrecommendations'] = 'Recommended activities';
$string['activitychoosersettings'] = 'Activity chooser settings';
$string['activitychooseractivefooter'] = 'Activity chooser footer';
$string['activitychooseractivefooter_desc'] = 'The activity chooser can support plugins that add items to the footer.';
$string['activitychooserhidefooter'] = 'No footer';
$string['activitychoosertabmode'] = 'Activity chooser tabs';
$string['activitychoosertabmode_desc'] = "The activity chooser enables a teacher to easily select activities and resources to add to their course. This setting determines which tabs should be displayed in it. Note that the starred tab is only displayed for a user if they have starred one or more activities and the recommended tab is only displayed if a site administrator has specified some recommended activities.";
$string['activitychoosertabmodeone'] = 'Starred, All, Activities, Resources, Recommended';
Expand Down

0 comments on commit 089a3ac

Please sign in to comment.