diff --git a/grade/classes/output/export_action_bar.php b/grade/classes/output/export_action_bar.php index 2b96906f739..da513904001 100644 --- a/grade/classes/output/export_action_bar.php +++ b/grade/classes/output/export_action_bar.php @@ -27,9 +27,6 @@ use moodle_url; */ class export_action_bar extends action_bar { - /** @var moodle_url $exportactiveurl The URL that should be set as active in the exports URL selector element. */ - protected $exportactiveurl; - /** @var string $activeplugin The plugin of the current export grades page (xml, ods, ...). */ protected $activeplugin; @@ -37,12 +34,14 @@ class export_action_bar extends action_bar { * The class constructor. * * @param \context $context The context object. - * @param moodle_url $exportactiveurl The URL that should be set as active in the exports URL selector element. + * @param null $unused This parameter has been deprecated since 4.1 and should not be used anymore. * @param string $activeplugin The plugin of the current export grades page (xml, ods, ...). */ - public function __construct(\context $context, moodle_url $exportactiveurl, string $activeplugin) { + public function __construct(\context $context, $unused, string $activeplugin) { + if ($unused !== null) { + debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER); + } parent::__construct($context); - $this->exportactiveurl = $exportactiveurl; $this->activeplugin = $activeplugin; } @@ -85,13 +84,17 @@ class export_action_bar extends action_bar { } $exportsmenu = []; + $exportactiveurl = null; // Generate the data for the exports navigation selector menu. foreach ($exports as $export) { $exportsmenu[$export->link->out()] = $export->string; + if ($export->id == $this->activeplugin) { + $exportactiveurl = $export->link->out(); + } } // This navigation selector menu will contain the links to all available grade export plugin pages. - $exportsurlselect = new \core\output\select_menu('exportas', $exportsmenu, $this->exportactiveurl->out()); + $exportsurlselect = new \core\output\select_menu('exportas', $exportsmenu, $exportactiveurl); $exportsurlselect->set_label(get_string('exportas', 'grades')); $data['exportselector'] = $exportsurlselect->export_for_template($output); diff --git a/grade/classes/output/export_key_manager_action_bar.php b/grade/classes/output/export_key_manager_action_bar.php index b3214934bb5..0b1268c990d 100644 --- a/grade/classes/output/export_key_manager_action_bar.php +++ b/grade/classes/output/export_key_manager_action_bar.php @@ -48,8 +48,7 @@ class export_key_manager_action_bar extends action_bar { } $courseid = $this->context->instanceid; // Get the data used to output the general navigation selector and exports navigation selector. - $exportnavselectors = new export_action_bar($this->context, - new moodle_url('/grade/export/keymanager.php', ['id' => $courseid]), 'keymanager'); + $exportnavselectors = new export_action_bar($this->context, null, 'keymanager'); $data = $exportnavselectors->export_for_template($output); // Add a button to the action bar with a link to the 'add user key' page. diff --git a/grade/classes/output/import_action_bar.php b/grade/classes/output/import_action_bar.php index 123d63fda3d..f96bb57ee1d 100644 --- a/grade/classes/output/import_action_bar.php +++ b/grade/classes/output/import_action_bar.php @@ -27,9 +27,6 @@ use moodle_url; */ class import_action_bar extends action_bar { - /** @var moodle_url $importactiveurl The URL that should be set as active in the imports URL selector element. */ - protected $importactiveurl; - /** @var string $activeplugin The plugin of the current import grades page (xml, csv, ...). */ protected $activeplugin; @@ -37,12 +34,14 @@ class import_action_bar extends action_bar { * The class constructor. * * @param \context $context The context object. - * @param moodle_url $importactiveurl The URL that should be set as active in the imports URL selector element. + * @param null $unused This parameter has been deprecated since 4.1 and should not be used anymore. * @param string $activeplugin The plugin of the current import grades page (xml, csv, ...). */ - public function __construct(\context $context, moodle_url $importactiveurl, string $activeplugin) { + public function __construct(\context $context, $unused, string $activeplugin) { + if ($unused !== null) { + debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER); + } parent::__construct($context); - $this->importactiveurl = $importactiveurl; $this->activeplugin = $activeplugin; } @@ -85,13 +84,17 @@ class import_action_bar extends action_bar { } $importsmenu = []; + $importactiveurl = null; // Generate the data for the imports navigation selector menu. foreach ($imports as $import) { $importsmenu[$import->link->out()] = $import->string; + if ($import->id == $this->activeplugin) { + $importactiveurl = $import->link->out(); + } } // This navigation selector menu will contain the links to all available grade export plugin pages. - $importsurlselect = new \core\output\select_menu('importas', $importsmenu, $this->importactiveurl->out()); + $importsurlselect = new \core\output\select_menu('importas', $importsmenu, $importactiveurl); $importsurlselect->set_label(get_string('importas', 'grades')); $data['importselector'] = $importsurlselect->export_for_template($output); diff --git a/grade/classes/output/import_key_manager_action_bar.php b/grade/classes/output/import_key_manager_action_bar.php index f4ba20c54a1..de421c113d1 100644 --- a/grade/classes/output/import_key_manager_action_bar.php +++ b/grade/classes/output/import_key_manager_action_bar.php @@ -48,8 +48,7 @@ class import_key_manager_action_bar extends action_bar { } $courseid = $this->context->instanceid; // Get the data used to output the general navigation selector and imports navigation selector. - $importnavselectors = new import_action_bar($this->context, - new moodle_url('/grade/import/keymanager.php', ['id' => $courseid]), 'keymanager'); + $importnavselectors = new import_action_bar($this->context, null, 'keymanager'); $data = $importnavselectors->export_for_template($output); // Add a button to the action bar with a link to the 'add user key' page. diff --git a/grade/export/ods/index.php b/grade/export/ods/index.php index 69dc1c6bb35..f3ddf8dee1c 100644 --- a/grade/export/ods/index.php +++ b/grade/export/ods/index.php @@ -33,7 +33,7 @@ $context = context_course::instance($id); require_capability('moodle/grade:export', $context); require_capability('gradeexport/ods:view', $context); -$actionbar = new \core_grades\output\export_action_bar($context, $PAGE->url, 'ods'); +$actionbar = new \core_grades\output\export_action_bar($context, null, 'ods'); print_grade_page_head($COURSE->id, 'export', 'ods', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_ods'), false, false, true, null, null, null, $actionbar); diff --git a/grade/export/txt/index.php b/grade/export/txt/index.php index c21eee12254..3c75d95827b 100644 --- a/grade/export/txt/index.php +++ b/grade/export/txt/index.php @@ -33,7 +33,7 @@ $context = context_course::instance($id); require_capability('moodle/grade:export', $context); require_capability('gradeexport/txt:view', $context); -$actionbar = new \core_grades\output\export_action_bar($context, $PAGE->url, 'txt'); +$actionbar = new \core_grades\output\export_action_bar($context, null, 'txt'); print_grade_page_head($COURSE->id, 'export', 'txt', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_txt'), false, false, true, null, null, null, $actionbar); diff --git a/grade/export/xls/index.php b/grade/export/xls/index.php index 207a0a9bacb..b3f981718ca 100644 --- a/grade/export/xls/index.php +++ b/grade/export/xls/index.php @@ -33,7 +33,7 @@ $context = context_course::instance($id); require_capability('moodle/grade:export', $context); require_capability('gradeexport/xls:view', $context); -$actionbar = new \core_grades\output\export_action_bar($context, $PAGE->url, 'xls'); +$actionbar = new \core_grades\output\export_action_bar($context, null, 'xls'); print_grade_page_head($COURSE->id, 'export', 'xls', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_xls'), false, false, true, null, null, null, $actionbar); diff --git a/grade/export/xml/index.php b/grade/export/xml/index.php index 8091807ff21..320ddf4218a 100644 --- a/grade/export/xml/index.php +++ b/grade/export/xml/index.php @@ -33,7 +33,7 @@ $context = context_course::instance($id); require_capability('moodle/grade:export', $context); require_capability('gradeexport/xml:view', $context); -$actionbar = new \core_grades\output\export_action_bar($context, $PAGE->url, 'xml'); +$actionbar = new \core_grades\output\export_action_bar($context, null, 'xml'); print_grade_page_head($COURSE->id, 'export', 'xml', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_xml'), false, false, true, null, null, null, $actionbar); diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index 7b8513ec5a8..fe4fb921ffe 100644 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -51,7 +51,7 @@ $separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)); $currentgroup = groups_get_course_group($course); -$actionbar = new \core_grades\output\import_action_bar($context, $PAGE->url, 'csv'); +$actionbar = new \core_grades\output\import_action_bar($context, null, 'csv'); print_grade_page_head($course->id, 'import', 'csv', get_string('importcsv', 'grades'), false, false, true, 'importcsv', 'grades', null, $actionbar); diff --git a/grade/import/direct/index.php b/grade/import/direct/index.php index 1d61a18b736..c68b4dc5367 100644 --- a/grade/import/direct/index.php +++ b/grade/import/direct/index.php @@ -47,7 +47,7 @@ $separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)); $currentgroup = groups_get_course_group($course); -$actionbar = new \core_grades\output\import_action_bar($context, $PAGE->url, 'direct'); +$actionbar = new \core_grades\output\import_action_bar($context, null, 'direct'); print_grade_page_head($course->id, 'import', 'direct', get_string('pluginname', 'gradeimport_direct'), false, false, true, 'userdata', 'gradeimport_direct', null, $actionbar); diff --git a/grade/import/xml/index.php b/grade/import/xml/index.php index 9fbb2143e35..3cf315e5a7a 100644 --- a/grade/import/xml/index.php +++ b/grade/import/xml/index.php @@ -87,7 +87,7 @@ if ($data = $mform->get_data()) { } } -$actionbar = new \core_grades\output\import_action_bar($context, $PAGE->url, 'xml'); +$actionbar = new \core_grades\output\import_action_bar($context, null, 'xml'); print_grade_page_head($COURSE->id, 'import', 'xml', get_string('importxml', 'grades'), false, false, true, 'importxml', 'gradeimport_xml', null, $actionbar); diff --git a/grade/upgrade.txt b/grade/upgrade.txt index e0ed9a55bca..ca1cc74209c 100644 --- a/grade/upgrade.txt +++ b/grade/upgrade.txt @@ -1,6 +1,10 @@ This file describes API changes in /grade/* ; Information provided here is intended especially for developers. +=== 4.1 === +* The $importactiveurl parameter in the constructor of the core_grades\output\import_action_bar class has been deprecated and is not used anymore. +* The $exportactiveurl parameter in the constructor of the core_grades\output\export_action_bar class has been deprecated and is not used anymore. + === 4.0 === * The select_in_gradebook_tabs() function in behat_grade.php has been deprecated. Please use the function