-
Notifications
You must be signed in to change notification settings - Fork 0
Check participation
Starting from v0.8.1, Mortimer allows experimenters to check, whether partcipants have
participated in a specific experiment through the route /participation
.
Changed in v0.8.4: When registering a participant, you must now provide the experiment version. When checking participation, you can still omit the experiment version. In this case, the check tells you whether the participant has been registered for any version of the experiment.
This feature will be generally used from within alfred3 experiments. It does not offer any graphical user interface.
We implemented this in a way that allows for a maximal level of data protection: You can only check, whether a specific alias is associated with a specific experiment, which means you need to know both the alias and the experiment id. In the database, we only save a hash of the alias. Commonly, you will want to use the email address as the alias.
One of the things that is special about this is the fact, that participation can be checked across different mortimer users (if you know the experiment id, which you can only get from an experiment's owner).
The example below assumes that mortimer runs locally on http://127.0.0.1:5000
.
In practice, you will have to replace this base path with Mortimers
actual address.
To register a participation, you send a post request with the used alias
and the experiment ID. For example, using Python's requests
librarby:
>>> import requests
>>> r = requests.post("http://127.0.0.1:5000/participation", data={"alias": "[email protected]", "exp_id": "123", "exp_version": "1"})
You can check for success by accessing the request object's status code.
A value of 201
indicates a successful registration, a value of 200
indicates
that the participant had already been registered, and a value of 400
means that you have
sent insufficient data (for example, only an alias but no experiment id).
>>> r.status_code
201
You can investigate the text of the response, which will
show either 'success'
or 'already registered'
for the status codes 200
and 201
.
>>> r.text
'success'
To check, whether a participant has been registered in a specific
experiment, you send a get request with the participant's alias and
the experiment id as url parameters. Optionally, you can send a specific experiment version as well. For example, again using Python's
requests
library:
>>> r = requests.get("http://127.0.0.1:5000/participation", params={"alias": "[email protected]", "exp_id": "123"})
With this request, you can first check, whether the request was successful
by accessing the status code. A value of 200
indicates that the
request was successful. A value of 400
means that you have sent insufficient
data (for example, only an alias but no experiment id).
>>> r.status_code
200
Next, if the request was successful, you can investigate the text of the
response. A response of 'true'
means that the alias has been registered
for the experiment. A response of 'false'
means that it has not been
registered (or that the alias was not found at all).
>>> r.text
'true'
- Register participants with an alias, an experiment ID and a specific experiment version
- Check participation with an alias and an experiment ID. Optionally specifiy an experiment version.