Skip to content

sweetbean.stimulus.InformedConsent

Informed consent screen: full text as HTML, advance with SPACE (html-keyboard-response).

Two visual styles are supported:

  • "default" (the default): a generic, minimal consent layout that simply lists the merged YAML-style fields under bold headings.
  • "princeton" (opt-in): renders the consent in the layout used by the Princeton University Adult Consent Form (see IRB.pdf in the autopi repo). Boilerplate text and IRB contact info default to Princeton's; any field can still be overridden from the consent_config dict.

Styling notes

Sweetbean's bundled main.css declares a global div { font-size: 36pt; line-height: 40pt } rule on top of a black body. Any nested <div> inside the rendered consent that does NOT carry its own inline font-size inherits that 36pt — which makes long-form consent text explode. To avoid that, both renderers prepend a single scoped <style> block that pins font-size: inherit on every descendant of .sweetbean-informed-consent; the more specific selector beats sweetbean's global div rule, so the consent's own typography survives. Visual hierarchy is then expressed through semantic class names (.ic-title, .ic-section-title, .ic-banner, .ic-press-space, .ic-meta, .ic-clauses) instead of brittle per-element inline styles.

InformedConsent

Bases: HtmlKeyboardResponse

Presents merged research/consent fields as HTML; participant presses SPACE to continue. No separate continue_text field — the footer copy is fixed in English.

Pass style="princeton" to :meth:from_sections to render in the Princeton University ADULT CONSENT FORM layout (see IRB.pdf).

Auto-fit is disabled by default for this stimulus: consent text is typically too long to scale-to-fit and should remain readable at its natural font size with the trial scrolling normally. Override with fit_to_viewport=True per-instance if you really want the consent body shrunk to one screen. See AUTHORING.md §"Auto-fit to viewport".

Source code in sweetbean/stimulus/InformedConsent.py
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
class InformedConsent(HtmlKeyboardResponse):
    """
    Presents merged research/consent fields as HTML; participant presses SPACE to continue.
    No separate ``continue_text`` field — the footer copy is fixed in English.

    Pass ``style="princeton"`` to :meth:`from_sections` to render in the
    Princeton University ADULT CONSENT FORM layout (see ``IRB.pdf``).

    Auto-fit is **disabled** by default for this stimulus: consent text is
    typically too long to scale-to-fit and should remain readable at its
    natural font size with the trial scrolling normally. Override with
    ``fit_to_viewport=True`` per-instance if you really want the consent
    body shrunk to one screen. See AUTHORING.md §"Auto-fit to viewport".
    """

    fit_to_viewport = False

    @classmethod
    def from_sections(
        cls,
        *,
        research_config: dict[str, Any] | None = None,
        consent_config: dict[str, Any] | None = None,
        duration: Any = None,
        side_effects: Any = None,
        style: str = "default",
    ) -> InformedConsent:
        """
        Merge ``research_config`` then ``consent_config`` (consent wins on key clashes),
        render HTML, and return an :class:`HtmlKeyboardResponse` trial with SPACE to advance.

        :param style: Visual layout. ``"default"`` (the default) keeps the original
            generic layout; ``"princeton"`` opts in to the Princeton University
            Adult Consent Form layout described in ``IRB.pdf``.
        """
        a = dict(research_config or {})
        b = dict(consent_config or {})
        merged = {**a, **b}
        stimulus_html = _render_consent_html(merged, style=style)
        return cls(
            duration=duration,
            stimulus=stimulus_html,
            choices=[" "],
            correct_key="",
            side_effects=side_effects,
        )

from_sections(*, research_config=None, consent_config=None, duration=None, side_effects=None, style='default') classmethod

Merge research_config then consent_config (consent wins on key clashes), render HTML, and return an :class:HtmlKeyboardResponse trial with SPACE to advance.

:param style: Visual layout. "default" (the default) keeps the original generic layout; "princeton" opts in to the Princeton University Adult Consent Form layout described in IRB.pdf.

Source code in sweetbean/stimulus/InformedConsent.py
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
@classmethod
def from_sections(
    cls,
    *,
    research_config: dict[str, Any] | None = None,
    consent_config: dict[str, Any] | None = None,
    duration: Any = None,
    side_effects: Any = None,
    style: str = "default",
) -> InformedConsent:
    """
    Merge ``research_config`` then ``consent_config`` (consent wins on key clashes),
    render HTML, and return an :class:`HtmlKeyboardResponse` trial with SPACE to advance.

    :param style: Visual layout. ``"default"`` (the default) keeps the original
        generic layout; ``"princeton"`` opts in to the Princeton University
        Adult Consent Form layout described in ``IRB.pdf``.
    """
    a = dict(research_config or {})
    b = dict(consent_config or {})
    merged = {**a, **b}
    stimulus_html = _render_consent_html(merged, style=style)
    return cls(
        duration=duration,
        stimulus=stimulus_html,
        choices=[" "],
        correct_key="",
        side_effects=side_effects,
    )