Value#

class alfred3.element.misc.Value(value: Union[str, int, float], name: str, description: str = '')[source]#

Bases: alfred3.element.core.InputElement

Value elements can be used to save data without any display.

Parameters
  • value – The value that you want to save.

  • name – Name of the element. This should be a unique identifier. It will be used to identify the corresponding data in the final data set.

Examples

Minimal example:

import alfred3 as al
exp = al.Experiment()

@exp.member
class Demo(al.Page):
    name = "demo1"

    def on_exp_access(self):
        self += al.Value("test", name="myvalue")

Methods

add_css

Adds CSS to the element.

add_js

Adds Javascript to the element.

added_to_experiment

Tells the element that it was added to an experiment.

added_to_page

Tells the element that it was added to a page.

prepare_web_widget

Hook for computations for preparing an element's web widget.

render_inner_html

Renders the element template element_template.

set_data

Sets the input data.

validate_data

Method for validation of input to the element.

Attributes

base_template

Base template for the element, which will be used to hold the rendered element template.

bottomlab

Label below of the main element widget.

codebook_data

Information about the element in dictionary form.

converted_width

List of bootstrap column widths at different screen sizes.

corrective_hints

Shortcut for accessing the element's corrective hints.

css_class_container

Returns the name the element container's CSS class.

css_class_element

Returns the name of the element's CSS class.

css_code

A list of tuples, which contain a priority and CSS code.

css_urls

A list of tuples, which contain a priority and an url pointing to CSS code.

data

Dictionary of element data.

debug_enabled

Boolean flag, indicating whether debug mode is enabled and default values should be set.

debug_value

Value to be used as a default in debug mode.

default

Default value of this element.

default_no_input_hint

Default hint if subject input is missing in force_entry elements.

description

Detailed description of this element to be added to the automatically generated codebook

disabled

A boolean flag, indicating whether the element is disabled A disabled input element is shown and displays its input value, but subjects cannot enter any data.

display_standalone

If True (default), the element will be displayed as usual on its own.

element_template

The element's specific, inner template.

element_width

Returns a string of column width definitions.

exp

The experiment session to which this element belongs.

experiment

Alias for exp

font_size

Font size

force_input

If True, subjects must fill this element to proceed.

hint_manager

A MessageManager, handling the corrective hints for this element.

input

The value that you want to save.

js_code

A list of tuples, which contain a priority and Javascript.

js_urls

A list of tuples, which contain a priority and an url pointing to JavaScript.

labels

Returns the labels in a single, nicely formatted string.

layout

Controls the allocation of horizontal space between the left and right label, as well as the main element.

leftlab

Label to the left of the main element widget.

name

Unique identifier for the element.

no_input_hint

Hint for subjects, if they left a force_input field empty.

page

The page to which this element belongs.

position

Position of the whole element on the page.

prefix

A string or element, serving as prefix.

rightlab

Label to the right of the main element widget.

section

The direct parent section of this element's page.

short_tree

String, giving the exact position in the experiment.

should_be_shown

Boolean, indicating whether the element is meant to be shown.

show_hints

Flag, indicating whether corrective hints regarding this element should be shown.

showif

Conditions that have to be met for the element to be shown.

suffix

A string or element, serving as suffix.

template_data

Dictionary of data to be passed on to jinja templates.

toplab

Label above of the main element widget.

tree

String, giving the exact position in the experiment.

web_widget

The element's rendered html code for display on a page.

width

Element width