Reply To: Multiple independent lm lists for switching task

Home Forums Support Multiple independent lm lists for switching task Reply To: Multiple independent lm lists for switching task

#946
Erwin Haasnoot
Keymaster

Hi Nina,

Sorry about the delayed response.
I’m afraid this will be fairly difficult to do. Qualtrics doesn’t allow the nesting of blocks, thus you can’t really nest L&M lists properly. There are several ways in which you can approach this behaviour, however, but take care that these are by no means perfect solutions and necessarily make use of quite a bit of JavaScript.

The solution will randomly decide whether lower-than-5 or odd/even is asked, and then should use conditional logic to display the necessary stimuli.

The crux is in how to generate these random decisions. What I think is the best is to generate an array with 36 ‘lower-than-5’ values, and 36 ‘odd/even’ and then shuffle them.

//Get the shuffled array
shuffledArray = QRTE.getBlockData(‘shuffledArray’);

//Check if it exists (does not at the start)
if(typeof shuffledArray === ‘undefined’) {

//Use knuth’s algorithm to shuffle the array, taken from:
//http://jsperf.com/array-shuffle-comparator/5
function knuthfisheryates(arr) {
var i, temp, j, len = arr.length;
for (i = 0; i < len; i++) { j = ~~(Math.random() * (i + 1)); temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } return arr; } //Fill the array that needs to be shuffled! shuffledArray = []; for(var i = 0; i < 36; i += 1) { shuffledArray.push('lower-than-5'); shuffledArray.push('odd/even'); } shuffledArray = knuthfisheryates(shuffledArray); QRTE.setBlockData("shuffledArray",shuffledArray); } //Set trial data to type QRTE.setTrialData('currentTrialType',shuffledArray[parseInt("${lm://CurrentLoopNumber}") - 1]); //CurrentLoopNumber defines the current loop And then use QRTE.getTrialData('currentTrialType') for the conditional logic in the Stimuli that need to be displayed upon either type of tasks. I hope this short summary on how to solve the problem helps, do not hesitate to contact us if you require more assistance. Best regards, Erwin Haasnoot