Experiment utils
experiment.utils
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
Source code in experiment/utils.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
create_player_labels(num_labels, label_style='number')
Create player labels
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_labels |
int
|
Number of labels |
required |
label_style |
str
|
‘number’, ‘alphabetic’, ‘roman’ |
'number'
|
Returns:
Type | Description |
---|---|
list[str]
|
Player label |
Source code in experiment/utils.py
77 78 79 80 81 82 83 84 85 86 87 88 |
|
external_url(text, url)
Create a HTML element for an external url
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text |
required |
url |
Url |
required |
Returns:
Type | Description |
---|---|
str
|
HTML element |
Source code in experiment/utils.py
63 64 65 66 67 68 69 70 71 72 73 74 |
|
format_label(number, label_style)
Generate player_label for create_player_label()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number |
int
|
index |
required |
label_style |
str
|
‘number’, ‘alphabetic’, ‘roman’ |
required |
Returns:
Type | Description |
---|---|
str
|
Player label |
Source code in experiment/utils.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
non_breaking_spaces(input_string)
Convert regular spaces to non breaking spacing on the given string Args: input_string: Input string
Returns:
Type | Description |
---|---|
str
|
String with non breaking spaces |
Source code in experiment/utils.py
50 51 52 53 54 55 56 57 58 59 60 |
|
slugify(text)
Create a slug from given string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Input text (str) |
required |
Returns:
Type | Description |
---|---|
str
|
slug |
Source code in experiment/utils.py
9 10 11 12 13 14 15 16 17 18 19 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 |
|