mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 08:00:37 +01:00
Merge branch 'MDL-78502-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE
This commit is contained in:
commit
7b720a1f56
@ -37,14 +37,21 @@ require_login($course);
|
||||
$context = context_course::instance($courseid);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
|
||||
$exportplugins = core_component::get_plugin_list('gradeexport');
|
||||
// Retrieve all grade export plugins the current user can access.
|
||||
$exportplugins = array_filter(core_component::get_plugin_list('gradeexport'),
|
||||
static function(string $exportplugin) use ($context): bool {
|
||||
return has_capability("gradeexport/{$exportplugin}:view", $context);
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
|
||||
if (!empty($exportplugins)) {
|
||||
$exportplugin = array_key_first($exportplugins);
|
||||
$url = new moodle_url("/grade/export/{$exportplugin}/index.php", ['id' => $courseid]);
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
// Otherwise, output the page with a notification stating that there are no available grade import options.
|
||||
// Otherwise, output the page with a notification stating that there are no available grade export options.
|
||||
$PAGE->set_title(get_string('export', 'grades'));
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
@ -37,7 +37,14 @@ require_login($course);
|
||||
$context = context_course::instance($courseid);
|
||||
require_capability('moodle/grade:import', $context);
|
||||
|
||||
$importplugins = core_component::get_plugin_list('gradeimport');
|
||||
// Retrieve all grade import plugins the current user can access.
|
||||
$importplugins = array_filter(core_component::get_plugin_list('gradeimport'),
|
||||
static function(string $importplugin) use ($context): bool {
|
||||
return has_capability("gradeimport/{$importplugin}:view", $context);
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
|
||||
if (!empty($importplugins)) {
|
||||
$importplugin = array_key_first($importplugins);
|
||||
$url = new moodle_url("/grade/import/{$importplugin}/index.php", ['id' => $courseid]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user