Issue with special characters #1458
-
Hi there, Here the code snippet, I use:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You could store your images as an array of objects, where each object contains the image name with and without the special characters. Then you could shuffle this array, and access the two different properties of this object when you need the filename vs names that are shown on the screen. E.g. var images = [
{path: 'stims/wirbelsaule.jpg', name: 'Wirbelsäule'},
{path: 'stims/another_stim.jpg', name: 'Another stim'},
// etc.
];
var images2 = jsPsych.randomization.shuffle(images); // stimulus objects are now in random order
//...
stimulus: function(){
var first_stim = images2.pop(); // this is now an object with keys called 'path' and 'name'
var first_stim_filepath = first_stim.path;
var first_stim_name = first_stim.name;
var html = `<table id=t01><tr><td><img src="${first_stim_filepath}"></td> <td></td></tr><tr><td><h1><center><option>${first_stim_name}</option></center></h1></td></tr></table>`;
return html;
},
//... Does that work? Also, did you see Discussion post #1450 ? I wonder if it's helpful/relevant? |
Beta Was this translation helpful? Give feedback.
You could store your images as an array of objects, where each object contains the image name with and without the special characters. Then you could shuffle this array, and access the two different properties of this object when you need the filename vs names that are shown on the screen. E.g.