MDL-68928 core_course: Select activity chooser footer
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
b81952a23d
commit
fbbfe9aa00
@@ -184,6 +184,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
// 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',
|
||||
@@ -197,6 +198,31 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// 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'),
|
||||
|
||||
@@ -4381,15 +4381,10 @@ class core_course_external extends external_api {
|
||||
$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(),
|
||||
|
||||
@@ -68,6 +68,9 @@ define('COURSE_DB_QUERY_LIMIT', 1000);
|
||||
/** 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':
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user