MDL-75155 grades: Use the select_menu widget

This commit is contained in:
Shamim Rezaie 2022-08-09 14:49:58 +10:00
parent 5d33ef3c21
commit fa59f35ca4
6 changed files with 50 additions and 34 deletions

View File

@ -91,8 +91,8 @@ class export_action_bar extends action_bar {
}
// This navigation selector menu will contain the links to all available grade export plugin pages.
$exportsurlselect = new \url_select($exportsmenu, $this->exportactiveurl->out(false), null,
'gradesexportactionselect');
$exportsurlselect = new \core\output\select_menu('exportas', $exportsmenu, $this->exportactiveurl->out());
$exportsurlselect->set_label(get_string('exportas', 'grades'));
$data['exportselector'] = $exportsurlselect->export_for_template($output);
return $data;

View File

@ -91,8 +91,8 @@ class import_action_bar extends action_bar {
}
// This navigation selector menu will contain the links to all available grade export plugin pages.
$importsurlselect = new \url_select($importsmenu, $this->importactiveurl->out(false), null,
'gradesimportactionselect');
$importsurlselect = new \core\output\select_menu('importas', $importsmenu, $this->importactiveurl->out());
$importsurlselect->set_label(get_string('importas', 'grades'));
$data['importselector'] = $importsurlselect->export_for_template($output);
return $data;

View File

@ -44,23 +44,25 @@
"title": null
},
"exportselector": {
"id": "url_select56789",
"action": "https://example.com/get",
"formid": "gradesexportactionselect",
"sesskey": "sesskey",
"classes": "urlselect",
"label": "",
"helpicon": false,
"showbutton": null,
"name": "exportas",
"value": "https://example.com/grade/export/ods/index.php",
"baseid": "select-menu56789",
"label": "Export as",
"labelattributes": [
{
"name": "class",
"value": "font-weight-bold"
}
],
"selectedoption": "OpenDocument spreadsheet",
"options": [
{
"name": "OpenDocument spreadsheet",
"value": "/grade/export/ods/index.php",
"selected": true
"value": "https://example.com/grade/export/ods/index.php",
"selected": true,
"id": "select-menu-option56789"
}
],
"disabled": false,
"title": null
]
}
}
}}
@ -73,8 +75,13 @@
{{/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}}
</div>
</div>

View File

@ -44,23 +44,25 @@
"title": null
},
"importselector": {
"id": "url_select56789",
"action": "https://example.com/get",
"formid": "gradesimportactionselect",
"sesskey": "sesskey",
"classes": "urlselect",
"label": "",
"helpicon": false,
"showbutton": null,
"name": "importas",
"value": "https://example.com/grade/import/csv/index.php",
"baseid": "select-menu56789",
"label": "Import as",
"labelattributes": [
{
"name": "class",
"value": "font-weight-bold"
}
],
"selectedoption": "CSV file",
"options": [
{
"name": "CSV file",
"value": "/grade/import/csv/index.php",
"selected": true
"value": "https://example.com/grade/import/csv/index.php",
"selected": true,
"id": "select-menu-option56789"
}
],
"disabled": false,
"title": null
]
}
}
}}
@ -73,8 +75,13 @@
{{/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}}
</div>
</div>

View File

@ -349,7 +349,7 @@ class behat_grade extends behat_base {
*/
public function i_navigate_to_import_page_in_the_course_gradebook($gradeimportoption) {
$this->i_navigate_to_in_the_course_gradebook("More > Import");
$this->select_in_gradebook_navigation_selector($gradeimportoption, 'gradesimportactionselect');
$this->execute('behat_forms::i_set_the_field_to', [get_string('importas', 'grades'), $gradeimportoption]);
}
/**
@ -364,7 +364,7 @@ class behat_grade extends behat_base {
*/
public function i_navigate_to_export_page_in_the_course_gradebook($gradeexportoption) {
$this->i_navigate_to_in_the_course_gradebook("More > Export");
$this->select_in_gradebook_navigation_selector($gradeexportoption, 'gradesexportactionselect');
$this->execute('behat_forms::i_set_the_field_to', [get_string('exportas', 'grades'), $gradeexportoption]);
}
/**

View File

@ -212,6 +212,7 @@ $string['excluded_help'] = 'If ticked, the grade will not be included in any agg
$string['expand'] = 'Expand category';
$string['expandcriterion'] = 'Expand criterion';
$string['export'] = 'Export';
$string['exportas'] = 'Export as';
$string['exportalloutcomes'] = 'Export all outcomes';
$string['exportfeedback'] = 'Include feedback in export';
$string['exportfeedback_desc'] = 'This can be overridden during export.';
@ -400,6 +401,7 @@ $string['identifier'] = 'Identify user by';
$string['idnumbers'] = 'ID numbers';
$string['ignore'] = 'Ignore';
$string['import'] = 'Import';
$string['importas'] = 'Import as';
$string['importcsv'] = 'Import CSV';
$string['importcsv_help'] = 'Grades can be imported via a CSV file with format as follows: