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
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
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
163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
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
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
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
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
serialize_actions(actions)
Serialize an array of actions
Source code in experiment/serializers.py
16 17 18 19 20 |
|
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
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
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 |
Source code in experiment/serializers.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
serialize_social_media_config(social_media_config, score=0)
Serialize social media config
Parameters:
Name | Type | Description | Default |
---|---|---|---|
social_media_config |
SocialMediaConfig
|
SocialMediaConfig instance |
required |
Returns:
Type | Description |
---|---|
dict
|
Basic social media info |
Source code in experiment/serializers.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|