From 848a90d1e5781482b039e685bfa543ce44ff2848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikel=20Mart=C3=ADn?= Date: Thu, 27 Jul 2023 16:21:24 +0200 Subject: [PATCH] MDL-78286 core_courseformat: Add direct link to edit completion settings --- .../output/local/content/cm/completion.php | 10 +++++++++- .../local/content/cm/completion_dialog.mustache | 9 +++++++++ .../tests/behat/coursepage_completion.feature | 17 +++++++++++++++++ lang/en/completion.php | 1 + theme/boost/scss/moodle/course.scss | 9 +++++++++ theme/boost/style/moodle.css | 9 +++++++++ theme/classic/style/moodle.css | 9 +++++++++ 7 files changed, 63 insertions(+), 1 deletion(-) diff --git a/course/format/classes/output/local/content/cm/completion.php b/course/format/classes/output/local/content/cm/completion.php index aac38a1aa668e..de375b5b9d589 100644 --- a/course/format/classes/output/local/content/cm/completion.php +++ b/course/format/classes/output/local/content/cm/completion.php @@ -102,10 +102,18 @@ public function export_for_template(\renderer_base $output): ?stdClass { * @return array the completion dialog exported for template */ private function get_completion_dialog(\renderer_base $output, stdClass $completioninfo): array { + global $PAGE; + + $editurl = new \moodle_url( + '/course/modedit.php', + ['update' => $this->mod->id, 'showonly' => 'activitycompletionheader'] + ); + $completioninfo->editurl = $editurl->out(false); + $completioninfo->editing = $PAGE->user_is_editing(); $dialogcontent = $output->render_from_template('core_courseformat/local/content/cm/completion_dialog', $completioninfo); + $buttoncontent = get_string('completionmenuitem', 'completion'); $buttonclass = ''; - if ($completioninfo->istrackeduser) { $buttoncontent = get_string('todo', 'completion'); if ($completioninfo->overallcomplete) { diff --git a/course/format/templates/local/content/cm/completion_dialog.mustache b/course/format/templates/local/content/cm/completion_dialog.mustache index f59edfe4804a4..61005ec4cae6a 100644 --- a/course/format/templates/local/content/cm/completion_dialog.mustache +++ b/course/format/templates/local/content/cm/completion_dialog.mustache @@ -93,4 +93,13 @@ {{/istrackeduser}} {{/ismanual}} + + {{! Show edit link to editing teachers. }} + {{#editing}} + {{#editurl}} +
+ {{#pix}} i/edit, core {{/pix}}{{#str}}editconditions, completion{{/str}} +
+ {{/editurl}} + {{/editing}} diff --git a/course/format/tests/behat/coursepage_completion.feature b/course/format/tests/behat/coursepage_completion.feature index 24267e2628ec2..4a6489bf3840c 100644 --- a/course/format/tests/behat/coursepage_completion.feature +++ b/course/format/tests/behat/coursepage_completion.feature @@ -70,3 +70,20 @@ Feature: Course page activities completion And I am on the "Course 1" course page And "To do" "button" should not exist in the "Activity sample" "activity" And the "View" item should exist in the "Done" dropdown of the "Activity sample" "activity" + + Scenario: Teacher can edit activity completion using completion dialog link + Given the following "activity" exists: + | activity | assign | + | name | Activity sample | + | course | C1 | + | completion | 2 | + | completionview | 1 | + When I am on the "C1" "Course" page logged in as "teacher1" + # Edit conditions link should not be displayed when editing mode is off. + Then "Edit conditions" "link" should not exist in the "Activity sample" "core_courseformat > Activity completion" + # Edit conditions link should be displayed when editing mode is on. + But I am on "C1" course homepage with editing mode on + And I click on "Edit conditions" "link" in the "Activity sample" "core_courseformat > Activity completion" + And I should see "Activity sample" in the "page-header" "region" + And I should see "Updating: Assignment" + And I should see "Activity completion" diff --git a/lang/en/completion.php b/lang/en/completion.php index bd2155400aa96..b2fe53e155567 100644 --- a/lang/en/completion.php +++ b/lang/en/completion.php @@ -154,6 +154,7 @@ $string['detail_desc:view'] = 'View'; $string['done'] = 'Done'; $string['hiddenrules'] = 'Some settings specific to {$a} have been hidden. To view unselect other activities'; +$string['editconditions'] = 'Edit conditions'; $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'; diff --git a/theme/boost/scss/moodle/course.scss b/theme/boost/scss/moodle/course.scss index 56c78d67eb4e3..196a41ba3e2a4 100644 --- a/theme/boost/scss/moodle/course.scss +++ b/theme/boost/scss/moodle/course.scss @@ -1603,6 +1603,15 @@ $activity-add-hover: theme-color-level('primary', -10) !default; height: $font-size-sm; margin-right: map-get($spacers, 1); } + .editcompletion a { + @include border-radius(); + color: $gray-700; + font-weight: bold; + text-decoration: none; + &:hover { + background-color: $gray-200; + } + } } } diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css index d8eaad610c582..f9fdb41cdbb8d 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -29355,6 +29355,15 @@ span.editinstructions .alert-link { height: 0.8203125rem; margin-right: 0.25rem; } +.activity-item .activity-completion .completion-dialog .editcompletion a { + border-radius: 0.5rem; + color: #495057; + font-weight: bold; + text-decoration: none; +} +.activity-item .activity-completion .completion-dialog .editcompletion a:hover { + background-color: #e9ecef; +} .activity-item .activity-groupmode-info { grid-area: groupmode; justify-self: end; diff --git a/theme/classic/style/moodle.css b/theme/classic/style/moodle.css index 30666dc171d98..92e66967bf41b 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -29355,6 +29355,15 @@ span.editinstructions .alert-link { height: 0.8203125rem; margin-right: 0.25rem; } +.activity-item .activity-completion .completion-dialog .editcompletion a { + border-radius: 0.25rem; + color: #495057; + font-weight: bold; + text-decoration: none; +} +.activity-item .activity-completion .completion-dialog .editcompletion a:hover { + background-color: #e9ecef; +} .activity-item .activity-groupmode-info { grid-area: groupmode; justify-self: end;