mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-44646-master' of https://github.com/lucaboesch/moodle
This commit is contained in:
commit
130ab46d37
@ -65,3 +65,20 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
|
||||
And I should not see "User Two"
|
||||
And I should not see "User Three"
|
||||
And I should not see "User Four"
|
||||
|
||||
Scenario: Filter user accounts by enrolled in any course
|
||||
When I set the following fields to these values:
|
||||
| id_anycourses | Yes |
|
||||
And I press "Add filter"
|
||||
Then I should see "User One"
|
||||
And I should see "User Two"
|
||||
And I should see "User Three"
|
||||
And I should not see "User Four"
|
||||
And I press "Remove all filters"
|
||||
And I set the following fields to these values:
|
||||
| id_anycourses | No |
|
||||
And I press "Add filter"
|
||||
And I should not see "User One"
|
||||
And I should not see "User Two"
|
||||
And I should not see "User Three"
|
||||
And I should see "User Four"
|
||||
|
@ -26,6 +26,7 @@ $string['actfilterhdr'] = 'Active filters';
|
||||
$string['addfilter'] = 'Add filter';
|
||||
$string['anycategory'] = 'any category';
|
||||
$string['anycourse'] = 'any course';
|
||||
$string['anycourses'] = 'Enrolled in any course';
|
||||
$string['anyfield'] = 'any field';
|
||||
$string['anyrole'] = 'any role';
|
||||
$string['anyvalue'] = 'any value';
|
||||
|
49
user/filters/anycourses.php
Normal file
49
user/filters/anycourses.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* This is filter is used to see which students are enroled on any courses
|
||||
*
|
||||
* @package core_user
|
||||
* @copyright 2014 Krister Viirsaar
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* User filter to distinguish users with no or any enroled courses.
|
||||
* @copyright 2014 Krister Viirsaar
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_filter_anycourses extends user_filter_yesno {
|
||||
|
||||
/**
|
||||
* Returns the condition to be used with SQL
|
||||
*
|
||||
* @param array $data filter settings
|
||||
* @return array sql string and $params
|
||||
*/
|
||||
public function get_sql_filter($data) {
|
||||
$value = $data['value'];
|
||||
|
||||
$not = $value ? '' : 'NOT';
|
||||
|
||||
return array("EXISTS ( SELECT userid FROM {user_enrolments} ) AND " .
|
||||
" id $not IN ( SELECT userid FROM {user_enrolments} )", array());
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ require_once($CFG->dirroot.'/user/filters/courserole.php');
|
||||
require_once($CFG->dirroot.'/user/filters/globalrole.php');
|
||||
require_once($CFG->dirroot.'/user/filters/profilefield.php');
|
||||
require_once($CFG->dirroot.'/user/filters/yesno.php');
|
||||
require_once($CFG->dirroot.'/user/filters/anycourses.php');
|
||||
require_once($CFG->dirroot.'/user/filters/cohort.php');
|
||||
require_once($CFG->dirroot.'/user/filters/user_filter_forms.php');
|
||||
require_once($CFG->dirroot.'/user/filters/checkbox.php');
|
||||
@ -63,10 +64,11 @@ class user_filtering {
|
||||
}
|
||||
|
||||
if (empty($fieldnames)) {
|
||||
$fieldnames = array('realname' => 0, 'lastname' => 1, 'firstname' => 1, 'username' => 1, 'email' => 1, 'city' => 1, 'country' => 1,
|
||||
'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1, 'systemrole' => 1,
|
||||
'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1, 'neveraccessed' => 1, 'timemodified' => 1,
|
||||
'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1, 'idnumber' => 1);
|
||||
$fieldnames = array('realname' => 0, 'lastname' => 1, 'firstname' => 1, 'username' => 1, 'email' => 1, 'city' => 1,
|
||||
'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1,
|
||||
'anycourses' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1,
|
||||
'neveraccessed' => 1, 'timemodified' => 1, 'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1,
|
||||
'idnumber' => 1);
|
||||
}
|
||||
|
||||
$this->_fields = array();
|
||||
@ -142,6 +144,8 @@ class user_filtering {
|
||||
case 'suspended': return new user_filter_yesno('suspended', get_string('suspended', 'auth'), $advanced, 'suspended');
|
||||
case 'profile': return new user_filter_profilefield('profile', get_string('profilefields', 'admin'), $advanced);
|
||||
case 'courserole': return new user_filter_courserole('courserole', get_string('courserole', 'filters'), $advanced);
|
||||
case 'anycourses':
|
||||
return new user_filter_anycourses('anycourses', get_string('anycourses', 'filters'), $advanced, 'user_enrolments');
|
||||
case 'systemrole': return new user_filter_globalrole('systemrole', get_string('globalrole', 'role'), $advanced);
|
||||
case 'firstaccess': return new user_filter_date('firstaccess', get_string('firstaccess', 'filters'), $advanced, 'firstaccess');
|
||||
case 'lastaccess': return new user_filter_date('lastaccess', get_string('lastaccess'), $advanced, 'lastaccess');
|
||||
|
Loading…
x
Reference in New Issue
Block a user