MDL-78633 core_course: Improve tertiary navigation in course completion

This commit is contained in:
Amaia Anabitarte 2023-07-04 11:57:12 +02:00
parent ef93325f27
commit b14669a34a
11 changed files with 41 additions and 35 deletions

View File

@ -314,7 +314,7 @@ class manager {
if (has_capability('moodle/course:update', $coursecontext)) {
$completionlink = new moodle_url('/course/completion.php', ['id' => $courseid]);
$options[$completionlink->out(false)] = get_string('coursecompletion', 'completion');
$options[$completionlink->out(false)] = get_string('coursecompletionsettings', 'completion');
}
if (has_capability('moodle/course:manageactivities', $coursecontext)) {

View File

@ -78,6 +78,7 @@ Feature: Allow to mark course as completed without cron for activity completion
And I set the field "completionusegrade" to "1"
And I press "Save and return to course"
And I navigate to "Course completion" in current page administration
And I should see "Course completion settings" in the "tertiary-navigation" "region"
And I expand all fieldsets
And I set the field "Assignment - Test assignment name" to "1"
And I set the field "Assignment - Test assignment name2" to "1"

View File

@ -37,7 +37,7 @@ Feature: Allow teachers to bulk edit activity completion rules in a course.
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I navigate to "Course completion" in current page administration
And I select "Bulk edit activity completion" from the "Course completion tertiary navigation" singleselect
And I set the field "Course completion tertiary navigation" to "Bulk edit activity completion"
And I click on "Test assignment one" "checkbox"
And I click on "Test assignment two" "checkbox"
And I click on "Edit" "button"
@ -68,7 +68,7 @@ Feature: Allow teachers to bulk edit activity completion rules in a course.
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I navigate to "Course completion" in current page administration
And I select "Bulk edit activity completion" from the "Course completion tertiary navigation" singleselect
And I set the field "Course completion tertiary navigation" to "Bulk edit activity completion"
And I click on "Test assignment one" "checkbox"
And I click on "Test assignment two" "checkbox"
And I click on "Edit" "button"

View File

@ -30,7 +30,7 @@ Feature: Allow teachers to edit the default activity completion rules in a cours
| Enable completion tracking | Yes |
And I press "Save and display"
When I navigate to "Course completion" in current page administration
And I select "Default activity completion" from the "Course completion tertiary navigation" singleselect
And I set the field "Course completion tertiary navigation" to "Default activity completion"
And I click on "Assignments" "checkbox"
And I click on "Edit" "button"
And I should see "Completion tracking"

View File

@ -73,8 +73,6 @@ echo $OUTPUT->header();
$actionbar = new \core_course\output\completion_action_bar($course->id, $PAGE->url);
echo $renderer->render_course_completion_action_bar($actionbar);
echo $OUTPUT->heading(get_string('bulkactivitycompletion', 'completion'));
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['theform']);
echo $renderer->bulkcompletion($bulkcompletiondata);

View File

@ -16,6 +16,7 @@
namespace core_course\output;
use core\output\select_menu;
use core_completion\manager;
use moodle_url;
use renderable;
@ -57,12 +58,18 @@ class completion_action_bar implements templatable, renderable {
* completion pages.
*/
public function export_for_template(renderer_base $output): array {
$urlselect = new url_select(manager::get_available_completion_options($this->courseid),
$this->currenturl->out(false), null, 'coursecompletionactionselect');
$urlselect->set_label(get_string('coursecompletionnavigation', 'completion'), ['class' => 'sr-only']);
$selectmenu = new select_menu(
'coursecompletionnavigation',
manager::get_available_completion_options($this->courseid),
$this->currenturl->out(false)
);
$selectmenu->set_label(
get_string('coursecompletionnavigation', 'completion'),
['class' => 'sr-only']
);
return [
'urlselect' => $urlselect->export_for_template($output),
'navigation' => $selectmenu->export_for_template($output),
];
}
}

View File

@ -166,8 +166,6 @@ echo $OUTPUT->header();
$actionbar = new \core_course\output\completion_action_bar($course->id, $PAGE->url);
echo $renderer->render_course_completion_action_bar($actionbar);
echo $OUTPUT->heading(get_string('editcoursecompletionsettings', 'core_completion'));
$form->display();
echo $OUTPUT->footer();

View File

@ -68,8 +68,6 @@ echo $OUTPUT->header();
$actionbar = new \core_course\output\completion_action_bar($course->id, $PAGE->url);
echo $renderer->render_course_completion_action_bar($actionbar);
echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['theform']);
echo $renderer->defaultcompletion($activityresourcedata);

View File

@ -17,37 +17,39 @@
Actions bar in the course completion pages.
Context variables required for this template:
* urlselect - The data object containing the required properties to render core/url_select.
* navigation - The data object containing the required properties to render core/tertiary_navigation_selector.
Example context (json):
{
"urlselect": {
"id": "url_select_test",
"action": "https://example.com/post",
"formid": "url_select_form",
"sesskey": "sesskey",
"classes": "urlselect",
"label": "",
"helpicon": false,
"showbutton": null,
"navigation": {
"name":"coursecompletionnavigation",
"label": "Course completion tertiary navigation",
"value": "\/course\/completion.php?id=4",
"baseid": "select-menu64a40e3ea86ed8",
"selectedoption": "Grader report",
"options": [
{
"name": "Some name",
"value": "/mod/data/someurl.php",
"selected": false
"id": "select-menu-option1",
"name": "Course completion settings",
"value": "/course/completion.php?id=4",
"selected": true
}
],
"disabled": false,
"title": null
"labelattributes":[
{
"name":"class",
"value":"sr-only"
}
]
}
}
}}
<div class="container-fluid tertiary-navigation">
<div class="container-fluid tertiary-navigation border-bottom" id="tertiary-navigation">
<div class="row">
{{#urlselect}}
{{#navigation}}
<div class="navitem">
{{>core/url_select}}
{{>core/tertiary_navigation_selector}}
</div>
{{/urlselect}}
{{/navigation}}
</div>
</div>

View File

@ -130,6 +130,7 @@ $string['coursecompletedmessage'] = '<p>Congratulations!</p><p>You have complete
$string['coursecompletion'] = 'Course completion';
$string['coursecompletioncondition'] = 'Condition: {$a}';
$string['coursecompletionnavigation'] = 'Course completion tertiary navigation';
$string['coursecompletionsettings'] = 'Course completion settings';
$string['coursegrade'] = 'Course grade';
$string['coursesavailable'] = 'Courses available';
$string['coursesavailableexplaination'] = 'Note: Course completion conditions must be set for a course to appear in the above list.';
@ -153,7 +154,6 @@ $string['detail_desc:receivepassgrade'] = 'Receive a passing grade';
$string['detail_desc:view'] = 'View';
$string['done'] = 'Done';
$string['hiddenrules'] = 'Some settings specific to <b>{$a}</b> have been hidden. To view unselect other activities';
$string['editcoursecompletionsettings'] = 'Edit course completion settings';
$string['enablecompletion'] = 'Enable completion tracking';
$string['enablecompletion_help'] = 'If enabled, activity completion conditions may be set in the activity settings and/or course completion conditions may be set. It is recommended to have this enabled so that meaningful data is displayed in the course overview on the Dashboard.';
$string['enrolmentduration'] = 'Enrolment duration';
@ -253,3 +253,4 @@ $string['xdays'] = '{$a} days';
// Deprecated since Moodle 4.0.
$string['yourprogress'] = 'Your progress';
$string['editcoursecompletionsettings'] = 'Edit course completion settings';

View File

@ -79,4 +79,5 @@ selectdevice,core_admin
selecttheme,core_admin
themenoselected,core_admin
unsettheme,core_admin
showmore,core_availability
showmore,core_availability
editcoursecompletionsettings,core_completion