MDL-75153 grade: Update the general tertiary nav selector in gradebook

Updates the general tertiary nav selector in gradebook to use the new
structure that utilizes the existing select_menu output component.
This commit is contained in:
Mihail Geshoski 2022-09-12 14:07:31 +08:00
parent 2b99e648cb
commit 0e1cdfde1d
16 changed files with 405 additions and 224 deletions

View File

@ -17,6 +17,7 @@
namespace core_grades\output;
use moodle_url;
use core\output\select_menu;
/**
* Renderable class for the general action bar in the gradebook pages.
@ -65,14 +66,14 @@ class general_action_bar extends action_bar {
* @return array
*/
public function export_for_template(\renderer_base $output): array {
$urlselect = $this->get_action_selector();
$selectmenu = $this->get_action_selector();
if (is_null($urlselect)) {
if (is_null($selectmenu)) {
return [];
}
return [
'generalnavselector' => $urlselect->export_for_template($output),
'generalnavselector' => $selectmenu->export_for_template($output),
];
}
@ -88,9 +89,9 @@ class general_action_bar extends action_bar {
/**
* Returns the URL selector object.
*
* @return \url_select|null The URL select object.
* @return \select_menu|null The URL select object.
*/
private function get_action_selector(): ?\url_select {
private function get_action_selector(): ?select_menu {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return null;
}
@ -186,6 +187,9 @@ class general_action_bar extends action_bar {
$menu[][get_string('moremenu')] = $moregroup;
}
return new \url_select($menu, $this->activeurl->out(false), null, 'gradesactionselect');
$selectmenu = new select_menu('gradesactionselect', $menu, $this->activeurl->out(false));
$selectmenu->set_label(get_string('gradebooknavigationmenu', 'grades'), ['class' => 'sr-only']);
return $selectmenu;
}
}

View File

@ -23,25 +23,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56789",
"selectedoption": "Outcomes",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Outcomes",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"manageoutcomesbutton": {
"id": "single_button12345",
@ -60,7 +77,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#manageoutcomesbutton}}

View File

@ -23,25 +23,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56788",
"selectedoption": "Export",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Export",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"exportselector": {
"name": "exportas",
@ -70,7 +87,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#exportselector}}

View File

@ -24,44 +24,63 @@
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
},
"exportselector": {
"id": "url_select56789",
"action": "https://example.com/get",
"formid": "gradesexportactionselect",
"sesskey": "sesskey",
"classes": "urlselect",
"label": "",
"helpicon": false,
"showbutton": null,
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56788",
"selectedoption": "Export",
"options": [
{
"name": "OpenDocument spreadsheet",
"value": "/grade/export/ods/index.php",
"selected": true
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Export",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"exportselector": {
"name": "exportas",
"value": "https://example.com/grade/export/keymanager.php",
"baseid": "select-menu56789",
"label": "Export as",
"labelattributes": [
{
"name": "class",
"value": "font-weight-bold"
}
],
"disabled": false,
"title": null
"selectedoption": "Key manager",
"options": [
{
"name": "Key manager",
"value": "https://example.com/grade/export/keymanager.php",
"selected": true,
"id": "select-menu-option56789"
}
]
},
"adduserkeybutton": {
"id": "single_button12345",
@ -80,13 +99,18 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#exportselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/select_menu}}
</div>
{{#js}}
document.querySelector('#{{baseid}}').addEventListener('change', function(e) {
window.location.href = e.target.value;
});
{{/js}}
{{/exportselector}}
{{#adduserkeybutton}}
<div class="navitem">

View File

@ -22,25 +22,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt1",
"baseid": "select-menu56789",
"selectedoption": "Grader report",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": true
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Import",
"value": "opt2",
"id": "select-menu-option2",
"selected": false
}
]
}
}
]
}
}
}}
@ -48,7 +65,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
</div>

View File

@ -23,25 +23,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56789",
"selectedoption": "Import",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Grade letters",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"editbutton": {
"id": "single_button12345",
@ -60,7 +77,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#editbutton}}

View File

@ -25,25 +25,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56789",
"selectedoption": "Gradebook setup",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "Setup",
"id": "select-menu-group2",
"options": [
{
"name": "Gradebook setup",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"addgradeitembutton": {
"id": "single_button12345",
@ -84,7 +101,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#addgradeitembutton}}

View File

@ -23,25 +23,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56788",
"selectedoption": "Import",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Import",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"importselector": {
"name": "importas",
@ -70,7 +87,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#importselector}}

View File

@ -17,51 +17,70 @@
Actions bar for the gradebook imports key manager page.
Context variables required for this template:
* generalnavselector - The data object containing the required properties to render core/url_select.
* generalnavselector - The data object containing the required properties to render the tertiary navigation selector.
* importselector - The data object containing the required properties to render the import options selector.
* adduserkeybutton - The data object containing the required properties to render the 'add user key' 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
},
"importselector": {
"id": "url_select56789",
"action": "https://example.com/get",
"formid": "gradesimportactionselect",
"sesskey": "sesskey",
"classes": "urlselect",
"label": "",
"helpicon": false,
"showbutton": null,
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56788",
"selectedoption": "Import",
"options": [
{
"name": "CSV file",
"value": "/grade/import/csv/index.php",
"selected": true
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group1",
"options": [
{
"name": "Import",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"importselector": {
"name": "importas",
"value": "https://example.com/grade/import/keymanager.php",
"baseid": "select-menu56789",
"label": "Import as",
"labelattributes": [
{
"name": "class",
"value": "font-weight-bold"
}
],
"disabled": false,
"title": null
"selectedoption": "Key manager",
"options": [
{
"name": "Key manager",
"value": "https://example.com/grade/import/keymanager.php",
"selected": true,
"id": "select-menu-option56789"
}
]
},
"adduserkeybutton": {
"id": "single_button12345",
@ -80,13 +99,18 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#importselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/select_menu}}
</div>
{{#js}}
document.querySelector('#{{baseid}}').addEventListener('change', function(e) {
window.location.href = e.target.value;
});
{{/js}}
{{/importselector}}
{{#adduserkeybutton}}
<div class="navitem">

View File

@ -23,25 +23,42 @@
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
"name": "Gradebook tertiary navigation selector",
"value": "opt2",
"baseid": "select-menu56789",
"selectedoption": "Scales",
"options": [
{
"selected": false,
"isgroup": {
"name": "View",
"id": "select-menu-group1",
"options": [
{
"name": "Grader report",
"value": "opt1",
"id": "select-menu-option1",
"selected": false
}
]
}
},
{
"selected": false,
"isgroup": {
"name": "More",
"id": "select-menu-group2",
"options": [
{
"name": "Scales",
"value": "opt2",
"id": "select-menu-option2",
"selected": true
}
]
}
}
]
},
"addnewscalebutton": {
"id": "single_button12345",
@ -60,7 +77,7 @@
<div class="row">
{{#generalnavselector}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/generalnavselector}}
{{#addnewscalebutton}}

View File

@ -334,7 +334,7 @@ class behat_grade extends behat_base {
$this->execute('behat_navigation::i_select_from_secondary_navigation', get_string('grades'));
}
$this->select_in_gradebook_navigation_selector($gradepath, 'gradesactionselect');
$this->execute('behat_forms::i_set_the_field_to', [get_string('gradebooknavigationmenu', 'grades'), $gradepath]);
}
/**

View File

@ -262,6 +262,7 @@ $string['gradebookcalculationswarning'] = 'Note: Some errors have been detected
The newer version is {$a->currentversion}; you are using gradebook version {$a->gradebookversion}. You can see a list of changes in <a href="{$a->url}">Gradebook calculation changes</a>.';
$string['gradebookhiddenerror'] = 'The gradebook is currently set to hide everything from students.';
$string['gradebooknavigationmenu'] = 'Gradebook navigation menu';
$string['gradebookhistories'] = 'Grade histories';
$string['gradebooksetup'] = 'Gradebook setup';
$string['gradeboundary'] = 'Letter grade boundary';

View File

@ -33,7 +33,6 @@
.path-grade-report-grader {
#region-main {
overflow-x: visible;
min-width: 100%;
width: auto;
display: flex;
@ -62,6 +61,12 @@
}
}
.path-grade {
#region-main {
overflow-x: visible;
}
}
// Rubrics
#page-grade-grading-manage {
#activemethodselector {

View File

@ -19387,7 +19387,6 @@ p.arrow_button {
left: 40vw; }
.path-grade-report-grader #region-main {
overflow-x: visible;
min-width: 100%;
width: auto;
display: flex;
@ -19410,6 +19409,9 @@ p.arrow_button {
.path-grade-report-user .gradefail {
color: #ca3120; }
.path-grade #region-main {
overflow-x: visible; }
#page-grade-grading-manage #activemethodselector label {
display: inline-block; }

View File

@ -19387,7 +19387,6 @@ p.arrow_button {
left: 40vw; }
.path-grade-report-grader #region-main {
overflow-x: visible;
min-width: 100%;
width: auto;
display: flex;
@ -19410,6 +19409,9 @@ p.arrow_button {
.path-grade-report-user .gradefail {
color: #ca3120; }
.path-grade #region-main {
overflow-x: visible; }
#page-grade-grading-manage #activemethodselector label {
display: inline-block; }

View File

@ -52,6 +52,6 @@ class behat_theme_classic_behat_grade extends behat_grade {
get_string('pluginname', 'block_navigation'), 'block'));
}
$this->select_in_gradebook_navigation_selector($gradepath, 'gradesactionselect');
$this->execute('behat_forms::i_set_the_field_to', [get_string('gradebooknavigationmenu', 'grades'), $gradepath]);
}
}