Table of contents
- List of the available _magpie views
- Properties of _magpie's Trial Type Views
- Properties of _magpie's Wraping views Type Views
- Trial views' lifecycle
- Trial views' hooks
- Trial views data format
- Forced-choice data format
- Textbox Input data format
- Slider Rating data format
- Dropdown choice data format
- Rating scale data format
- Sentence choice data format
- Image selection data format
- Key press data format
- Self-paced reading with forced choice response data format
- Self-paced reading with slider rating response data format
- Sample use of _magpie views
- magpieViews.forcedChoice
- magpieViews.sliderRating
- magpieViews.dropdownChoice
- magpieViews.textboxInput
- magpieViews.ratingScale
- magpieViews.imageSelection
- magpieViews.sentenceChoice
- magpieViews.keyPress
- magpieViews.selfPacedReading
- magpieViews.selfPacedReading_ratingScale
- magpieViews.intro
- gives general information about the experiment
- records the participant's prolific id if the experiment runs on Prolific
- magpieViews.instructions
- gives experiment-specific instructions
- magpieViews.begin
- warns the participant the experiment is about to begin
- can be used between the practice trial and the main trial
- magpieViews.postTest
- collects extra information about the participant (age, gender, etc.)
- magpieViews.thanks (and submit the data)
- Debug mode: displays the data
- submits the data of the live experiments
trials: int
- the number of trials this view will appearname: string
trial_type: string
- the name of the trial type as you want it to appear in the submitted the final data (for example 'main binary choice')data: array
- an array of trial objects
title: string
- the title at the top of the viewpause: number (in ms)
- blank screen before the fixation point or stimulus showfix_duration: number (in ms)
- blank screen with fixation point in the middlestim_duration: number (in ms)
- for how long to have the stimulus on the screenhook: object
- option to hook and add custom functions to the view. more about hooks
trials: int
- the number of trials this view will appearname: string
-
magpieViews.intro:
buttonText: string
- the text of the button that takes the participant to the next view
- default: 'Next'
title: string
- the title of the view
- default: 'Welcome!'
text: string
- the text of the view
- default: there is no default
-
magpieViews.instructions:
buttonText: string
- the text of the button that takes the participant to the next view
- default: 'Next'
title: string
- the title of the view
- default: 'Instructions'
text: string
- the text of the view
- default: there is no default
-
magpieViews.begin:
buttonText: string
- the text of the button that takes the participant to the next view
- default: 'Next'
title: string
- the title of the view
- default: 'Begin'
text: string
- the text of the view
- default: there is no default
-
magpieViews.postTest:
buttonText: string
- the text of the button that takes the participant to the next view
- default: 'Next'
title: string
- the title of the view
- default: 'Additional Information'
text: string
- the text of the view
- default: there is no default
age_question: string
- question about participant's age
- default: 'Age',
gender_question: string
- question about participant's gender
- default: 'Gender'
gender_male: string
- answer option for the gender question
- default: 'male'
gender_female: string
- answer option for the gender question
- default: 'female'
gender_other: string
- answer option for the gender question
- default: 'other'
edu_question: string
- question about participant's level of education
- default: 'Level of Education'
edu_graduated_high_school: string
- answer option for the education question
- default: 'Graduated High School'
edu_graduated_college: string
- answer option for the education question
- default: 'Graduated College'
edu_higher_degree: string
- answer option for the education question
- default: 'Higher Degree'
languages_question: string
- question about participant's native languages
- default: 'Native Languages'
languages_more: string
- more info about what native languages are
- default: '(i.e. the language(s) spoken at home when you were a child)'
-
magpieViews.thanks:
title: string
- the title of the view
- default: 'Thank you for taking part in this experiment!'
prolificConfirmText: string
- text asking the participant to press the 'confirm' button
- default: 'Please press the button below to confirm that you completed the experiment with Prolific'
All the trial views go through 4 steps.
-
pause step - blank screen
- enable by passing
pause: number (in miliseconds)
(will show a pause for after number amount of time) - shows nothing but a blank screen and the
QUD
if there is such
- enable by passing
-
fixation point step - a cross in the middle where the stimulus appears
- passed to the trial view as
fix_duration: number (in miliseconds)
- shows a cross in the middle of the stimulus and the
QUD
if there is such
- passed to the trial view as
-
stimulus shown step - stimulus appears
3.5 (optional) stimulus hidden step - hides the stimulus from the screen
* hide the stimulus after certain amount of time by passing stim_duration: number (in miliseconds)
to the view creation
* hide the stimulus when SPACE gets pressed with stim_duration: 'space'
* skip this step by not defining stim_duration
- interactions are enabled - the participant can interact with the view (respond, read the sentence etc.)
The views you created do not need to use these timeouts, however, each trial view still goes through these steps on the background and you can still hook and call locally defined functions
You can create functions in your local js files and hook these functions to the trial view. To understand how hooks work, first learn about magpie's trial views lifecycle
Hooks
-
after the pause is finished enable with
hook.after_pause: _function_
-
after the fixation point hides enable with
hook.after_fin_point: _function_
-
after the stimulus is shown enable with
hook.after_stim_shown: _function_
-
after the stimulus hides enable with
hook.after_stim_hidden: _function_
-
after the interactions are enabled enable with
hook.after_response_enabled: _function_
Your custom functions get the trial data
for each trial view and next
as arguments. You can use the data
if you need to. To proceed to the next step of the lifecycle, you have to call next()
Full lifecycle - hook sample
- pause shows
- pause finishes
- after_pause function called
- fixation point shows
- fixation point disappears
- after_fix_point function called
- stimulus shows
- after_stim_shown function called
- stimlus hides
- after_stim_hidden function called
- response is enabled
- after_response_enabled function called
Real example
Imagine you want to tell the participants whether their repsonse was correct while they are getting familiar with the experiment, for example in the practice trial view. To do that you need to get the answer they chose and check it for correctness. You can define a funciton that gets their response and hook to the trial view after the response is enabled. In the example below, assume that option1
is always the correct answer.
// compares the chosen answer to the value of `option1`
function checkResponse(data, next) {
$('input[name=answer]').on('change', function(e) {
if (e.target.value === data.option1) {
alert('Your answer is correct! Yey!');
} else {
alert('Sorry, this answer is incorrect :(');
}
next();
})
}
and add a after_response_enabled
hook to the view:
const practice = magpieViews.forcedChoice({
trials: 20,
name: 'practice',
trial_type: 'practice',
data: practice_trials.forcedChoice,
fix_duration: 500,
pause: 500,
hook: {
after_response_enabled: checkResponse
}
});
-
Obligatory Fileds
option1: string
option2: string
-
Optional Fields
question: string
QUD: string
- text that is always present on the slidecanvas: object
more about magpie canvaspicture: string (link)
const forced_choice_trials = [
{
picture: "path/to/picture_of_bread.jpg",
question: "What's on the bread?",
option1: "jam",
option2: "ham"
},
{
question: "What's the weather?",
option1: "shiny",
option2: "rainbow"
}
];
-
Obligatory Fileds
question: string
-
Optional Fields
QUD: string
- text that is always present on the slidecanvas: object
more about magpie canvaspicture: string (link)
min_chars: number
- the minumum number of characters in the textarea field before proceeding is available
- default - 10
const textbox_input_trials = [
{
picture: "path/to/picture.jpg",
question: "What's on the bread?",
min_chars: 100
},
{
question: "What's the weather?",
min_chars: 50
}
];
-
Obligatory Fileds
optionLeft: string
optionRight: string
-
Optional Fields
QUD: string
- text that is always present on the slidecanvas: object
more about magpie canvaspicture: string (link)
question: string
const slider_rating_trials = [
{
picture: 'path/to/picture_of_bread.jpg',
question: "What's on the bread?",
optionLeft: 'jam',
optionRight: 'ham'
},
{
question: "What's the weather?",
optionLeft: 'shiny',
optionRight: 'rainbow'
}
];
-
Obligatory Fileds
option1: string
option2: string
-
Optional Fields
QUD: string
- text that is always present on the slidecanvas: object
more about magpie canvaspicture: string (link)
question_left_part: string
question_right_part: string
const dropdown_choice_trials = [
{
picture: 'path/to/picture_of_bread.jpg',
question: "What's on the bread?",
option1: 'jam',
option2: 'ham'
},
{
question: "What's the weather?",
option1: 'shiny',
option2: 'rainbow'
}
];
-
Obligatory Fileds
optionLeft: string
optionRight: string
-
Optional Fields
QUD: string
- text that is always present on the slidecanvas: object
more about magpie canvaspicture: string (link)
question: string
const rating_scale_trials = [
{
picture: 'path/to/picture_of_bread.jpg',
question: 'What\'s on the bread?',
option1: 'jam',
option2: 'ham'
},
{
question: "What's the weather?",
option1: 'shiny',
option2: 'rainbow'
}
];
-
Obligatory Fileds
option1: string
option2: string
-
Optional Fields
QUD: string
- text that is always present on the slidecanvas: object
more about magpie canvaspicture: string (link)
question: string
const sentence_choice_trials = [
{
picture: 'path/to/picture_of_bread.jpg',
question: "What's on the bread?",
option1: 'jam',
option2: 'ham'
},
{
picture: 'path/to/picture_of_bread.jpg',
option1: 'jam',
option2: 'ham'
},
{
question: "What's the weather?",
option1: 'shiny',
option2: 'rainbow'
}
];
-
Obligatory Fileds
option1: string
option2: string
picture1: string (link)
- refers tooption1
picture2: string (link)
- refers tooption2
-
Optional Fields
QUD: string
- text that is always present on the slidequestion: string
canvas: object
more about magpie canvas
const image_selection_trials = [
{
picture1: 'path/to/picture1.jpg',
picture2: 'path/to/picture2.jpg',
option1: 'yes',
option2: 'no'
},
{
picture1: 'path/to/picture_of_bread1.jpg',
picture2: 'path/to/picture_of_bread2.jpg',
question: "What's on the bread?",
option1: 'jam',
option2: 'ham'
}
];
-
Obligatory Fileds
key1: string
key2: string
<key-specified in key1, e.g. f>: string
<key specified in key2, e.g. j>: string
expected: string
-
Optional Fields
question: string
picture: string (link)
canvas: object
more about magpie canvas
const key_press_trials = [
{
question: "What's the weather like?",
key1: 'f',
key2: 'j',
f: 'shiny',
j: 'rainbow',
expected: 'shiny'
},
{
question: "What's on the bread?",
picture: 'path/to/picture.jpg',
key1: 'f',
key2: 'j',
f: 'ham',
j: 'jam',
expected: 'jam'
}
];
-
Obligatory Fileds
sentence: string
- the spr parts are separated by ' | '
option1: string
option2: string
-
Optional Fields
QUD: string
- text that is always present on the slidehelp_text: string
- instructions to press SPACE above the spr sentence lines
- default - Press the SPACE bar to reveal the words
picture: string
canvas: object
more about magpie canvasquestion: string
const spr_trials = [
{
QUD: "Johnny says: 'I want you to bring me the box where ...",
picture: "images/all-false3.png"
help_text: 'just press SPACE',
question: "Should you bring Johnny this box or not?",
sentence: "all | of | the | yellow | marbles | are | inside | the | case.'",
option1: "Bring it",
option2: "Leave it",
},
{
question: "Should you bring Johnny this box or not?",
sentence: "some | of the | black marbles | are | inside | the case.'",
option1: "Bring it",
option2: "Leave it"
}
];
-
Obligatory Fileds
sentence: string
- the spr parts are separated by ' | '
optionLeft: string
optionRight: string
-
Optional Fields
QUD: string
- text that is always present on the slidehelp_text: string
- SPACE press text above the spr sentencepicture: string
canvas: object
more about magpie canvasquestion: string
const spr_rc_trials = [
{
QUD: "Johnny says: 'I want you to bring me the box where ...",
picture: "images/all-false3.png"
help_text: 'SPACEEEE',
sentence: "all | of the | yellow marbles | are | inside | the case.'",
question: "Should you bring Johnny this box or not?",
optionLeft: "Bring it",
optionRight: "Leave it",
},
{
question: "Should you bring Johnny this box or not?",
sentence: "some | of the | black marbles | are | inside | the case.'",
optionLeft: "Bring it",
optionRight: "Leave it"
}
];
Sample use of _magpie views:
// your_js_file.js
const intro = magpieViews.intro({
name: 'intro',
title: 'Welcome!',
text: "Let's start!",
buttonText: 'Begin the experiment',
trials: 1
});
const instructions = magpieViews.instructions({
name: 'instuctions',
title: 'Instructions',
text: 'Choose an answer',
buttonText: 'Next',
trials: 1
});
const practice = magpieViews.forcedChoice({
name: 'practice_forced_choice',
trial_type: 'practice',
data: practice_trials,
trials: 2
});
const main = magpieViews.forcedChoice({
name: 'main_forced_choice',
trial_type: 'main',
data: main_trials,
trials: 4
});
const thanks = magpieViews.thanks({
name: 'thanks'
title: 'Thank you for taking part in this experiment!',
trials: 1
});
$("document").ready(function() {
magpieInit({
views_seq: [
intro,
instructions,
main,
thanks
],
deploy: {
'experimentID': '4',
'serverAppURL': 'https://magpie-demo.herokuapp.com/api/submit_experiment/',
'deployMethod': 'debug',
'contact_email": '[email protected]',
'prolificURL": 'https://app.prolific.ac/submissions/complete?cc=ABCD1234'
},
progress_bar: {
in: [
'practice_forced_choice',
'main_forced_choice'
],
style: 'default',
width: 100
}
});
});