Experiment serializers
experiment.serializers#
get_finished_session_count(block, participant)
#
Get the number of finished sessions for this block and participant
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block |
Block
|
Block instance |
required |
participant |
Participant
|
Participant instance |
required |
Returns:
Type | Description |
---|---|
int
|
Number of finished sessions for this block and participant |
Source code in experiment/serializers.py
get_session_info(blocks, participant)
#
Return information of the sessions played by this participant in the blocks of this phase
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blocks |
list[Block]
|
All blocks from the current phase |
required |
participant |
Participant
|
The participant currently playing |
required |
Returns:
Type | Description |
---|---|
dict
|
dict with session count and accumulated score |
Source code in experiment/serializers.py
get_started_session_count(block, participant)
#
Get the number of started sessions for this block and participant
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block |
Block
|
Block instance |
required |
participant |
Participant
|
Participant instance |
required |
Returns:
Type | Description |
---|---|
int
|
Number of started sessions for this block and participant |
Source code in experiment/serializers.py
get_upcoming_block(phase, participant, times_played)
#
return next block with minimum finished sessions for this participant if all blocks have been played an equal number of times, return None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phase |
Phase
|
Phase for which next block needs to be picked |
required |
participant |
Participant
|
Participant for which next block needs to be picked |
required |
Source code in experiment/serializers.py
serialize_actions(actions)
#
serialize_block(block_object, language='en')
#
Serialize block
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block_object |
Block
|
Block instance |
required |
language |
str
|
Language code |
'en'
|
Returns:
Type | Description |
---|---|
dict
|
Block info for a participant |
Source code in experiment/serializers.py
serialize_experiment(experiment)
#
Serialize experiment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment |
Experiment
|
Experiment instance |
required |
Returns:
Type | Description |
---|---|
dict
|
Basic info about an experiment |
Source code in experiment/serializers.py
serialize_phase(phase, participant, times_played)
#
Serialize phase
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phase |
Phase
|
Phase instance |
required |
participant |
Participant
|
Participant instance |
required |
Returns:
Type | Description |
---|---|
dict
|
a dictionary of the dashboard (if applicable), |
dict
|
the next block, |
dict
|
number of sessions played |
dict
|
accumlated score of the phase |