Skip to content

Commit

Permalink
MDL-75155 grades: Use the select_menu widget
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Sep 6, 2022
1 parent 5d33ef3 commit fa59f35
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 34 deletions.
4 changes: 2 additions & 2 deletions grade/classes/output/export_action_bar.php
Expand Up @@ -91,8 +91,8 @@ public function export_for_template(\renderer_base $output): array {
}

// 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;
Expand Down
4 changes: 2 additions & 2 deletions grade/classes/output/import_action_bar.php
Expand Up @@ -91,8 +91,8 @@ public function export_for_template(\renderer_base $output): array {
}

// 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;
Expand Down
35 changes: 21 additions & 14 deletions grade/templates/export_action_bar.mustache
Expand Up @@ -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
]
}
}
}}
Expand All @@ -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>
35 changes: 21 additions & 14 deletions grade/templates/import_action_bar.mustache
Expand Up @@ -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
]
}
}
}}
Expand All @@ -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>
4 changes: 2 additions & 2 deletions grade/tests/behat/behat_grade.php
Expand Up @@ -349,7 +349,7 @@ public function i_navigate_to_in_the_course_gradebook($gradepath) {
*/
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]);
}

/**
Expand All @@ -364,7 +364,7 @@ public function i_navigate_to_import_page_in_the_course_gradebook($gradeimportop
*/
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]);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lang/en/grades.php
Expand Up @@ -212,6 +212,7 @@
$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.';
Expand Down Expand Up @@ -400,6 +401,7 @@
$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:
Expand Down

0 comments on commit fa59f35

Please sign in to comment.