taboulet
-
Modifié le 1 avril 2024 à 13:23
Elie330
Messages postés1Date d'inscriptionmercredi 3 avril 2024StatutMembreDernière intervention 3 avril 2024
-
3 avril 2024 à 15:23
Bonjour,
Je programme une expérience afin de répliquer et approfondir un papier scientifique pour mon mémoire de première année de master.
J'ai commencé à programmer depuis 3 semaines et terminé la programmation de mon expérience depuis la semaine dernière. Tout fonctionne parfaitement, mais j'ai pour projet de proposer aux participants le choix entre l'expérience en français et anglais. Je bug depuis. Je ne vais pas vous envoyer les 2 000 lignes (sauf si vous le souhaitez ahaha) mais un très léger résumé pour que vous compreniez la logique globale. SVP pouvez-vous m'expliquer pourquoi ça ne fonctionne pas?
Plus précisément, la page de choix de la langue apparaît, mais rien ne suit après avoir cliqué. Merci par avance !!!!!!!
NB: pour info, j'utilise la librairie jspsych et Jatos en hébergeur
var timeline = [];
var timeline_en = []
var timeline_fr = []
var Default_Question_Block_en = {
type: "instructions",
pages: [
'<p style="text-align: center;font-size: 22px;"><b>Consent form</b></p>'+
'<div style="text-align: left;">'+
'<br>Welcome! blablabla<br><br>'+
'<b>Please click on "Continue" if you are 15 years of age or older and if you consent to participate:</b><br><br>',
],
button_label_next: "Continue",
button_label_previous: "Return to the previous page",
show_clickable_nav: true
}
timeline_true_certain_en.push(Default_Question_Block_en)
var timeline_true_certain_en = [];
var trials_2exp_en = {
name: trials_2exp_en,
};
timeline_true_certain_en.push(trials_2exp_en);
//2ND CONDITION => TRUE UNCERTAIN
var timeline_true_uncertain_en = [];
timeline_true_uncertain_en.push(Default_Question_Block_en)
// Function to randomly assign conditions to participants
function assignCondition_3_en() {
var randomCondition_3 = Math.random(); // Generate a random number between 0 and 1
if (randomCondition_3 < 1/2) {
timeline_en.push(...timeline_true_certain_en);
} else {
timeline_en.push(...timeline_true_uncertain_en);
}
}
assignCondition_3_en()
jatos.onLoad(function () {
jsPsych.init({
timeline: timeline_en,
show_progress_bar: false,
on_finish: function () {
var resultJson = jsPsych.data.get().json();
jatos.endStudy(resultJson, 'success!', true) /
}
});
});
// French version
var timeline_true_certain_fr = [];
var Default_Question_Block_fr = {
type: "instructions",
pages: [
'<p style="text-align: center;font-size: 22px;"><b>Consent form</b></p>'+
'<div style="text-align: left;">'+
"<br>Bonjour! BLA BLA BLA<br><br>'+
'<b>Veuillez cliquer sur "Continuer" si vous avez 15 ans ou plus et si vous consentez à participer :</b><br><br>',
],
button_label_next: "Continuer",
button_label_previous: "Retour à la page précédente",
show_clickable_nav: true
}
timeline_true_certain_fr.push(Default_Question_Block_fr);
var trials_2exp_fr = {
name: trials_2exp_fr,
};
timeline_true_certain_fr.push(trials_2exp_fr);
//2ND CONDITION => TRUE UNCERTAIN
var timeline_true_uncertain_fr = [];
timeline_true_uncertain_fr.push(Default_Question_Block_fr);
timeline_true_uncertain_fr.push(trials_2exp_fr);
function assignCondition_3_en() {
var randomCondition_3 = Math.random(); // Generate a random number between 0 and 1
if (randomCondition_3 < 1/2) {
timeline_fr.push(...timeline_true_certain_fr);
} else {
timeline_fr.push(...timeline_true_uncertain_fr);
}
}
// Initialize jsPsych
jatos.onLoad(function () {
jsPsych.init({
timeline: timeline_fr,
show_progress_bar: false,
on_finish: function () {
//jsPsych.data.displayData(); //shows data output (in json format) on the screen after timeline ends
var resultJson = jsPsych.data.get().json();
jatos.endStudy(resultJson, 'success!', true) //sends data output to the JATOS server, adds a message to the result object, and shows an End Page to the user (https://www.jatos.org/jatos.js-Reference.html#jatosendstudy)
}
});
});
var languageSelect = document.getElementById('language-select');
languageSelect.addEventListener('change', function() {
var selectedLanguage = languageSelect.value;
if (selectedLanguage === 'fr') {
timeline = timeline_fr;
} else if (selectedLanguage === 'en') {
timeline = timeline_en;
}
jsPsych.init({
timeline: timeline
});
})