Exp-lookit-dialogue-page Class
These docs have moved here.This class is deprecated.
This frame is deprecated and will not be included in release 2.x. For new studies, use the frame Exp-lookit-images-audio instead.
Frame to implement a storybook page with dialogue spoken by characters. First, characters appear and any main narration audio is played. Next, the user can click on the characters to play additional audio associated with each character image, or (for a choice trial) the user clicks one of the images to select it as an answer. Once main narration audio has been played and either a selection has been made (for a choice trial, isChoiceFrame: true) or all required character audio has been played (for a non-choice trial), the user can proceed by pressing 'next'. (A trial with only main narration audio can also simply auto-proceed when audio is finished.)
Recording is optional. If webcam recording is conducted (doRecording: true) then audio does not start until recording does, to ensure the entire trial is recorded.
The character images are specified in 'images', including an image source, positioning on the screen, any animation at the start of the trial, any associated audio, and whether that audio is required.
This frame is displayed fullscreen; if the frame before it is not, that frame needs to include a manual "next" button so that there's a user interaction event to trigger fullscreen mode. (Browsers don't allow us to switch to FS without a user event.)
The examples below show a few expected uses of this frame. In phase-2, two characters are shown; the protagonist is already present, and speaker1 flies in from the left. Speaker1 has associated audio (dialogue). After the narrative audio, the user can click on speaker1 to play the audio, and will then be able to proceed.
phase-5 is a choice trial, where the user has to click on one of the two images before proceeding.
"frames": {
"phase-2": {
"kind": "exp-lookit-dialogue-page",
"baseDir": "https://s3.amazonaws.com/lookitcontents/politeness/",
"audioTypes": ["mp3", "ogg"],
"backgroundImage": "order1_test1_background.png",
"doRecording": false,
"autoProceed": false,
"parentTextBlock": {
"title": "Parents!",
"text": "some instructions",
"emph": true,
"css": {
"color": "red",
"font-size": "12px"
}
},
"images": [
{
"id": "protagonist",
"src": "order1_test1_listener1.png",
"left": "40",
"bottom": "2",
"height": "60"
},
{
"id": "speaker1",
"text": "Click to hear what he said!",
"src": "order1_test1_speaker1.png",
"left": "20",
"bottom": "2",
"height": "60",
"animate": "flyleft",
"requireAudio": true,
"imageAudio": "polcon_example_2_2speaker1polite"
}
],
"audioSources": [
{
"audioId": "firstAudio",
"sources": "polcon_example_2_1intro"
}
]
},
"phase-5": {
"kind": "exp-lookit-dialogue-page",
"baseDir": "https://s3.amazonaws.com/lookitcontents/politeness/",
"audioTypes": ["mp3", "ogg"],
"backgroundImage": "order1_test1_background.png",
"doRecording": false,
"autoProceed": false,
"isChoiceFrame": true,
"parentTextBlock": {
"title": "Parents:",
"text": "click on the character your child selects.",
"emph": true
},
"images": [
{
"id": "speaker1",
"src": "order1_test1_speaker1.png",
"left": "20",
"bottom": "2",
"height": "60"
},
{
"id": "speaker2",
"src": "order1_test1_speaker2.png",
"left": "60",
"bottom": "2",
"height": "60"
}
],
"audioSources": [
{
"audioId": "firstAudio",
"sources": "polcon_example_5q1"
}
]
}
}
Item Index
Methods
- destroyRecorder
- destroySessionRecorder
- exitFullscreen
- hideRecorder
- makeTimeEvent
- onRecordingStarted
- onSessionRecordingStarted
- serializeContent
- setupRecorder
- showFullscreen
- showRecorder
- startRecorder
- startSessionRecorder
- stopRecorder
- stopSessionRecorder
- whenPossibleToRecordObserver
- whenPossibleToRecordSessionObserver
Properties
- assetsToExpand
- audioOnly
- audioSources
- audioTypes
- autoProceed
- autosave
- backgroundImage
- baseDir
- displayFullscreen
- displayFullscreenOverride
- doRecording
- doUseCamera
- endSessionRecording
- fsButtonID
- fullScreenElementId
- generateProperties
- images
- isChoiceFrame
- maxRecordingLength
- maxUploadSeconds
- nPhase
- nTrial
- parameters
- parentTextBlock
- recorder
- recorderElement
- recorderReady
- selectNextFrame
- sessionAudioOnly
- sessionMaxUploadSeconds
- showWaitForRecordingMessage
- showWaitForUploadMessage
- startRecordingAutomatically
- startSessionRecording
- stoppedRecording
- videoId
- videoList
- videoTypes
- waitForRecordingMessage
- waitForRecordingMessageColor
- waitForUploadMessage
- waitForUploadMessageColor
- waitForWebcamImage
- waitForWebcamVideo
Data collected
Methods
destroyRecorder
()
destroySessionRecorder
()
exitFullscreen
()
hideRecorder
()
makeTimeEvent
-
eventName
-
[extra]
Create the time event payload for a particular frame / event. This can be overridden to add fields to every event sent by a particular frame
Parameters:
Returns:
Event type, time, and any additional metadata provided
onRecordingStarted
()
onSessionRecordingStarted
()
serializeContent
-
eventTimings
Each frame that extends ExpFrameBase will send at least an array eventTimings
,
a frame type, and any generateProperties back to the server upon completion.
Individual frames may define additional properties that are sent.
Parameters:
-
eventTimings
Array
Returns:
setupRecorder
-
element
Parameters:
-
element
NodeA DOM node representing where to mount the recorder
Returns:
showFullscreen
()
showRecorder
()
startRecorder
()
Returns:
startSessionRecorder
()
Returns:
stopRecorder
()
Returns:
stopSessionRecorder
()
Returns:
whenPossibleToRecordObserver
()
whenPossibleToRecordSessionObserver
()
Properties
audioOnly
Number
Default: 0
audioSources
Object[]
Array of objects describing audio to play at the start of this frame. Each element describes a separate audio segment.
Sub-properties:
-
audioId
Stringunique string identifying this audio segment
-
sources
Object[]Array of {src: 'url', type: 'MIMEtype'} objects with audio sources for this segment.
Can also give a single string 'filename', which will be expanded out to the appropriate array based on
baseDir
andaudioTypes
values; seeaudioTypes
. -
highlights
Object[]Array of {'range': [startT, endT], 'image': 'imageId'} objects, where the imageId values correspond to the ids given in images
audioTypes
String[]
['typeA', 'typeB']
and an audio source
is given as intro
, the audio source will be
expanded out to
[
{
src: 'baseDir' + 'typeA/intro.typeA',
type: 'audio/typeA'
},
{
src: 'baseDir' + 'typeB/intro.typeB',
type: 'audio/typeB'
}
]
Default: ['mp3', 'ogg']
autosave
Number
private
Default: 1
baseDir
String
baseDir
+ img/
. Any audio/video src values provided as
strings rather than objects with src
and type
will be
expanded out to baseDir/avtype/[stub].avtype
, where the potential
avtypes are given by audioTypes
and videoTypes
.
baseDir should include a trailing slash
(e.g., http://stimuli.org/myexperiment/
); if a value is provided that
does not end in a slash, one will be added.
Default: ''
displayFullscreenOverride
String
true
to display this frame in fullscreen mode, even if the frame type
is not always displayed fullscreen. (For instance, you might use this to keep
a survey between test trials in fullscreen mode.)
Default: false
doRecording
Boolean
Whether to do webcam recording (will wait for webcam connection before starting audio if so)
doUseCamera
Boolean
Default: true
endSessionRecording
Number
Default: false
fullScreenElementId
String
private
generateProperties
String
Function to generate additional properties for this frame (like {"kind": "exp-lookit-text"}) at the time the frame is initialized. Allows behavior of study to depend on what has happened so far (e.g., answers on a form or to previous test trials). Must be a valid Javascript function, returning an object, provided as a string.
Arguments that will be provided are: expData
, sequence
, child
, pastSessions
, conditions
.
expData
, sequence
, and conditions
are the same data as would be found in the session data shown
on the Lookit experimenter interface under 'Individual Responses', except that
they will only contain information up to this point in the study.
expData
is an object consisting of frameId
: frameData
pairs; the data associated
with a particular frame depends on the frame kind.
sequence
is an ordered list of frameIds, corresponding to the keys in expData
.
conditions
is an object representing the data stored by any randomizer frames;
keys are frameId
s for randomizer frames and data stored depends on the randomizer
used.
child
is an object that has the following properties - use child.get(propertyName)
to access:
additionalInformation
: String; additional information field from child formageAtBirth
: String; child's gestational age at birth in weeks. Possible values are "24" through "39", "na" (not sure or prefer not to answer), "<24" (under 24 weeks), and "40>" (40 or more weeks).birthday
: Date objectgender
: "f" (female), "m" (male), "o" (other), or "na" (prefer not to answer)givenName
: String, child's given name/nicknameid
: String, child UUIDlanguageList
: String, space-separated list of languages child is exposed to (2-letter codes)conditionList
: String, space-separated list of conditions/characteristics- of child from registration form, as used in criteria expression, e.g. "autism_spectrum_disorder deaf multiple_birth"
pastSessions
is a list of previous response objects for this child and this study,
ordered starting from most recent (at index 0 is this session!). Each has properties
(access as pastSessions[i].get(propertyName)):
completed
: Boolean, whether they submitted an exit surveycompletedConsentFrame
: Boolean, whether they got through at least a consent frameconditions
: Object representing any conditions assigned by randomizer framescreatedOn
: Date objectexpData
: Object consisting of frameId: frameData pairsglobalEventTimings
: list of any events stored outside of individual frames - currently just used for attempts to leave the study earlysequence
: ordered list of frameIds, corresponding to keys in expDataisPreview
: Boolean, whether this is from a preview session (possible in the event this is an experimenter's account)
Example:
function(expData, sequence, child, pastSessions, conditions) {
return {
'blocks':
[
{
'text': 'Name: ' + child.get('givenName')
},
{
'text': 'Frame number: ' + sequence.length
},
{
'text': 'N past sessions: ' + pastSessions.length
}
]
};
}
(This example is split across lines for readability; when added to JSON it would need to be on one line.)
Default: null
images
Object[]
Array of images to display and information about their placement
Sub-properties:
-
id
Stringunique ID for this image. This will be used to refer to the choice made by the user, if any.
-
src
StringURL of image source (can be full URL, or stub to append to baseDir; see
baseDir
) -
left
Stringdistance from left of story area to image center, as percentage of story area width - as string
-
height
Stringimage height, as percentage of story area height - as string
-
bottom
Stringbottom margin, as percentage of story area height - as string
-
animate
Stringanimation to use at start of trial on this image, if any. If not provided, image is shown throughout trial. Options are 'fadein', 'fadeout', 'flyleft' (fly from left), and 'flyright'.
-
text
Stringtext to display above image, e.g. 'Click to hear what he said!' If omitted, no text is shown.
-
imageAudio
Object[]sources Array of {src: 'url', type: 'MIMEtype'} objects with audio sources for audio to play when this image is clicked, if any. (Omit to not associate audio with this image.)
Can also give a single string
filename
, which will be expanded out to the appropriate array based onbaseDir
andaudioTypes
values; seeaudioTypes
. -
requireAudio
Booleanwhether to require the user to click this image and complete the audio associated before proceeding to the next trial. (Incompatible with autoProceed.)
isChoiceFrame
Boolean
Whether this is a frame where the user needs to click to select one of the images before proceeding
Default: false
maxRecordingLength
Number
Default: 7200
maxUploadSeconds
Number
Default: 5
nPhase
Number
Phase number (just included as a convenience & sent to server, to make handling collected data simpler)
Default: 0
nTrial
Number
Trial number (just included as a convenience & sent to server, to make handling collected data simpler)
Default: 0
parameters
Object[]
An object containing values for any parameters (variables) to use in this frame.
Any property VALUES in this frame that match any of the property NAMES in parameters
will be replaced by the corresponding parameter value. For example, suppose your frame
is:
{
'kind': 'FRAME_KIND',
'parameters': {
'FRAME_KIND': 'exp-lookit-text'
}
}
Then the frame kind
will be exp-lookit-text
. This may be useful if you need
to repeat values for different frame properties, especially if your frame is actually
a randomizer or group. You may use parameters nested within objects (at any depth) or
within lists.
You can also use selectors to randomly sample from or permute
a list defined in parameters
. Suppose STIMLIST
is defined in
parameters
, e.g. a list of potential stimuli. Rather than just using STIMLIST
as a value in your frames, you can also:
- Select the Nth element (0-indexed) of the value of
STIMLIST
: (Will cause error ifN >= THELIST.length
)
'parameterName': 'STIMLIST#N'
- Select (uniformly) a random element of the value of
STIMLIST
:
'parameterName': 'STIMLIST#RAND'
- Set
parameterName
to a random permutation of the value ofSTIMLIST
:
'parameterName': 'STIMLIST#PERM'
- Select the next element in a random permutation of the value of
STIMLIST
, which is used across all substitutions in this randomizer. This allows you, for instance, to provide a list of possible images in yourparameterSet
, and use a different one each frame with the subset/order randomized per participant. If moreSTIMLIST#UNIQ
parameters than elements ofSTIMLIST
are used, we loop back around to the start of the permutation generated for this randomizer.
'parameterName': 'STIMLIST#UNIQ'
Default: {}
recorder
VideoRecorder
private
recorderReady
Boolean
private
selectNextFrame
String
Function to select which frame index to go to when using the 'next' action on this frame. Allows flexible looping / short-circuiting based on what has happened so far in the study (e.g., once the child answers N questions correctly, move on to next segment). Must be a valid Javascript function, returning a number from 0 through frames.length - 1, provided as a string.
Arguments that will be provided are:
frames
, frameIndex
, expData
, sequence
, child
, pastSessions
frames
is an ordered list of frame configurations for this study; each element
is an object corresponding directly to a frame you defined in the
JSON document for this study (but with any randomizer frames resolved into the
particular frames that will be used this time).
frameIndex
is the index in frames
of the current frame
expData
is an object consisting of frameId
: frameData
pairs; the data associated
with a particular frame depends on the frame kind.
sequence
is an ordered list of frameIds, corresponding to the keys in expData
.
child
is an object that has the following properties - use child.get(propertyName)
to access:
additionalInformation
: String; additional information field from child formageAtBirth
: String; child's gestational age at birth in weeks. Possible values are "24" through "39", "na" (not sure or prefer not to answer), "<24" (under 24 weeks), and "40>" (40 or more weeks).birthday
: timestamp in format "Mon Apr 10 2017 20:00:00 GMT-0400 (Eastern Daylight Time)"gender
: "f" (female), "m" (male), "o" (other), or "na" (prefer not to answer)givenName
: String, child's given name/nicknameid
: String, child UUID
pastSessions
is a list of previous response objects for this child and this study,
ordered starting from most recent (at index 0 is this session!). Each has properties
(access as pastSessions[i].get(propertyName)):
completed
: Boolean, whether they submitted an exit surveycompletedConsentFrame
: Boolean, whether they got through at least a consent frameconditions
: Object representing any conditions assigned by randomizer framescreatedOn
: timestamp in format "Thu Apr 18 2019 12:33:26 GMT-0400 (Eastern Daylight Time)"expData
: Object consisting of frameId: frameData pairsglobalEventTimings
: list of any events stored outside of individual frames - currently just used for attempts to leave the study earlysequence
: ordered list of frameIds, corresponding to keys in expData
Example that just sends us to the last frame of the study no matter what:
`"function(frames, frameIndex, frameData, expData, sequence, child, pastSessions) {return frames.length - 1;}"
``
Default: null
sessionAudioOnly
Number
Default: 0
sessionMaxUploadSeconds
Number
Default: 10
showWaitForRecordingMessage
Boolean
Default: true
showWaitForUploadMessage
Boolean
Default: true
startRecordingAutomatically
Boolean
Default: false
startSessionRecording
Number
Default: false
stoppedRecording
Boolean
private
videoId
String
private
videoStream_<experimentId>_<frameId>_<sessionId>_timestampMS_RRR
where RRR are random numeric digits.
videoList
List
private
videoTypes
String[]
['typeA', 'typeB']
and a video source
is given as intro
, the video source will be
expanded out to
[
{
src: 'baseDir' + 'typeA/intro.typeA',
type: 'video/typeA'
},
{
src: 'baseDir' + 'typeB/intro.typeB',
type: 'video/typeB'
}
]
Default: ['mp4', 'webm']
waitForRecordingMessage
Boolean
Default: 'Please wait... <br><br> starting webcam recording'
waitForRecordingMessageColor
Boolean
Default: 'white'
waitForUploadMessage
Boolean
Default: 'Please wait... <br><br> uploading video'
waitForUploadMessageColor
String
Default: 'white'
waitForWebcamImage
String
`baseDir/img/
if this frame otherwise supports use of
baseDir
`.
Default: ''
waitForWebcamVideo
String
`{'src': 'https://...', 'type': '...'}
` objects (e.g. providing both
webm and mp4 versions at specified URLS) or a single string relative to `baseDir/<EXT>/
` if this frame otherwise
supports use of `baseDir
`.
Default: ''
Data keys collected
These are the fields that will be captured by this frame and sent back to the Lookit server. Each of these fields will correspond to one row of the CSV frame data for a given response - the row will havekey
set to the data key name, and value
set to the value for this response.
Equivalently, this data will be available in the exp_data
field of the response JSON data.
currentlyHighlighted
Which image is selected at the end of the trial, or null if none is. This indicates the final selected choice for a choice trial.
eventTimings
Ordered list of events captured during this frame (oldest to newest). Each event is
represented as an object with at least the properties
{'eventType': EVENTNAME, 'timestamp': TIMESTAMP}
.
See Events tab for details of events that might be captured.
frameType
Type of frame: EXIT (exit survey), CONSENT (consent or assent frame), or DEFAULT (anything else)
Events
completeMainAudio
When narration audio is completed
enteredFullscreen
leftFullscreen
nextFrame
Move to next frame
pauseVideo
playSpeakerAudio
When image audio is played (recorded even if not completed)
Event Payload:
-
imageId
String
previousFrame
Move to previous frame
recorderReady
sessionRecorderReady
startSessionRecording
stoppingCapture
stopSessionRecording
unpauseVideo
videoStreamConnection
Event Payload:
-
status
Stringstatus of video stream connection, e.g. 'NetConnection.Connect.Success' if successful