magpie-modules
Advanced tools
Comparing version 0.1.2 to 0.2.0
# Changelog | ||
## Latest version: 0.1.2 | ||
## Latest version: 0.2.0 | ||
- Say hello to our new name \_magpie | ||
- version 0.2.0 | ||
- new module: Mouse tracking | ||
- new view template: listen and decide | ||
- version 0.1.1 | ||
- This project is now called `magpie-modules` on npm | ||
@@ -10,4 +14,2 @@ - Lodash is now included in magpie.full.js | ||
## Older versions (babe-project) | ||
- version 0.1.1 + 0.1.2 | ||
@@ -14,0 +16,0 @@ - Image display: |
{ | ||
"name": "magpie-modules", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "minimal architecture for the generation of portable interactive experiments (https://github.com/magpie-ea/magpie-modules)", | ||
@@ -5,0 +5,0 @@ "main": "magpie.js", |
# \_magpie project | ||
minimal architecture for the generation of portable interactive experiments | ||
**Latest version: 0.1.2** | ||
**Latest version: 0.1.1** | ||
@@ -6,0 +6,0 @@ - Say hello to our new name \_magpie |
@@ -56,3 +56,14 @@ // The view template dict contains a generator function for every view type we support | ||
</div>`; | ||
} | ||
}, | ||
listen_and_decide: function(config, CT) { | ||
return `<div class='magpie-view'> | ||
<h1 class='magpie-view-title'>${config.title}</h1> | ||
<div class='magpie-view-stimulus-container'> | ||
<div class='magpie-view-stimulus'> | ||
<p>Listen</p> | ||
<audio src="${config.audioPath}${config.data[CT].question_file}" class="magpie-lad-question magpie-nodisplay" /></div> | ||
</div> | ||
<audio src="${config.audioPath}${config.data[CT].answer_file}" class="magpie-lad-answer magpie-nodisplay" /> | ||
</div>`; | ||
}, | ||
}; | ||
@@ -198,3 +209,32 @@ | ||
</div>`; | ||
} | ||
}, | ||
image_selection_mousetracking: function(config, CT) { | ||
const path = config.imagePath | ||
let left,right | ||
// randomize location allocation | ||
if (Math.random() > 0.5) { | ||
left = config.data[CT].picture_target | ||
config.data[CT].target_location = 'left' | ||
right = config.data[CT].picture_competitor | ||
config.data[CT].competitor_location = 'right' | ||
}else{ | ||
left = config.data[CT].picture_competitor | ||
config.data[CT].competitor_location = 'left' | ||
right = config.data[CT].picture_target | ||
config.data[CT].target_location = 'right' | ||
} | ||
return `<div class='magpie-view-answer-container'> | ||
<img src='${path}${left}' class='magpie-view-picture magpie-response-picture magpie-response-picture-left' id="img1"> | ||
<img src='${path}${right}' class='magpie-view-picture magpie-response-picture magpie-response-picture-right' id="img2"> | ||
<p class="clearfix"></p> | ||
<p> </p> | ||
<p> </p> | ||
<p> </p> | ||
<p> </p> | ||
<p> </p> | ||
<p> </p> | ||
<button class="magpie-lad-start">Start</button> | ||
</div>`; | ||
}, | ||
}; | ||
@@ -597,2 +637,48 @@ | ||
}, | ||
listen_and_decide: function(config, CT, magpie, answer_container_generator, startingTime) { | ||
const $view = $(".magpie-view") | ||
const $question = $('.magpie-lad-question') | ||
setTimeout(function() { | ||
$question[0].play() | ||
}, config.initialDelay) | ||
$question.on('ended', function() { | ||
$view.append(answer_container_generator(config, CT)); | ||
$('.magpie-view-stimulus-container').addClass('magpie-nodisplay') | ||
const $answer = $('.magpie-lad-answer') | ||
const $start = $('.magpie-lad-start') | ||
$start.click(function(evt) { | ||
config.data[CT].mousetracking.start({x: evt.originalEvent.clientX, y: evt.originalEvent.clientY}) | ||
$('#img1').on(config.decisionEvent, function() { | ||
submit('left') | ||
}) | ||
$('#img2').on(config.decisionEvent, function() { | ||
submit('right') | ||
}) | ||
$answer[0].play() | ||
}) | ||
}) | ||
function submit(position) { | ||
let response = (position === config.data[CT].target_location)? 'target' : 'competitor' | ||
// For filler trials we compare with the expected response | ||
if (config.data[CT].condition === 'filler' && config.data[CT].expected_response) { | ||
const img = position === config.data[CT].target_location? config.data[CT].picture_target : config.data[CT].picture_competitor | ||
response = (img === config.data[CT].expected_response)? 'target' : 'competitor' | ||
} | ||
const RT = Date.now() - startingTime; // measure RT before anything else | ||
let trial_data = { | ||
trial_name: config.name, | ||
trial_number: CT + 1, | ||
response, | ||
RT: RT | ||
}; | ||
trial_data = magpieUtils.view.save_config_trial_data(config.data[CT], trial_data); | ||
magpie.trial_data.push(trial_data); | ||
magpie.findNextView(); | ||
} | ||
} | ||
@@ -721,3 +807,11 @@ }; | ||
default_handle_response: handle_response_functions.self_paced_reading | ||
}, | ||
listen_and_decide_mousetracking: { | ||
type: "trial", | ||
default_title: "", | ||
default_button_text: "", | ||
default_view_temp: stimulus_container_generators.listen_and_decide, | ||
default_answer_temp: answer_container_generators.image_selection_mousetracking, | ||
default_handle_response: handle_response_functions.listen_and_decide | ||
} | ||
}; | ||
}; |
@@ -74,2 +74,6 @@ const magpieUtils = { | ||
save_config_trial_data: function(config_info, trial_data) { | ||
if (config_info.mousetracking !== undefined) { | ||
config_info.mousetracking.cleanup() | ||
} | ||
for (let prop in config_info) { | ||
@@ -98,2 +102,6 @@ if (config_info.hasOwnProperty(prop)) { | ||
if (config_info.mousetracking !== undefined) { | ||
delete trial_data.mousetracking; | ||
} | ||
return trial_data; | ||
@@ -189,2 +197,4 @@ }, | ||
magpieMousetracking(config.mousetracking, data) | ||
resolve(); | ||
@@ -191,0 +201,0 @@ }; |
@@ -62,3 +62,4 @@ const magpieViews = { | ||
evts: config.hook, | ||
view: view_type | ||
view: view_type, | ||
mousetracking: config.mousetracking | ||
}, | ||
@@ -65,0 +66,0 @@ // After the first three steps of the trial view lifecycle (can all be empty) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
535607
23
8272
2