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_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_total_score(blocks, participant)
#
Calculate total score of all blocks on the dashboard
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blocks |
list
|
All blocks on the dashboard |
required |
participant |
Participant
|
The participant we want the total score from |
required |
Returns:
Type | Description |
---|---|
int
|
Total score of given the blocks for this 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), the next block, and the total score of the phase |