diff --git a/course/format/classes/output/local/content/cm/completion.php b/course/format/classes/output/local/content/cm/completion.php index aac38a1aa66..de375b5b9d5 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 @@ class completion implements named_templatable, renderable { * @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 f59edfe4804..61005ec4cae 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 24267e2628e..4a6489bf384 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 52e0cc8fc61..fddc90898c3 100644 --- a/lang/en/completion.php +++ b/lang/en/completion.php @@ -154,6 +154,7 @@ $string['detail_desc:receivepassgrade'] = 'Receive a passing grade'; $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, you can set conditions for activity completion or course completion.'; $string['enrolmentduration'] = 'Enrolment duration'; diff --git a/theme/boost/scss/moodle/course.scss b/theme/boost/scss/moodle/course.scss index 10456dff365..7c7b41ee9dc 100644 --- a/theme/boost/scss/moodle/course.scss +++ b/theme/boost/scss/moodle/course.scss @@ -1606,6 +1606,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 20040d7aa86..e3741b78c7e 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -29393,6 +29393,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 6702e116674..d0639a9e9d1 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -29393,6 +29393,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;