Experiment
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 phase |
playlists |
list(section.models.Playlist
|
The playlist(s) used in this block |
image |
Image
|
Image that will be showed on the dashboard |
slug |
str
|
Slug for this block |
active |
bool
|
Is this block active? |
rounds |
int
|
Number of rounds |
bonus_points |
int
|
Bonus points |
rules |
str
|
The rules used for this block |
translated_content |
BlockTranslatedContent
|
Translated content |
theme_config |
ThemeConfig
|
Theme settings |
Source code in experiment/models.py
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 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
name
property
#
Name of the block, which will be used for dashboards
add_default_question_series()
#
Add default question_series to block
Source code in experiment/models.py
current_participants()
#
Get distinct list of participants
Returns:
Type | Description |
---|---|
List[Participant]
|
Associated participants |
Source code in experiment/models.py
get_current_content(fallback=True)
#
Get content for the ‘current’ language
Returns:
Type | Description |
---|---|
BlockTranslatedContent
|
Translated content |
Source code in experiment/models.py
get_fallback_content()
#
Get fallback content for the block
Returns:
Type | Description |
---|---|
BlockTranslatedContent | None
|
Fallback content |
Source code in experiment/models.py
get_rules()
#
Get instance of rules class to be used for this session
Returns:
Type | Description |
---|---|
Base
|
Rules |
Source code in experiment/models.py
get_translated_content(language, fallback=True)
#
Get content for a specific language
Returns:
Type | Description |
---|---|
BlockTranslatedContent
|
Translated content |
Source code in 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 experiment/models.py
playlist_count()
#
BlockTranslatedContent
#
Bases: TranslatedContent
Translated content for a Block
Attributes:
Name | Type | Description |
---|---|---|
block |
Block
|
Associated block |
language |
str
|
Language code |
name |
str
|
Block name |
description |
str
|
Description |
Source code in experiment/models.py
Experiment
#
Bases: Model
A model to allow nesting multiple phases with blocks into a ‘parent’ experiment
Attributes:
Name | Type | Description |
---|---|---|
slug |
str
|
Slug |
translated_content |
Queryset[ExperimentTranslatedContent]
|
Translated content |
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 experiment/models.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
associated_blocks()
#
Return a list of all associated blocks for this experiment
Returns:
Type | Description |
---|---|
list[Block]
|
Associated blocks |
Source code in experiment/models.py
current_participants()
#
Get distinct list of participants
Returns:
Type | Description |
---|---|
Participant
|
Associated participants |
Source code in experiment/models.py
export_feedback()
#
export feedback for the blocks in this experiment
Returns:
Type | Description |
---|---|
QuerySet[Session]
|
Associated block feedback |
Source code in experiment/models.py
export_sessions()
#
export sessions for this experiment
Returns:
Type | Description |
---|---|
QuerySet[Session]
|
Associated sessions |
Source code in experiment/models.py
get_current_content(fallback=True)
#
Get content for the ‘current’ language
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fallback |
bool
|
Return fallback language if language isn’t available |
True
|
Returns:
Type | Description |
---|---|
ExperimentTranslatedContent
|
Translated content |
Source code in experiment/models.py
get_fallback_content()
#
Get fallback content for the experiment
Returns:
Type | Description |
---|---|
ExperimentTranslatedContent
|
Translated content |
get_translated_content(language, fallback=True)
#
Get content for a specific language
Parameters:
Name | Type | Description | Default |
---|---|---|---|
language |
str
|
Language code |
required |
fallback |
bool
|
Return fallback language if language isn’t available |
True
|
Returns:
Type | Description |
---|---|
ExperimentTranslatedContent
|
Translated content |
Source code in experiment/models.py
ExperimentTranslatedContent
#
Bases: TranslatedContent
Translated content for an Experiment
Attributes:
Name | Type | Description |
---|---|---|
experiment |
Experiment
|
Associated experiment |
index |
int
|
Index |
language |
str
|
Language code |
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 |
Source code in 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 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 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 experiment/models.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
|
get_content(score)
#
Get social media share content
Parameters:
Name | Type | Description | Default |
---|---|---|---|
score |
float
|
Score |
required |
experiment_name |
Experiment name |
required |
Returns:
Type | Description |
---|---|
str
|
Social media shared text |
Raises:
Type | Description |
---|---|
ValueError
|
If required parameters are missing when needed |
Source code in experiment/models.py
consent_upload_path(instance, filename)
#
Generate path to save consent file based on experiment.slug and language
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance |
Experiment
|
Experiment instance to determine folder name |
required |
filename |
str
|
Name of the consent file to be uploaded |
required |
Returns:
Name | Type | Description |
---|---|---|
upload_to |
str
|
Path for uploading the consent file |
Note
Used by the Block model for uploading consent file