Hi,
for an audience that should include all users whose country is 'Austria' and whose language is 'German', the audience is being populated with the users who do *not* match these criteria.
SQL like this is being generated:
SELECT userid AS id, MAX(inrules) AS addme, MAX(inmembers) AS deleteme
FROM (
SELECT u.id as userid, 1 AS inrules, 0 AS inmembers
FROM mdl_user u
WHERE u.username <> 'guest'
and u.deleted = 0
and u.confirmed = 1 AND (1=1
AND ( 1=1
AND ((u.country) IS NULL OR u.country NOT ILIKE '%AT%' ESCAPE E'\\')
AND ((u.lang) IS NULL OR u.lang NOT ILIKE '%de' ESCAPE E'\\')
)
) UNION ALL
SELECT cm.userid AS userid, 0 AS inrules, 1 AS inmembers
FROM mdl_cohort_members cm
WHERE cm.cohortid = 25 ) q
GROUP BY userid
HAVING MAX(inrules) <> MAX(inmembers)
It appears that cohort_rule_sqlhandler_in::get_query_base_operator(($operator, $query, $lov) is not working quite the way it should. It's getting passed a value of 1 for the $operator (which is, by the way COHORT_RULES_OP_IN_EQUAL, which = 1 ). However, it's not looking for COHORT_RULES_OP_IN_EQUAL in the switch statement. It finds COHORT_RULES_OP_IN_NOTCONTAIN, which = 1, and returns SQL based on that.