Experiment
backend.experiment.models#
Block
#
Bases: Model
Root entity for configuring experiment blocks
Attributes:
| Name | Type | Description |
|---|---|---|
phase |
Phase
|
The phase this block belongs to |
index |
int
|
Index of this block in the phase |
slug |
str
|
Slug for this block |
name |
str
|
Block name |
description |
str
|
Description |
playlists |
list(section.models.Playlist
|
The playlist(s) used in this block |
image |
Image
|
Image that will be showed on the dashboard |
active |
bool
|
Is this block active? |
rounds |
int
|
Number of rounds |
bonus_points |
int
|
Bonus points |
rules |
str
|
The rules used for this block |
theme_config |
ThemeConfig
|
Theme settings |
rules_config |
dict
|
a dictionary containing extra settings for the rules coupled to the block |
Source code in backend/experiment/models.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
add_default_question_lists()
#
Add default question lists to block
Source code in backend/experiment/models.py
create_question_list(question_list, index=0)
#
create a question list for this block based on a dict specifying name and list of question keys
Source code in backend/experiment/models.py
get_rules()
#
Get instance of rules class to be used for this session
Returns:
| Type | Description |
|---|---|
Base
|
Rules |
Source code in backend/experiment/models.py
max_score()
#
Get max score from all sessions with a positive score
Returns:
| Type | Description |
|---|---|
int
|
max score from all sessions with a positive score |
Source code in backend/experiment/models.py
playlist_count()
#
Experiment
#
Bases: Model
A model to allow nesting multiple phases with blocks into a ‘parent’ experiment
Attributes:
| Name | Type | Description |
|---|---|---|
slug |
str
|
Slug |
name |
str
|
Name of the experiment |
description |
str
|
Description |
consent |
FileField
|
Consent text markdown or html |
about_content |
str
|
About text |
social_media_message |
str
|
Message to post with on social media. Can contain {points} and {experiment_name} placeholders |
disclaimer |
str
|
Disclaimer text |
privacy |
str
|
Privacy statement text |
theme_config |
ThemeConfig
|
ThemeConfig instance |
active |
bool
|
Set experiment active |
social_media_config |
SocialMediaConfig
|
SocialMediaConfig instance |
phases |
Queryset[Phase]
|
Queryset of Phase instances |
Source code in backend/experiment/models.py
Feedback
#
Bases: Model
A model for adding feedback to an experiment block
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
Text |
block |
Block
|
Associated block |
Source code in backend/experiment/models.py
Phase
#
Bases: Model
Root entity for configuring experiment phases
Attributes:
| Name | Type | Description |
|---|---|---|
experiment |
Experiment
|
Instance of an Experiment |
index |
int
|
Index of the phase |
dashboard |
bool
|
Should the dashbopard be displayed for this phase? |
randomize |
bool
|
Should the blocks of this phase be randomized? |
Source code in backend/experiment/models.py
SocialMediaConfig
#
Bases: Model
Social media config for an experiment
Attributes:
| Name | Type | Description |
|---|---|---|
experiment |
Experiment
|
Experiment instance |
tags |
list[str]
|
Tags |
url |
str
|
Url to be shared |
channels |
list[str]
|
Social media channel |
Source code in backend/experiment/models.py
get_content(score)
#
Get social media share content
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
score
|
float
|
Score |
required |
Returns:
| Type | Description |
|---|---|
str
|
Social media shared text |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required parameters are missing when needed |
Source code in backend/experiment/models.py
consent_upload_path(instance, filename)
#
Generate path to save consent file based on experiment.slug and language Returns: upload_to (str): Path for uploading the consent file