Skip to content

Commit

Permalink
MDL-78286 core_courseformat: Add direct link to edit completion settings
Browse files Browse the repository at this point in the history
  • Loading branch information
roland04 committed Aug 8, 2023
1 parent 1474f74 commit 848a90d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 1 deletion.
10 changes: 9 additions & 1 deletion course/format/classes/output/local/content/cm/completion.php
Expand Up @@ -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) {
Expand Down
Expand Up @@ -93,4 +93,13 @@
{{/istrackeduser}}
{{/ismanual}}
</div>

{{! Show edit link to editing teachers. }}
{{#editing}}
{{#editurl}}
<div class="editcompletion border-top mt-3 pt-3">
<a href="{{editurl}}" class="px-2 py-1">{{#pix}} i/edit, core {{/pix}}{{#str}}editconditions, completion{{/str}}</a>
</div>
{{/editurl}}
{{/editing}}
</div>
17 changes: 17 additions & 0 deletions course/format/tests/behat/coursepage_completion.feature
Expand Up @@ -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"
1 change: 1 addition & 0 deletions lang/en/completion.php
Expand Up @@ -154,6 +154,7 @@
$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['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';
Expand Down
9 changes: 9 additions & 0 deletions theme/boost/scss/moodle/course.scss
Expand Up @@ -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;
}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions theme/boost/style/moodle.css
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions theme/classic/style/moodle.css
Expand Up @@ -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;
Expand Down

0 comments on commit 848a90d

Please sign in to comment.