Merge branch 'MDL-78280-master' of https://github.com/roland04/moodle

This commit is contained in:
Andrew Nicols 2023-07-20 00:03:15 +08:00 committed by Ilya Tregubov
commit 0eaafc713c
No known key found for this signature in database
GPG Key ID: 0F58186F748E55C1
29 changed files with 399 additions and 124 deletions

View File

@ -222,6 +222,15 @@ class cm_completion_details {
return $this->cminfo->completion == COMPLETION_TRACKING_AUTOMATIC;
}
/**
* Whether this activity module instance tracks completion manually.
*
* @return bool
*/
public function is_manual(): bool {
return $this->cminfo->completion == COMPLETION_TRACKING_MANUAL;
}
/**
* Fetches the user ID that has overridden the completion state of this activity for the user.
*
@ -248,6 +257,10 @@ class cm_completion_details {
public function show_manual_completion(): bool {
global $PAGE;
if (!$this->is_manual()) {
return false;
}
if ($PAGE->context->contextlevel == CONTEXT_MODULE) {
// Manual completion should always be shown on the activity page.
return true;

View File

@ -157,7 +157,7 @@ class behat_completion extends behat_base {
/**
* Checks if the activity with specified name is maked as complete.
*
* @Given /^the "(?P<conditionname>(?:[^"]|\\")*)" completion condition of "(?P<activityname>(?:[^"]|\\")*)" is displayed as "(?P<completionstatus>(?:[^"]|\\")*)"$/
* @When the :conditionname completion condition of :activityname is displayed as :completionstatus
* @param string $conditionname The completion condition text.
* @param string $activityname The activity name.
* @param string $completionstatus The completion status. Must be either of the following: 'todo', 'done', 'failed'.
@ -169,7 +169,7 @@ class behat_completion extends behat_base {
throw new coding_exception('Invalid completion status. It must be of type "todo", "done", or "failed".');
}
$text = get_string("completion_automatic:$completionstatus", 'core_course') . ' ' . $conditionname;
$text = get_string("completion_automatic:$completionstatus", 'core_course');
$conditionslistlabel = get_string('completionrequirements', 'core_course', $activityname);
$selector = "div[aria-label='$conditionslistlabel']";
@ -178,20 +178,21 @@ class behat_completion extends behat_base {
// If there is a dropdown, open it.
$dropdownnode = $this->find('css', $selector . ' .dropdown-menu');
if (!$dropdownnode->hasClass('show')) {
$params = [get_string('completionmenuitem', 'completion'), "button", $selector, "css_element"];
$params = ["button.dropdown-toggle", "css_element", $selector, "css_element"];
$this->execute("behat_general::i_click_on_in_the", $params);
}
} catch (ElementNotFoundException $e) {
// If the dropdown does not exist, we are in the activity page, all good.
}
$this->execute("behat_general::assert_element_contains_text", [$text, $selector, "css_element"]);
$xpath = "//div[@aria-label='$conditionslistlabel']//span[text()='$conditionname']/..";
$this->execute("behat_general::assert_element_contains_text", [$text, $xpath, "xpath_element"]);
}
/**
* Checks if the activity with specified name is maked as complete.
*
* @Given /^the "(?P<conditionname>(?:[^"]|\\")*)" completion condition of "(?P<activityname>(?:[^"]|\\")*)" overridden by "(?P<username>(?:[^"]|\\")*)" is displayed as "(?P<completionstatus>(?:[^"]|\\")*)"$/
* @When the :conditionname completion condition of :activityname overridden by :username is displayed as :completionstatus
* @param string $conditionname The completion condition text.
* @param string $activityname The activity name.
* @param string $username The full name of the user overriding the student's activity completion.
@ -207,7 +208,7 @@ class behat_completion extends behat_base {
'condition' => $conditionname,
'setby' => $username,
]);
$conditionbadge = "span[aria-label='$conditionlabel']";
$conditionbadge = "div[aria-label='$conditionlabel']";
$conditionslistlabel = get_string('completionrequirements', 'core_course', $activityname);
$completionconditions = "div[aria-label='$conditionslistlabel']";
@ -336,13 +337,24 @@ class behat_completion extends behat_base {
/**
* Check that the activity has the given automatic completion condition.
*
* @Given /^"(?P<activityname>(?:[^"]|\\")*)" should have the "(?P<conditionname>(?:[^"]|\\")*)" completion condition$/
* @When :activityname should have the :conditionname completion condition
* @param string $activityname The activity name.
* @param string $conditionname The automatic condition name.
*/
public function activity_should_have_the_completion_condition(string $activityname, string $conditionname): void {
$containerselector = "div[data-region=activity-information][data-activityname='$activityname']";
try {
// If there is a dropdown, open it.
$dropdownnode = $this->find('css', $containerselector . ' .dropdown-menu');
if (!$dropdownnode->hasClass('show')) {
$params = ["button.dropdown-toggle", "css_element", $containerselector, "css_element"];
$this->execute("behat_general::i_click_on_in_the", $params);
}
} catch (ElementNotFoundException $e) {
// If the dropdown does not exist, we are in the activity page, all good.
}
$params = [$conditionname, $containerselector, 'css_element'];
$this->execute("behat_general::assert_element_contains_text", $params);
}

View File

@ -1,4 +1,4 @@
@core @core_completion
@core @core_completion @javascript
Feature: Show activity completion status or activity completion configuration on the course page
In order to understand the configuration or status of an activity's completion
As a user
@ -38,16 +38,16 @@ Feature: Show activity completion status or activity completion configuration on
Scenario: Show completion configuration to editing teachers
Given I am on the "Course 1" course page logged in as teacher1
And the manual completion button for "Test forum name" should be disabled
And "Test forum name" should have the "Mark as done" completion condition
And "Test assignment name" should have the "View" completion condition
And there should be no completion information shown for "Test quiz name"
And I am on "Course 1" course homepage with editing mode on
And the manual completion button for "Test forum name" should be disabled
And "Test forum name" should have the "Mark as done" completion condition
And "Test assignment name" should have the "View" completion condition
And there should be no completion information shown for "Test quiz name"
Scenario: Show completion configuration to non-editing teachers
Given I am on the "Course 1" course page logged in as teacher2
And the manual completion button for "Test forum name" should be disabled
And "Test forum name" should have the "Mark as done" completion condition
And "Test assignment name" should have the "View" completion condition
And there should be no completion information shown for "Test quiz name"

View File

@ -18,13 +18,14 @@ Feature: Allow teachers to edit the visibility of completion conditions in a cou
| activity | course | idnumber | name | completion | completionsubmit |
| choice | C1 | c1m | Test choice manual| 1 | 0 |
| choice | C1 | c1a | Test choice auto | 2 | 1 |
@javascript
Scenario: Completion condition displaying for manual and auto completion
Given I log in as "teacher1"
When I am on "Course 1" course homepage
# The manual completion toggle button should be always displayed in both course homepage and activity view.
Then the manual completion button for "Test choice manual" should be disabled
# The manual completion "Mark as done" criteria should displayed in the dropdown in the course homepage.
Then "Test choice manual" should have the "Mark as done" completion condition
And I follow "Test choice manual"
# The manual completion toggle button should be displayed in activity view.
And the manual completion button for "Test choice manual" should be disabled
# Automatic completion conditions should be displayed on both activity view page and course homepage if show completion conditions is enabled.
And I am on "Course 1" course homepage

View File

@ -41,6 +41,7 @@ require_once($CFG->libdir . '/completionlib.php');
* @package core_completion
* @copyright 2021 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \core_completion\cm_completion_details
*/
class cm_completion_details_test extends advanced_testcase {
@ -121,6 +122,7 @@ class cm_completion_details_test extends advanced_testcase {
/**
* Test for has_completion().
*
* @covers ::has_completion
* @dataProvider has_completion_provider
* @param int $completion The completion tracking mode.
* @param bool $expectedresult Expected result.
@ -153,6 +155,7 @@ class cm_completion_details_test extends advanced_testcase {
/**
* Test for is_available().
*
* @covers ::is_automatic
* @dataProvider is_automatic_provider
* @param int $completion The completion tracking mode.
* @param bool $expectedresult Expected result.
@ -163,6 +166,39 @@ class cm_completion_details_test extends advanced_testcase {
$this->assertEquals($expectedresult, $cmcompletion->is_automatic());
}
/**
* Provides data for test_is_manual().
*
* @return array[]
*/
public function is_manual_provider(): array {
return [
'Automatic' => [
COMPLETION_TRACKING_AUTOMATIC, false
],
'Manual' => [
COMPLETION_TRACKING_MANUAL, true
],
'None' => [
COMPLETION_TRACKING_NONE, false
],
];
}
/**
* Test for is_manual().
*
* @covers ::is_manual
* @dataProvider is_manual_provider
* @param int $completion The completion tracking mode.
* @param bool $expectedresult Expected result.
*/
public function test_is_manual(int $completion, bool $expectedresult) {
$cmcompletion = $this->setup_data($completion);
$this->assertEquals($expectedresult, $cmcompletion->is_manual());
}
/**
* Data provider for test_get_overall_completion().
* @return array[]
@ -177,6 +213,7 @@ class cm_completion_details_test extends advanced_testcase {
/**
* Test for get_overall_completion().
*
* @covers ::get_overall_completion
* @dataProvider overall_completion_provider
* @param int $state
*/
@ -316,6 +353,7 @@ class cm_completion_details_test extends advanced_testcase {
/**
* Test for \core_completion\cm_completion_details::get_details().
*
* @covers ::get_details
* @dataProvider get_details_provider
* @param int $completion The completion tracking mode.
* @param int|null $completionview Completion status of the "view" completion condition.
@ -415,6 +453,7 @@ class cm_completion_details_test extends advanced_testcase {
/**
* Test custom sort order is functioning in \core_completion\cm_completion_details::get_details().
*
* @covers ::get_details
* @dataProvider get_details_custom_order_provider
* @param bool $completionview Completion status of the "view" completion condition.
* @param bool $completiongrade Completion status of the "must receive grade" completion condition.

View File

@ -4,6 +4,7 @@ information provided here is intended especially for developers.
=== 4.3 ===
* A trait class, core_completion/form/form_trait has been added to reuse code for adding and validation completion settings to any
form.
* New method is_manual() has been added to `core_completion/cm_completion_details`
=== 4.0 ===
* New method mark_course_completions_activity_criteria() has been added to mark course completions instantly. It is

View File

@ -121,6 +121,7 @@ class activity_information implements renderable, templatable {
$data->hascompletion = $this->cmcompletion->has_completion();
$data->isautomatic = $this->cmcompletion->is_automatic();
$data->ismanual = $this->cmcompletion->is_manual();
$data->showmanualcompletion = $this->cmcompletion->show_manual_completion();
// Get the name of the user overriding the completion condition, if available.

View File

@ -25,13 +25,9 @@
namespace core_courseformat\output\local\content;
use cm_info;
use core\activity_dates;
use core\output\named_templatable;
use core_availability\info_module;
use core_completion\cm_completion_details;
use core_course\output\activity_information;
use core_courseformat\base as course_format;
use core_courseformat\output\activitybadge;
use core_courseformat\output\local\courseformat_named_templatable;
use renderable;
use renderer_base;
@ -69,6 +65,9 @@ class cm implements named_templatable, renderable {
/** @var string the activity availability class name */
protected $availabilityclass;
/** @var string the activity completion class name */
protected $completionclass;
/**
* Constructor.
*
@ -90,6 +89,7 @@ class cm implements named_templatable, renderable {
$this->cmnameclass = $format->get_output_classname('content\\cm\\cmname');
$this->controlmenuclass = $format->get_output_classname('content\\cm\\controlmenu');
$this->availabilityclass = $format->get_output_classname('content\\cm\\availability');
$this->completionclass = $format->get_output_classname('content\\cm\\completion');
}
/**
@ -205,33 +205,13 @@ class cm implements named_templatable, renderable {
* @return bool the module has completion information
*/
protected function add_completion_data(stdClass &$data, renderer_base $output): bool {
global $USER;
$course = $this->mod->get_course();
// Fetch completion details.
$showcompletionconditions = $course->showcompletionconditions == COMPLETION_SHOW_CONDITIONS;
$completiondetails = cm_completion_details::get_instance($this->mod, $USER->id, $showcompletionconditions);
// Fetch activity dates.
$activitydates = [];
if ($course->showactivitydates) {
$activitydates = activity_dates::get_dates_for_module($this->mod, $USER->id);
$completion = new $this->completionclass($this->format, $this->section, $this->mod);
$templatedata = $completion->export_for_template($output);
if ($templatedata) {
$data->activityinfo = $templatedata;
return true;
}
$activityinfodata = (object) ['hasdates' => false, 'hascompletion' => false];
// There are activity dates to be shown; or
// Completion info needs to be displayed
// * The activity tracks completion; AND
// * The showcompletionconditions setting is enabled OR an activity that tracks manual
// completion needs the manual completion button to be displayed on the course homepage.
$showcompletioninfo = $completiondetails->has_completion() && ($showcompletionconditions ||
(!$completiondetails->is_automatic() && $completiondetails->show_manual_completion()));
if ($showcompletioninfo || !empty($activitydates)) {
$activityinfo = new activity_information($this->mod, $completiondetails, $activitydates);
$activityinfodata = $activityinfo->export_for_template($output);
}
$data->activityinfo = $activityinfodata;
return $activityinfodata->hascompletion;
return false;
}
/**

View File

@ -0,0 +1,120 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_courseformat\output\local\content\cm;
use cm_info;
use section_info;
use renderable;
use stdClass;
use core\activity_dates;
use core\output\named_templatable;
use core\output\local\dropdown\dialog as dropdown_dialog;
use core_completion\cm_completion_details;
use core_course\output\activity_information;
use core_courseformat\base as course_format;
use core_courseformat\output\local\courseformat_named_templatable;
/**
* Base class to render course module completion.
*
* @package core_courseformat
* @copyright 2023 Mikel Martin <mikel@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class completion implements named_templatable, renderable {
use courseformat_named_templatable;
/**
* Constructor.
*
* @param course_format $format the course format
* @param section_info $section the section info
* @param cm_info $mod the course module ionfo
*/
public function __construct(
protected course_format $format,
protected section_info $section,
protected cm_info $mod,
) {
}
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param \renderer_base $output typically, the renderer that's calling this function
* @return stdClass data context for a mustache template
*/
public function export_for_template(\renderer_base $output): ?stdClass {
global $USER;
$course = $this->mod->get_course();
$showcompletionconditions = $course->showcompletionconditions == COMPLETION_SHOW_CONDITIONS;
$completiondetails = cm_completion_details::get_instance($this->mod, $USER->id, $showcompletionconditions);
$activitydates = [];
if ($course->showactivitydates) {
$activitydates = activity_dates::get_dates_for_module($this->mod, $USER->id);
}
// There are activity dates to be shown; or
// Completion info needs to be displayed
// * The activity tracks completion; AND
// * The showcompletionconditions setting is enabled OR an activity that tracks manual
// completion needs the manual completion button to be displayed on the course homepage.
$showcompletioninfo = $completiondetails->has_completion() && ($showcompletionconditions ||
(!$completiondetails->is_automatic() && $completiondetails->show_manual_completion()));
if (!$showcompletioninfo && empty($activitydates)) {
return null;
}
$activityinfodata = (object) [ 'hasdates' => false, 'hascompletion' => false ];
$activityinfo = new activity_information($this->mod, $completiondetails, $activitydates);
$activityinfodata = $activityinfo->export_for_template($output);
if ($activityinfodata->isautomatic || ($activityinfodata->ismanual && !$activityinfodata->istrackeduser)) {
$activityinfodata->completiondialog = $this->get_completion_dialog($output, $activityinfodata);
}
return $activityinfodata;
}
/**
* Get the completion dialog.
*
* @param \renderer_base $output typically, the renderer that's calling this function
* @param stdClass $completioninfo the completion info
* @return array the completion dialog exported for template
*/
private function get_completion_dialog(\renderer_base $output, stdClass $completioninfo): array {
if ($completioninfo->istrackeduser) {
$buttoncontent = get_string('todo', 'completion');
} else {
$buttoncontent = get_string('completionmenuitem', 'completion');
}
$content = $output->render_from_template('core_courseformat/local/content/cm/completion_dialog', $completioninfo);
$completiondialog = new dropdown_dialog($buttoncontent, $content, [
'classes' => 'completion-dropdown',
'buttonclasses' => 'btn btn-sm btn-outline-secondary dropdown-toggle',
'dropdownposition' => dropdown_dialog::POSITION['end'],
]);
return $completiondialog->export_for_template($output);
}
}

View File

@ -27,6 +27,12 @@
"activityname": "Course announcements",
"hascompletion": true,
"uservisible": true,
"completiondialog": {
"buttoncontent": "To do",
"dialogcontent": "You must view this activity to complete it.",
"buttonclasses": "btn btn-sm btn-outline-secondary dropdown-toggle",
"classes": "completion-dropdown"
},
"isautomatic": true,
"showmanualcompletion": true,
"completiondetails": [
@ -44,42 +50,21 @@
<div data-region="activity-information" data-activityname="{{activityname}}" class="activity-information">
{{#uservisible}}
<div data-region="completion-info">
{{#isautomatic}}
<div class="automatic-completion-conditions"
data-region ="completionrequirements"
aria-label="{{#str}}completionrequirements, core_course, {{activityname}}{{/str}}"
>
<div class="dropdown">
<a
href="#"
class="btn btn-sm btn-outline-secondary dropdown-toggle"
role="button"
id="completion-dropdown-button-{{cmid}}"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
{{#str}}completionmenuitem, completion{{/str}}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="completion-dropdown-button-{{cmid}}">
<div class="p-2" role="list">
{{#completiondetails}}
{{$ core_course/completion_automatic }}
{{> core_course/completion_automatic }}
{{/ core_course/completion_automatic }}
{{/completiondetails}}
</div>
</div>
</div>
{{! Completion dropdown dialog }}
{{#completiondialog}}
<div data-region="completionrequirements" aria-label="{{#str}}completionrequirements, core_course, {{activityname}}{{/str}}">
{{> core/local/dropdown/dialog }}
</div>
{{/isautomatic}}
{{^isautomatic}}
{{#showmanualcompletion}}
{{/completiondialog}}
{{! Manual completion button }}
{{#showmanualcompletion}}
{{#istrackeduser}}
{{$ core_course/completion_manual }}
{{> core_course/completion_manual }}
{{/ core_course/completion_manual }}
{{/showmanualcompletion}}
{{/isautomatic}}
{{/istrackeduser}}
{{/showmanualcompletion}}
</div>
{{/uservisible}}
</div>

View File

@ -0,0 +1,96 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_courseformat/local/content/cm/completion_dialog
Container to display activity completion dialog content.
Example context (json):
{
"istrackeduser": true,
"completiondetails": [
{
"statuscomplete": 1,
"description": "View"
},
{
"statusincomplete": 1,
"description": "Receive a grade"
}
]
}
}}
<div class="completion-dialog px-2">
{{! Dialog header. }}
{{#istrackeduser}}
<strong>{{#str}}youmust, completion{{/str}}</strong>
{{/istrackeduser}}
{{^istrackeduser}}
<strong>{{#str}}studentsmust, completion{{/str}}</strong>
{{/istrackeduser}}
{{! Completion criterias.}}
<div class="ml-2" role="list">
{{#completiondetails}}
{{! Show completion status and description to tracked users. }}
{{#istrackeduser}}
{{#statuscomplete}}
<div class="d-flex mt-2 text-success" role="listitem" {{#accessibledescription}}title="{{.}}" aria-label="{{.}}"{{/accessibledescription}}>
<div>
{{#pix}}i/checked{{/pix}}
<span class="sr-only">{{#str}}completion_automatic:done, core_course{{/str}}</span>
</div>
<span>{{description}}</span>
</div>
{{/statuscomplete}}
{{#statuscompletefail}}
<div class="d-flex mt-2 text-danger" role="listitem" {{#accessibledescription}}title="{{.}}" aria-label="{{.}}"{{/accessibledescription}}>
<div>
{{#pix}}e/cancel{{/pix}}
<span class="sr-only">{{#str}}completion_automatic:failed, core_course{{/str}}</span>
</div>
<span>{{description}}</span>
</div>
{{/statuscompletefail}}
{{#statusincomplete}}
<div class="d-flex mt-2" role="listitem" {{#accessibledescription}}title="{{.}}" aria-label="{{.}}"{{/accessibledescription}}>
<div>
{{#pix}}i/dot{{/pix}}
<span class="sr-only">{{#str}}completion_automatic:todo, core_course{{/str}}</span>
</div>
<span>{{description}}</span>
</div>
{{/statusincomplete}}
{{/istrackeduser}}
{{! Show only description (without status) to non-tracked users. }}
{{^istrackeduser}}
<div class="d-flex mt-2" role="listitem">
<div>{{#pix}}i/dot{{/pix}}</div>
<span>{{description}}</span>
</div>
{{/istrackeduser}}
{{/completiondetails}}
{{! Show also manual completion description in the list to non-tracked users. }}
{{#ismanual}}
{{^istrackeduser}}
<div class="d-flex mt-2" role="listitem">
<div>{{#pix}}i/dot{{/pix}}</div>
<span>{{#str}} completion_manual:markdone, core_course {{/str}}</span>
</div>
{{/istrackeduser}}
{{/ismanual}}
</div>
</div>

View File

@ -29,37 +29,37 @@
}}
{{#istrackeduser}}
{{#statuscomplete}}
<span class="badge badge-pill alert-success icon-no-margin" role="listitem" {{!
<div class="badge badge-pill alert-success icon-no-margin" role="listitem" {{!
}}{{#accessibledescription}}{{!
}}title="{{.}}" {{!
}}aria-label="{{.}}" {{!
}}{{/accessibledescription}}>
{{#pix}}i/checked{{/pix}}
<strong>{{#str}}completion_automatic:done, core_course{{/str}}</strong> <span class="font-weight-normal">{{description}}</span>
</span>
</div>
{{/statuscomplete}}
{{#statuscompletefail}}
<span class="badge badge-pill alert-danger icon-no-margin" role="listitem" {{!
<div class="badge badge-pill alert-danger icon-no-margin" role="listitem" {{!
}}{{#accessibledescription}}{{!
}}title="{{.}}" {{!
}}aria-label="{{.}}" {{!
}}{{/accessibledescription}}>
{{#pix}}e/cancel{{/pix}}
<strong>{{#str}}completion_automatic:failed, core_course{{/str}}</strong> <span class="font-weight-normal">{{description}}</span>
</span>
</div>
{{/statuscompletefail}}
{{#statusincomplete}}
<span class="badge badge-pill badge-light" role="listitem" {{!
<div class="badge badge-pill badge-light" role="listitem" {{!
}}{{#accessibledescription}}{{!
}}title="{{.}}" {{!
}}aria-label="{{.}}" {{!
}}{{/accessibledescription}}>
<strong>{{#str}}completion_automatic:todo, core_course{{/str}}</strong> <span class="font-weight-normal">{{description}}</span>
</span>
</div>
{{/statusincomplete}}
{{/istrackeduser}}
{{^istrackeduser}}
<span class="badge badge-pill badge-light" role="listitem">
<div class="badge badge-pill badge-light" role="listitem">
<span class="font-weight-normal">{{description}}</span>
</span>
</div>
{{/istrackeduser}}

View File

@ -235,6 +235,7 @@ $string['selfcompletion'] = 'Self completion';
$string['showcompletionconditions'] = 'Show activity completion conditions';
$string['showcompletionconditions_help'] = 'Activity completion conditions are always shown on the activity page. This setting determines whether activity completion conditions are also shown below each activity on the course page.';
$string['showinguser'] = 'Showing user';
$string['studentsmust'] = 'Students must';
$string['timecompleted'] = 'Time completed';
$string['todo'] = 'To do';
$string['unenrolingfromcourse'] = 'Unenrolling from course';
@ -250,6 +251,7 @@ $string['viewingactivity'] = 'Viewing the {$a}';
$string['withconditions'] = 'With conditions';
$string['writingcompletiondata'] = 'Writing completion data';
$string['xdays'] = '{$a} days';
$string['youmust'] = 'You must';
// Deprecated since Moodle 4.0.
$string['yourprogress'] = 'Your progress';

View File

@ -43,8 +43,7 @@ Feature: View activity completion in the assignment activity
Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to Yes
Given I am on the "Course 1" course page logged in as teacher1
# Teacher view.
And the manual completion button for "Music history" should exist
And the manual completion button for "Music history" should be disabled
And "Music history" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"
@ -62,10 +61,7 @@ Feature: View activity completion in the assignment activity
And I set the field "Show activity completion conditions" to "No"
And I press "Save and display"
# Teacher view.
And the manual completion button for "Music history" should not exist
And I am on the "Music history" "assign activity" page
And the manual completion button for "Music history" should exist
And the manual completion button for "Music history" should be disabled
And "Completion" "button" should not exist in the "Music history" "activity"
And I log out
# Student view.
When I am on the "Course 1" course page logged in as "student1"

View File

@ -55,7 +55,7 @@ Feature: View activity completion information in the chat activity
| completion | 1 |
And I am on "Course 1" course homepage
# Teacher view.
And the manual completion button for "Music history" should be disabled
And "Music history" should have the "Mark as done" completion condition
And I log out
# Student view.
And I am on the "Music history" Activity page logged in as student1

View File

@ -35,8 +35,7 @@ Feature: View activity completion information for the label
Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to No
Given I am on "Course 1" course homepage
# Teacher view.
And the manual completion button for "Test label 1" should exist
And the manual completion button for "Test label 1" should be disabled
And "Test label 1" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"
@ -54,8 +53,7 @@ Feature: View activity completion information for the label
And I set the field "Show activity completion conditions" to "Yes"
And I press "Save and display"
# Teacher view.
And the manual completion button for "Test label 1" should exist
And the manual completion button for "Test label 1" should be disabled
And "Test label 1" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"

View File

@ -1,4 +1,4 @@
@mod @mod_lesson
@mod @mod_lesson @javascript
Feature: Set end of lesson reached as a completion condition for a lesson
In order to ensure students really see all lesson pages
As a teacher

View File

@ -1,4 +1,4 @@
@mod @mod_lesson
@mod @mod_lesson @javascript
Feature: Set time spent as a completion condition for a lesson
In order to ensure students spend the needed time to study lessons
As a teacher

View File

@ -1,4 +1,4 @@
@mod @mod_quiz @core_completion
@mod @mod_quiz @core_completion @javascript
Feature: Set a quiz to be marked complete when the student uses all attempts allowed
In order to ensure a student has learned the material before being marked complete
As a teacher
@ -35,8 +35,7 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
| 1 | False |
Scenario Outline: Student attempts the quiz - pass and fails
When I log in as "student1"
And I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as student1
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo"
@ -45,18 +44,17 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
And I set the field "<answer>" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
And I am on "Course 1" course homepage
Then the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "<passcompletionexpected>"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done"
And I follow "Test quiz name"
And I click on "Test quiz name" "link" in the "region-main" "region"
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "<passcompletionexpected>"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And I am on the "Test quiz name" "quiz activity" page logged in as teacher1
And "Test quiz name" should have the "Receive a pass grade or complete all available attempts" completion condition
And I am on "Course 1" course homepage
And I navigate to "Reports" in current page administration

View File

@ -1,4 +1,4 @@
@mod @mod_quiz @core_completion
@mod @mod_quiz @core_completion @javascript
Feature: Set a quiz to be marked complete when the student completes a minimum amount of attempts
In order to ensure a student has completed the quiz before being marked complete
As a teacher
@ -35,26 +35,24 @@ Feature: Set a quiz to be marked complete when the student completes a minimum a
| 1 | False |
Scenario: student1 uses up both attempts without passing
When I log in as "teacher1"
And I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as teacher1
And "Completed: Test quiz name" "icon" should not exist in the "Test quiz name" "list_item"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student1
And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "todo"
And I follow "Test quiz name"
And I click on "Test quiz name" "link" in the "region-main" "region"
And I press "Re-attempt quiz"
And I set the field "False" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
And I am on "Course 1" course homepage
Then the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done"
And I follow "Test quiz name"
And I click on "Test quiz name" "link" in the "region-main" "region"
And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And I am on the "Course 1" course page logged in as teacher1
And I click on "Test quiz name" "link" in the "region-main" "region"
And "Test quiz name" should have the "Make attempts: 2" completion condition
And I am on "Course 1" course homepage
And I navigate to "Reports" in current page administration

View File

@ -31,6 +31,7 @@ Feature: Set a quiz to be marked complete when the student passes
| question | page |
| First question | 1 |
@javascript
Scenario: student1 passes on the first try
When I log in as "student1"
And I am on "Course 1" course homepage

View File

@ -33,8 +33,7 @@ Feature: View activity completion information for file resources
| resource | C1 | Myfile | <display> | 0 | 0 | 0 | 1 | mod/resource/tests/fixtures/samplefile.txt | 620 | 450 | 1 |
And I am on "Course 1" course homepage with editing mode on
# Teacher view.
And the manual completion button for "Myfile" should exist
And the manual completion button for "Myfile" should be disabled
And "Myfile" should have the "Mark as done" completion condition
# Student view.
When I am on the "Course 1" course page logged in as student1
Then the manual completion button for "Myfile" should exist
@ -64,8 +63,7 @@ Feature: View activity completion information for file resources
| Completion tracking | Students can manually mark the activity as completed |
And I click on "Save and return to course" "button"
# Teacher view.
And the manual completion button for "Myfile" should exist
And the manual completion button for "Myfile" should be disabled
And "Myfile" should have the "Mark as done" completion condition
And I am on the "Myfile" "resource activity" page
And the manual completion button for "Myfile" should exist
And the manual completion button for "Myfile" should be disabled

View File

@ -1,4 +1,4 @@
@mod @mod_survey @core_completion
@mod @mod_survey @core_completion @javascript
Feature: A teacher can use activity completion to track a student progress
In order to use activity completion
As a teacher
@ -50,14 +50,13 @@ Feature: A teacher can use activity completion to track a student progress
And I follow "Test survey name"
And the "Submit answers" completion condition of "Test survey name" is displayed as "done"
@javascript
Scenario: Use manual completion
Given the following "activities" exist:
| activity | name | course | idnumber | completion |
| survey | Test survey name | C1 | survey1 | 1 |
And I am on "Course 1" course homepage
# Teacher view.
And the manual completion button for "Test survey name" should be disabled
And "Test survey name" should have the "Mark as done" completion condition
# Student view.
When I am on the "survey1" Activity page logged in as student1
Then the manual completion button of "Test survey name" is displayed as "Mark as done"

View File

@ -77,6 +77,7 @@ Feature: View activity completion information in the URL resource
When I am on the "Music history" "url activity" page logged in as student1
Then the "View" completion condition of "Music history" is displayed as "done"
@javascript
Scenario: View automatic completion items in open display mode as teacher
Given the following "activity" exists:
| activity | url |
@ -92,6 +93,7 @@ Feature: View activity completion information in the URL resource
And I am on the "Course 1" course page
Then "Music history" should have the "View" completion condition
@javascript
Scenario: View automatic completion items in open display mode as student
Given the following "activity" exists:
| activity | url |
@ -172,7 +174,7 @@ Feature: View activity completion information in the URL resource
And the manual completion button of "Music history" is displayed as "Done"
@javascript
Scenario Outline: The manual completion button will be shown on the course page for Open, In pop-up and New window display mode if the Show activity completion conditions is set to No as teacher
Scenario Outline: The Mark as done completion condition will be shown on the course page for Open, In pop-up and New window display mode if the Show activity completion conditions is set to No as teacher
Given the following "activity" exists:
| activity | url |
| course | C1 |
@ -186,8 +188,7 @@ Feature: View activity completion information in the URL resource
| popupwidth | 620 |
| popupheight | 450 |
When I am on the "Course 1" course page logged in as teacher1
Then the manual completion button for "Music history" should exist
And the manual completion button for "Music history" should be disabled
Then "Music history" should have the "Mark as done" completion condition
Examples:
| display | description |

BIN
pix/i/dot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

3
pix/i/dot.svg Normal file
View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="2" fill="#495057"/>
</svg>

After

Width:  |  Height:  |  Size: 148 B

View File

@ -1575,6 +1575,17 @@ $activity-add-hover: theme-color-level('primary', -10) !default;
width: 100%;
}
}
.completion-dialog {
color: $gray-700;
font-size: $font-size-sm;
min-width: 12rem;
.icon {
font-size: $font-size-sm;
width: $font-size-sm;
height: $font-size-sm;
margin-right: map-get($spacers, 1);
}
}
}
.activity-groupmode-info {

View File

@ -29183,6 +29183,17 @@ span.editinstructions .alert-link {
width: 100%;
}
}
.activity-item .activity-info .completion-dialog {
color: #495057;
font-size: 0.8203125rem;
min-width: 12rem;
}
.activity-item .activity-info .completion-dialog .icon {
font-size: 0.8203125rem;
width: 0.8203125rem;
height: 0.8203125rem;
margin-right: 0.25rem;
}
.activity-item .activity-groupmode-info {
grid-area: groupmode;
justify-self: end;

View File

@ -29183,6 +29183,17 @@ span.editinstructions .alert-link {
width: 100%;
}
}
.activity-item .activity-info .completion-dialog {
color: #495057;
font-size: 0.8203125rem;
min-width: 12rem;
}
.activity-item .activity-info .completion-dialog .icon {
font-size: 0.8203125rem;
width: 0.8203125rem;
height: 0.8203125rem;
margin-right: 0.25rem;
}
.activity-item .activity-groupmode-info {
grid-area: groupmode;
justify-self: end;