6.1.5 Matchmaking
| (require conscript/matchmaking) | package: conscript |
The bindings in this module are also provided by conscript/base.
These functions are used for matching participants into groups. Tehy take care of the mechanics of pausing the study until groups are full, and of sharing results between group members.
A matchmaker function is used to collect participants into groups of a given size, displaying a “Please wait” step until the group is full. A pending group is one that has one or more members but still needs more to meet its quota; a ready group has met its quota of assigned participants and is ready to proceed.
procedure
(make-matchmaker group-size [group-ok?]) → (-> (-> xexpr?) any/c)
group-size : exact-positive-integer? group-ok? : (-> buid/c boolean?) = values
You should avoid calling make-matchmaker more than once with different values of group-size in the same study.
A group-ok? procedure can be supplied in order to give the study author a way to prevent adding the participant to certain groups. The procedure will be called with the identifier of the candidate group, which can be used as a key to the hash returned by get-pending-groups. The procedure must return #t if the participant can be added to the candidate group or #f if not. (During the body of the group-ok? procedure, the hash table returned by get-pending-groups will not yet include the current-participant-id.)
procedure
(get-current-group) → (or/c buid/c #f)
If the result is not #f, it can be used as a key for the hash returned by either get-ready-groups or get-pending-groups (depending on whether the current participant is in a ready group or a pending group) to get a list of participant IDs.
procedure
(get-ready-groups) → (hash/c buid/c (listof integer?))
Each key in the hash table is a group ID and references a list of participant IDs assigned to that group.
procedure
(get-pending-groups) → (hash/c buid/c (listof integer?))
Each key in the hash table is a group ID and references a list of participant IDs assigned to that group.
procedure
(current-group-members #:include-self? include-self?)
→ (listof integer?) include-self? : #f
By default, current participant’s own ID is not included in the returned list, but if include-self? is not #f then the returned list will include all members of the group.
procedure
If, at the time the participant’s current group is reset, they were in a group that was only partially filled, then a subsequent call to a matchmaker function may add them back to the same group (causing their ID to appear more than once in that group’s member list). If they were in a filled group, the participant’s ID will remain among the list of the original group members.
procedure
(store-my-result-in-group! lookup-key val) → void?
lookup-key : any/c val : any/c
If the current participant is not a member of a group, no data will be recorded.
procedure
(get-my-result-in-group lookup-key) → any/c
lookup-key : any/c
procedure
(current-group-member-results lookup-key #:include-ids? ids? #:include-self? include-self?)
→
(or/c (listof (cons/c id/c any/c)) (listof any/c)) lookup-key : any/c ids? : #f include-self? : #f
If the current participant is not a member of a group, an empty list is returned.
If ids? is not #f, then each element the returned list will be a pair of the form (id . result) where id is the ID of the participant that recorded the result. If ids? is #f, the returned list will simply contain all the result values.
By default, current participant’s own result is not included in the returned list, but if include-self? is not #f then the returned list will include a response recorded by the current participant under lookup-key, if one exists, or #f if it does not exist.
As an example, assume the current participant has an ID of 100 and is paired with participant 199. If the current participant has recorded a response of "no" under lookup key 'has-eaten and the other group member has not yet recorded a response under that key:
(current-group-member-results 'has-eaten) ; → ’(#f) (current-group-member-results 'has-eaten #:include-ids? #t) ; → ’((199 . #f)) (current-group-member-results 'has-eaten #:include-self? #t) ; → ’("no" #f) (current-group-member-results 'has-eaten #:include-self? #t #:include-ids? #t) ; → ’((100 . "no") (199 . #f))
procedure
(current-group-results-count lookup-key #:include-self? include-self) → exact-nonnegative-integer? lookup-key : any/c include-self : #f
If the current participant is not a member of a group, the result will be 0.
By default, current participant’s own result is not counted, but if include-self? is not #f then the count will reflect any responses recorded by the current participant under lookup-key, if any.