mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
Merge branch 'MDL-79681' of https://github.com/paulholden/moodle
This commit is contained in:
commit
6cea979891
user
@ -229,7 +229,7 @@ class participants_filter extends \core\output\datafilter {
|
||||
|
||||
// Get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
|
||||
// We need to make it diferently for normal courses and site course.
|
||||
if (!$this->course->id == SITEID) {
|
||||
if (!($this->course->id == SITEID)) {
|
||||
// Regular course.
|
||||
$params = [
|
||||
'courseid' => $this->course->id,
|
||||
@ -237,7 +237,17 @@ class participants_filter extends \core\output\datafilter {
|
||||
];
|
||||
$select = 'courseid = :courseid AND timeaccess != :timeaccess';
|
||||
$minlastaccess = $DB->get_field_select('user_lastaccess', 'MIN(timeaccess)', $select, $params);
|
||||
$lastaccess0exists = $DB->record_exists('user_lastaccess', $params);
|
||||
|
||||
// Determine enrolled users, who do not have accompanying lastaccess to the course.
|
||||
[$enrolledsql, $enrolledparams] = get_enrolled_sql($this->context);
|
||||
|
||||
$sql = "SELECT 'x'
|
||||
FROM {user} u
|
||||
JOIN ({$enrolledsql}) je ON je.id = u.id
|
||||
LEFT JOIN {user_lastaccess} ula ON ula.userid = je.id AND ula.courseid = :courseid
|
||||
WHERE COALESCE(ula.timeaccess, 0) = :timeaccess";
|
||||
|
||||
$lastaccess0exists = $DB->record_exists_sql($sql, array_merge($params, $enrolledparams));
|
||||
} else {
|
||||
// Front page.
|
||||
$params = ['lastaccess' => 0];
|
||||
@ -247,8 +257,6 @@ class participants_filter extends \core\output\datafilter {
|
||||
}
|
||||
|
||||
$now = usergetmidnight(time());
|
||||
$timeoptions = [];
|
||||
$criteria = get_string('usersnoaccesssince');
|
||||
|
||||
$getoptions = function(int $count, string $singletype, string $type) use ($now, $minlastaccess): array {
|
||||
$values = [];
|
||||
@ -282,7 +290,7 @@ class participants_filter extends \core\output\datafilter {
|
||||
|
||||
if ($lastaccess0exists) {
|
||||
$values[] = [
|
||||
'value' => time(),
|
||||
'value' => -1,
|
||||
'title' => get_string('never', 'moodle'),
|
||||
];
|
||||
}
|
||||
|
@ -286,6 +286,26 @@ Feature: Course participants can be filtered
|
||||
And I should not see "Student 4" in the "participants" "table"
|
||||
And I should not see "Patricia Pea" in the "participants" "table"
|
||||
|
||||
@javascript
|
||||
Scenario: Filter users who have not accessed a course
|
||||
Given I am on the "C1" "Enrolled users" page logged in as "patricia"
|
||||
When I set the field "type" in the "Filter 1" "fieldset" to "Inactive for more than"
|
||||
|
||||
# Everyone has accessed the course.
|
||||
And I open the autocomplete suggestions list in the "Filter 1" "fieldset"
|
||||
And I should not see "Never" in the ".form-autocomplete-suggestions" "css_element"
|
||||
|
||||
# Switch to a course which only some participants have accessed.
|
||||
And I am on the "C2" "Enrolled users" page
|
||||
And I set the field "type" in the "Filter 1" "fieldset" to "Inactive for more than"
|
||||
And I set the field "Type or select..." in the "Filter 1" "fieldset" to "Never"
|
||||
And I click on "Apply filters" "button"
|
||||
Then I should see "Student 2" in the "participants" "table"
|
||||
And I should see "Student 3" in the "participants" "table"
|
||||
And I should see "Trendy Learnson" in the "participants" "table"
|
||||
And I should not see "Student 1" in the "participants" "table"
|
||||
And I should not see "Patricia Pea" in the "participants" "table"
|
||||
|
||||
@javascript
|
||||
Scenario: Multiple filters applied (All filterset match type)
|
||||
Given I am on the "C1" "Course" page logged in as "patricia"
|
||||
|
Loading…
x
Reference in New Issue
Block a user