{# Embedded HTML5 audio, with optional force-listen gating and telemetry. Audio always uses native controls — there is no `minimal_controls` because the scrubber doubles as the only progress indicator the participant has. When `force_listen` is on, a snap-back guard prevents seeking past the supposed playhead position. When `id` is set, three telemetry columns are written: {id}_started (epoch seconds when first played, 0 if never), {id}_ended (epoch seconds at last observed activity), and {id}_listened (accumulated forward play time in seconds, excluding seeks and background-tab playback). Args: id (str, optional): When set, telemetry is recorded; when omitted, the clip is purely embedded and produces no database columns. src (str): URL of the audio file. autoplay (bool, optional): Start playback as soon as the page loads. Defaults to False. force_listen (bool, optional): When true, the Continue button is disabled until the participant has listened to at least completion_threshold of the clip. Defaults to False. completion_threshold (float, optional): Fraction of total duration that counts as "listened". Defaults to 0.98. Example: { "questiontype": "audio", "id": "new_audio", "instructions": "", "src": "/static/clip.mp3", "force_listen": false, "completion_threshold": 0.98 } #} {% set fl = question.force_listen|default(false) %} {% set threshold = question.completion_threshold|default(0.98) %} {% set prior_started = question.prior_started|default(0) %} {% set prior_ended = question.prior_ended|default(0) %} {% set prior_listened = question.prior_listened|default(0) %}
{% if question.id %} {% endif %}