Experiment utils
experiment.utils#
block_export_json_results(block_slug)
#
Export block JSON data as zip archive
Source code in experiment/utils.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
Source code in experiment/utils.py
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
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 |
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
get_block_json_export_as_repsonse(block_slug)
#
Create a download response for the admin experimenter dashboard
Source code in experiment/utils.py
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
slugify(text)
#
Create a slug from given string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Input text (str) |
required |
Returns:
Type | Description |
---|---|
str
|
slug |