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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
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
export_table(session_keys, result_keys, export_options)
#
Export filtered tabular data for admin
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_keys |
list[str]
|
session fieldnames to be included |
required |
result_keys |
list[str]
|
result fieldnames to be included |
required |
export_options |
dict[str, Any]
|
export options (see admin/forms.py) |
required |
Returns:
Type | Description |
---|---|
tuple[list[dict[str, Any]], list[str]]
|
csv rows, field names |
Source code in experiment/models.py
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 393 394 395 396 397 398 399 400 |
|
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
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
|
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