diff --git a/course/enrollment.py b/course/enrollment.py
index b7e99e9299b313475bfb887759d0b8e27872ec4f..839450bf97542aba41c95cee04d5f46e5e925499 100644
--- a/course/enrollment.py
+++ b/course/enrollment.py
@@ -553,6 +553,8 @@ _email = intern("email")
_email_contains = intern("email_contains")
_user = intern("user")
_user_contains = intern("user_contains")
+_institutional_id = intern("institutional_id")
+_institutional_id_contains = intern("institutional_id__contains")
_tagged = intern("tagged")
_role = intern("role")
_status = intern("status")
@@ -583,6 +585,9 @@ _LEX_TABLE = [
(_email_contains, RE(r"email-contains:([^ \t\n\r\f\v)]+)")),
(_user, RE(r"username:([^ \t\n\r\f\v)]+)")),
(_user_contains, RE(r"username-contains:([^ \t\n\r\f\v)]+)")),
+ (_institutional_id, RE(r"institutional-id:([^ \t\n\r\f\v)]+)")),
+ (_institutional_id_contains,
+ RE(r"institutional-id-contains:([^ \t\n\r\f\v)]+)")),
(_tagged, RE(r"tagged:([-\w]+)")),
(_role, RE(r"role:(\w+)")),
(_status, RE(r"status:(\w+)")),
@@ -594,7 +599,9 @@ _LEX_TABLE = [
_TERMINALS = ([
- _id, _email, _email_contains, _user, _user_contains, _tagged, _role, _status])
+ _id, _email, _email_contains, _user, _user_contains, _tagged, _role, _status,
+ _institutional_id, _institutional_id_contains
+])
# {{{ operator precedence
@@ -637,6 +644,18 @@ def parse_query(course, expr_str):
pstate.advance()
return result
+ elif next_tag is _institutional_id:
+ result = Q(
+ user__institutional_id__iexact=pstate.next_match_obj().group(1))
+ pstate.advance()
+ return result
+
+ elif next_tag is _institutional_id_contains:
+ result = Q(
+ user__institutional_id__icontains=pstate.next_match_obj().group(1))
+ pstate.advance()
+ return result
+
elif next_tag is _tagged:
ptag, created = ParticipationTag.objects.get_or_create(
course=course,
@@ -753,6 +772,8 @@ class ParticipationQueryForm(StyledForm):
"email-contains:abc
, "
"username:abc
, "
"username-contains:abc
, "
+ "institutional-id:2015abcd
, "
+ "institutional-id-contains:2015
, "
"tagged:abc
, "
"role:instructor|teaching_assistant|"
"student|observer|auditor
, "