Skip to content

Commit

Permalink
Merge pull request #836 from chaotic-kingdoms/oppia-1341-bugfix-cohor…
Browse files Browse the repository at this point in the history
…t-criteria

oppia-1341: Fix bug in cohort criteria filtering
  • Loading branch information
alexlittle committed Nov 24, 2022
2 parents f0bc2a0 + 5085f8f commit 929726f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions oppia/models/cohorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def update_participants_by_role(self, role):

role_criteria = CohortCritera.objects.filter(cohort=self, role=role)

participants = []
participants = User.objects
# as Django's filter() function is accumulative, we can concatenate them as an AND expression
for criteria in role_criteria:
customfield = CustomField.objects.filter(id=criteria.user_profile_field).first()
if not customfield:
continue
value = criteria.user_profile_value
participants = (participants if participants else User.objects).filter(
participants = participants.filter(
get_customfields_filter(value, customfield))

for participant in participants:
Expand Down

0 comments on commit 929726f

Please sign in to comment.