I'm new to jsPsych and JS in general. Currently we are building a relatively straightforward experiment in which the participant is presented with a serie of word-pairs out of which they have to choose one. The words are retrieved from a server and have a number of attributes. The script is made in such a way that we can easily adjust the experiment and module types we want to retrieve.
The instructions are displayed without any problems. However, when i want to present the words on screen i keep bumping into the same error messages:
Trial level node is missing the "type" parameter. The parameters of the node are: {//OBJECT PROPERTIES//}
followed by
Uncaught TypeError: cannot read property 'trial' of undefined
Any help on how to continue from here is much appreciated, the relevant chunk of code is this:
// Call function to collect experiment module
getData({"experiment":"1","module": "1"}, function(){
// retrieve questions from sample
var questions = this.questions;
var trials_exp1 = [];
// loop through these questions and create stimuli array
for (var i = 0; i < questions.length; i++) {
trials_exp1.push({
type: 'single-stim',
stimuli: [questions[i].question1 + " " + questions[i].question2],
choices: ['a','s'],
is_html: true
});
}
console.log("Questions for Experiment 1 finished loading");
// Push retrieved experiment to timeline
timeline.push(trials_exp1);
}).done (function(){
// all experiments are loaded, start the experiments
console.log("Finished loading: Start experiment");
startExperiment();
})
Thank you in advance!
- Laurent
--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/71cabbf5-21ef-4486-8550-776aceee7204%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I had to drop the project for a while so my apologies for the late reply. Thank you for the response, concatenating did help. Unfortunately, the following error occurs when i try to test the experiment:
Uncaught ReferenceError: timeline is not defined
startExperiment @ IAT.html:110
(anonymous function) @ IAT.html:89
j @ jquery.min.js:2
fireWith @ jquery.min.js:2
x @ jquery.min.js:4
b @ jquery.min.js:4
While the problem seems to be obvious, i have trouble coming up with a solution. I'm using some helper functions throughout the script and it looks like the created timeline is not properly passed on to the jsPsych.init function. Also, when i log the timeline throughout the experiment it appears as an object, whereas in other experiments (for example the reaction time experiment from the tutorial) the timeline is logged as an array.
Do you have any idea what the problem might be? The stimuli are loaded in the code below
// Call function to collect experiment module
getData({"experiment":"1","module": "1"}, function(){
// retrieve questions from sample
var questions = this.questions;
var trials_exp1 = [];
// loop through these questions and create stimuli array
for (var i = 0; i < questions.length; i++) {
trials_exp1.push({
type: 'single-stim',
stimuli: ['<p style="text-align:center; font-size:32px;">'+questions[i].question1 + " "
+ questions[i].question2+'</p>'],
choices: ['a','s'],
is_html: true
});
};
console.log("Questions for Experiment 1 finished loading");
timeline = timeline.concat(trials_exp1);
}).done (function(){
// all experiments are loaded, start the experiments
console.log("Finished loading: Start experiment");
startExperiment();
})
And the experiment is started in this chunk:
// Start the experiment
function startExperiment(){
jsPsych.init({
timeline: timeline,
on_trial_start: function() {
console.log("Trial started");
},
on_finish: function() {
console.log("Experiment finished");
jsPsych.data.displayData('csv');
--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/1adcb959-9319-4703-a28f-fe73ac65a8d1%40googlegroups.com.
Thank you, it was indeed an issue with the scope. Unfortunately, i'm already running into the next noobish issue: I want to present wordpairs that are gathered from a server when the experiment starts and they are concatenated into an array. When i try to present the words using the single-stim plugin the script apparently searches for the stimuli in my root folder:
ET file:///C:/Users/jsPsych%20script/[STIMULUS] net::ERR_FILE_NOT_FOUND
However, when i use the categorize plugin, the words are presented correctly and the paradigm runs fine. Am i missing something with the single-stim plugin? It's fine to use the categorize plugin but i feel that it is somewhat slower while my paradigm depends on a very fast and rhythmic presentation and responses. For example, is there a build-in parameter that turns off the feedback logging and presentation?
Finally, i also want to randomize the location of the word-pairs (e.g.: word 1 presented right and word 2 left and vice versa). I've thought of creating a copy of the stimulus array and switch the location in the second array. Then present a word-pair from a random stimulus array. But how do i avoid having the same pair presented twice? The second option i thought of was creating two presentation fields, one for each word, and randomize the location of those fields everytime a word-pair is presented. Does anyone have suggestions or knows an much easier way to work around it?
Again, thank you for your time!
Best,
Laurent
--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/c17788cc-4fdf-4332-8a8e-c834a3364e59%40googlegroups.com.