Minno Suite
About
Documentation
Blog
Forum
Documentation
Getting started
Server
Using the Dashboard
Getting started (admin account)
Getting started (researcher)
Setting up Dropbox
Study Development
Data
Installation
Requirements
Manual Installation
Docker Installation
The Docker Configuration File
AWS Cloud Installation
AWS Update
AWS Paid SSL
DigitalOcean Installation
A secure connection (https)
Free domain with Freenom
Core concepts
Javascript
Creating a task
Deploying a task
API
Logger
Sequencer
Introduction
Templates
Inheritance
inheritanceAbstraction
inheritanceByData
inheritanceCustom
inheritanceExRandom
inheritanceRandom
inheritanceRepeat
inheritanceSeed
inheritanceSequential
Mixers
mixerBranch
mixerChoose
mixerMultiBranch
mixerRandom
mixerRepeat
mixerWeightedRandom
mixerWrapper
Sequencer
Variables
Current
Global
Local
Time sensitive tasks
Data
API
Settings
Media
Stimulus
Trial
Input
Interactions
Interactions - actions
Interactions - conditions
Stimuli \ Layout
Scorer
Examples
helloPlay
inheritance
input
interactions
sequence
settings
stimulus
stroop-block
stroop-inheritance
stroop-interactions
stroop-setup
stroop-task
touch
trial
Tutorials
Hello world
Slide show
Questionnaires
Introduction
Data
API
Settings
Pages
Questions
dropdown
Grid
Info
multiGrid
Rank
selectOne & selectMulti
Slider
Text & Textarea
textNumber
Examples
Body weight
bodyAwareness
buttons
buttonsAdvanced
buttonsOnePage
dependency
gridExample
liveDependency
nfc
openEnded
openEndedLong
playground
rateImages
rateImagesSizes
scaleWithFeedback
sliderExample
timer
userPrevResp
usingImages
Study Manager
Playground
API
Tasks
Custom tasks
Settings
Project Implicit Build
Task types
Allow Leaving
Inject Style
Is Touch
Messages
Post
Post CSV
Quest
Redirect
Set Value
Time
Yes/No
Examples
Show Video
Weight task
Resources
Edit this page
Create child page
Create documentation issue
Create project issue
Documentation
Time sensitive tasks
Examples
inheritance
inheritance
inheritance.js
Run
Download
// In this tutorial we will learn how to create sets of Trials/Stimuli/Media and use them for randomization. // Sets are essentialy lists of objects that allow us to select objects out of them. // The typical set definition looks something like this: // API.addMediaSet('setName',[ // media1, // media2 // ]); // Using objects from a set is simple. all you have to do is add the `inherit` property to the inheriting object. // There are two syntax types for inheriting. // The simplified version randomly inherits a media object form the set 'mediaSet': // media: {inherit: 'mediaSet'} // The full syntax allows you to pick the inheritance type: // media: { // inherit: { // set: 'mediaSet', // type: 'exRandom' // } // } define(['timeAPI'], function(APIconstructor) { var API = new APIconstructor(); // #### media sets // We define a set of media objects and call it *good*. API.addMediaSets('good', [ {word: 'Paradise'}, {word: 'Pleasure'}, {word: 'Cheer'}, {word: 'Wonderful'}, {word: 'Splendid'}, {word: 'Love'} ]); // We define a set of media objects and call it *bad*. API.addMediaSets('bad', [ {word: 'Bomb'}, {word: 'Abuse'}, {word: 'Sadness'}, {word: 'Pain'}, {word: 'Poison'}, {word: 'Grief'} ]); // #### Stimulus sets // We define two types of stimuli: bad media on the left, good media on the right. // This way, we use inheritance to style each media set in a uniform way. API.addStimulusSets("Default", [ // randomly inherit a media object from the 'bad' media set { data: {type:'bad'}, location: {left:30}, media: {inherit:'bad'} }, // randomly inherit a media object from the 'good' media set { data: {type:'good'}, location: {right:30}, media: {inherit:'good'} } ]); // #### Trial sets // We define only one trial, this is inherantly gives us a shortcut to this trial, and will eventuall allow us to use it as a prototype. </br> // This trial simply displays a random stimulus. API.addTrialSets("Default", [ { input: [{handle: 'end', on:'space'}], layout: [{inherit:'Default'}], interactions: [ { conditions: [{type:'inputEquals',value:'end'}], actions: [{type:'endTrial'}] } ] } ]); // #### sequence API.addSequence([ // ##### Simple inheritance // We can simply inherit the Default trial and have it display random stimuli. {inherit:'Default'}, {inherit:'Default'}, {inherit:'Default'}, // ##### Exclusive Randomization // `exRandom`: pick a random object with exclusion. // Repeated calls to `exRandom` will not return the same object until all objects in the set have been used. </br> // Specificaly this Trial presents a random 'bad' media object (note that in this case we inherit a media object, not a stimulus). { input: [{handle: 'end', on:'space'}], layout: [ /* begin stimulus */ { /* begin media */ media: { inherit:{ set:'bad', type:'exRandom' } } /* end media */ } /* end stimulus */ ], interactions: [ { conditions: [{type:'inputEquals',value:'end'}], actions: [{type:'endTrial'}] } ] }, // ##### Inherit by Data // `byData` checks if the inherit objtects' `data` property is a subset of the elements' `data` property and if it is it picks the element. // (this means that if all properties of `data` equal to the properties of the same name in `element.data` it is a fit). </br> // Specificaly, this trial picks the stimulus that has `data:{type:'good'}` (note that in this case we inherit a whole stimulus object). { input: [{handle: 'end', on:'space'}], layout: [ /* begin stimulus */ { inherit:{ set:'Default', type:'byData', data: {type:'good'} } } /* end stimulus */ ], interactions: [ { conditions: [{type:'inputEquals',value:'end'}], actions: [{type:'endTrial'}] } ] }, // ##### Prototyping // One of the greatest powers of inheritance is prototyping; using a the inheritance as a template for more advanced elements. // When an element (the child) has an inherit property, then the child is used to extend the inherited element (the parent). // What this means is that inherited properties are overwritten by explicit properties. Let's see how this works. { // Inherit the 'Default' trial. inherit: 'Default', // The layout property gets overridden layout: [{media:{word:'One Child'}}] }, { // Inherit the 'Default' trial. inherit: 'Default', // The layout property gets overriden in a different way. layout: [{media:{word:'A differen child'}}] } ]); return API.script; });
Last modified March 11, 2021:
setup hugo (11980dc)