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
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
export_json_results(block)
#
Export block JSON data as zip archive, force download
Source code in experiment/utils.py
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 |
|
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
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 |