Hi Yoav,
Unfortunately, it didn't seem possible to divert people to an external platform to complete a study (people don't know their ID number and vendors don't like it as ppl drop out). So we persevered with trying to integrate the code.
We've just managed to do it (though can't find a way to hide the text box above the IAT, ideas welcome!) so I thought I'd share the code as this downloads successfully.
This is for the weight IAT:
best wishes
Steph
Qualtrics.SurveyEngine.addOnload(function () {
// Hide question and next button
var container = this.getQuestionContainer();
// Load MinnoJS from the CDN (update if necessary)
var scriptTag = document.createElement('script');
scriptTag.src = '
https://cdn.jsdelivr.net/gh/minnojs/minno-quest@0.3/dist/pi-minno.js';
scriptTag.onload = onLoad;
container.appendChild(scriptTag);
// Create the root element for MinnoJS
var canvas = document.createElement('div');
container.appendChild(canvas);
// Function to proceed to next question
var proceed = this.clickNextButton.bind(this);
// Function to handle the data logging from MinnoJS
function handleMinnoJSLogging(value) {
console.log('Logger called:', value);
var el = container.querySelector('textarea');
if (el) {
el.value = value;
} else {
console.error('Could not find textarea element to set value.');
}
}
// This function gets activated only after MinnoJS is loaded
function onLoad() {
console.log('MinnoJS loaded');
// Start your MinnoJS task (set the correct URL)
minnoJS(canvas, '
https://cdn.jsdelivr.net/gh/baranan/minno-tasks@0.*/IAT/qualtrics/weightIATexample.js');
// Set up the logger function for MinnoJS
minnoJS.logger = handleMinnoJSLogging;
// At the end of the study, let MinnoJS proceed to the next question
minnoJS.onEnd = function () {
console.log('MinnoJS task finished');
// Need to wait a few milliseconds for Qualtrics to register the value
setTimeout(proceed, 1000);
}
}
});