MDL-72873 core_grades: Add tertiary navigation in gradebook setup
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core_grades\output;
|
||||
|
||||
use moodle_url;
|
||||
|
||||
/**
|
||||
* Renderable class for the action bar elements in the gradebook setup pages.
|
||||
*
|
||||
* @package core_grades
|
||||
* @copyright 2021 Mihail Geshoski <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class gradebook_setup_action_bar extends action_bar {
|
||||
|
||||
/**
|
||||
* Returns the template for the action bar.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_template(): string {
|
||||
return 'core_grades/gradebook_setup_action_bar';
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
*
|
||||
* @param \renderer_base $output renderer to be used to render the action bar elements.
|
||||
* @return array
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output): array {
|
||||
global $CFG;
|
||||
|
||||
if ($this->context->contextlevel !== CONTEXT_COURSE) {
|
||||
return [];
|
||||
}
|
||||
$courseid = $this->context->instanceid;
|
||||
// Get the data used to output the general navigation selector.
|
||||
$generalnavselector = new general_action_bar($this->context,
|
||||
new moodle_url('/grade/edit/tree/index.php', ['id' => $courseid]), 'settings', 'setup');
|
||||
$data = $generalnavselector->export_for_template($output);
|
||||
|
||||
// Add a button to the action bar with a link to the 'add grade item' page.
|
||||
$addgradeitemlink = new moodle_url('/grade/edit/tree/item.php', ['courseid' => $courseid]);
|
||||
$addgradeitembutton = new \single_button($addgradeitemlink, get_string('additem', 'grades'), 'get');
|
||||
$data['addgradeitembutton'] = $addgradeitembutton->export_for_template($output);
|
||||
|
||||
// If outcomes are enabled, add a button to the action bar with a link to the 'add outcome item' page.
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
$addoutcomeitemlink = new moodle_url('/grade/edit/tree/outcomeitem.php', ['courseid' => $courseid]);
|
||||
$addoutcomeitembutton = new \single_button($addoutcomeitemlink, get_string('addoutcomeitem', 'grades'),
|
||||
'get');
|
||||
$data['addoutcomeitembutton'] = $addoutcomeitembutton->export_for_template($output);
|
||||
}
|
||||
|
||||
// Add a button to the action bar with a link to the 'add category' page.
|
||||
$addcategorylink = new moodle_url('/grade/edit/tree/category.php', ['courseid' => $courseid]);
|
||||
$addcategorybutton = new \single_button($addcategorylink, get_string('addcategory', 'grades'), 'get');
|
||||
$data['addcategorybutton'] = $addcategorybutton->export_for_template($output);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,9 @@ if (grade_regrade_final_grades_if_required($course, $grade_edit_tree_index_check
|
||||
$recreatetree = true;
|
||||
}
|
||||
|
||||
print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'));
|
||||
$actionbar = new \core_grades\output\gradebook_setup_action_bar($context);
|
||||
print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'),
|
||||
false, false, true, null, null, null, $actionbar);
|
||||
|
||||
// Print Table of categories and items
|
||||
echo $OUTPUT->box_start('gradetreebox generalbox');
|
||||
@@ -286,15 +288,6 @@ echo $OUTPUT->container_start('buttons mdl-align');
|
||||
|
||||
if ($moving) {
|
||||
echo $OUTPUT->single_button(new moodle_url('index.php', array('id'=>$course->id)), get_string('cancel'), 'get');
|
||||
} else {
|
||||
echo $OUTPUT->single_button(new moodle_url('item.php', array('courseid' => $course->id)), get_string('additem',
|
||||
'grades'), 'get');
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
echo $OUTPUT->single_button(new moodle_url('outcomeitem.php', array('courseid'=>$course->id)), get_string('addoutcomeitem', 'grades'), 'get');
|
||||
}
|
||||
echo $OUTPUT->single_button(new moodle_url('category.php', array('courseid' => $course->id)), get_string('addcategory',
|
||||
'grades'), 'get');
|
||||
//echo $OUTPUT->(new moodle_url('index.php', array('id'=>$course->id, 'action'=>'autosort')), get_string('autosort', 'grades'), 'get');
|
||||
}
|
||||
|
||||
echo $OUTPUT->container_end();
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_grades/gradebook_setup_action_bar
|
||||
|
||||
Actions bar for the gradebook setup page.
|
||||
|
||||
Context variables required for this template:
|
||||
* generalnavselector - The data object containing the required properties to render the general navigation selector.
|
||||
* addgradeitembutton - The data object containing the required properties to render the 'add grade item' button.
|
||||
* addoutcomeitembutton - The data object containing the required properties to render the 'add outcome item' button.
|
||||
* addcategorybutton - The data object containing the required properties to render the 'add category' button.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"generalnavselector": {
|
||||
"id": "url_select12345",
|
||||
"action": "https://example.com/get",
|
||||
"classes": "urlselect",
|
||||
"formid": "gradesactionselect",
|
||||
"sesskey": "sesskey",
|
||||
"label": "",
|
||||
"helpicon": false,
|
||||
"showbutton": null,
|
||||
"options": [{
|
||||
"name": "View", "isgroup": true, "options":
|
||||
[
|
||||
{"name": "Grader report", "isgroup": false, "value": "/grade/report/grader/index.php"}
|
||||
]},
|
||||
{"name": "Setup", "isgroup": true, "options":
|
||||
[
|
||||
{"name": "Gradebook setup", "isgroup": false, "value": "/grade/edit/tree/index.php"}
|
||||
]}],
|
||||
"disabled": false,
|
||||
"title": null
|
||||
},
|
||||
"addgradeitembutton": {
|
||||
"id": "single_button12345",
|
||||
"method" : "get",
|
||||
"classes": "singlebutton",
|
||||
"formid": null,
|
||||
"url" : "#",
|
||||
"primary" : false,
|
||||
"tooltip" : null,
|
||||
"label" : "Add grade item",
|
||||
"attributes": []
|
||||
},
|
||||
"addoutcomeitembutton": {
|
||||
"id": "single_button13245",
|
||||
"method" : "get",
|
||||
"classes": "singlebutton",
|
||||
"formid": null,
|
||||
"url" : "#",
|
||||
"primary" : false,
|
||||
"tooltip" : null,
|
||||
"label" : "Add outcome item",
|
||||
"attributes": []
|
||||
},
|
||||
"addcategorybutton": {
|
||||
"id": "single_button14325",
|
||||
"method" : "get",
|
||||
"classes": "singlebutton",
|
||||
"formid": null,
|
||||
"url" : "#",
|
||||
"primary" : false,
|
||||
"tooltip" : null,
|
||||
"label" : "Add category",
|
||||
"attributes": []
|
||||
}
|
||||
}
|
||||
}}
|
||||
<div class="container-fluid mb-4">
|
||||
<div class="row">
|
||||
<div class="d-flex">
|
||||
<div>
|
||||
{{#generalnavselector}}
|
||||
{{>core/url_select}}
|
||||
{{/generalnavselector}}
|
||||
</div>
|
||||
{{#addgradeitembutton}}
|
||||
<div class="ml-2">
|
||||
{{>core/single_button}}
|
||||
</div>
|
||||
{{/addgradeitembutton}}
|
||||
{{#addoutcomeitembutton}}
|
||||
<div class="ml-2">
|
||||
{{>core/single_button}}
|
||||
</div>
|
||||
{{/addoutcomeitembutton}}
|
||||
{{#addcategorybutton}}
|
||||
<div class="ml-2">
|
||||
{{>core/single_button}}
|
||||
</div>
|
||||
{{/addcategorybutton}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user