fixed survey

This commit is contained in:
2026-02-28 00:03:43 +01:00
parent d29e0e392b
commit e5cea96416

142
index.js
View File

@@ -27,13 +27,13 @@ function delayed_redirect(url) {
}
const jsPsych = initJsPsych({
on_finish: function() {
on_finish: function () {
jsPsych.getDisplayElement().innerHTML = textStimuli.complete;
},
on_close: function() {
on_close: function () {
delayed_redirect(import.meta.env.VITE_CLOSED_URL);
},
on_data_update: function() {
on_data_update: function () {
if (debug) {
console.log(jsPsych.data.get().json());
}
@@ -149,7 +149,7 @@ const consent_form = {
type: jsPsychHtmlButtonResponse,
stimulus: stimulusMap.get('consent'),
choices: ['Exit', 'Continue'],
on_finish: function(data) {
on_finish: function (data) {
if (data.response === 0) {
jsPsych.abortExperiment(stimulusMap.get('no_consent'));
}
@@ -242,22 +242,10 @@ const captcha_trials = Array.from({ length: CAPTCHA_TRIAL_COUNT }, (_, index) =>
create_captcha_trial(index)
);
const die_probe_row = {
text:
'I suspected that the die roll was not random, or the number I received was pre-determined.',
value: 'SuspicionDie',
};
const difficulty_probe_row = {
text:
'I suspected that, contrary to what I was told, the captcha task difficulty was not determined by the die roll.',
value: 'SuspicionDifficulty',
};
const survey_function = survey => {
survey.onAfterRenderPage.add(function(sender, options) {
survey.onAfterRenderPage.add(function (sender, options) {
console.log('Survey page rendered:', sender.currentPage);
if (survey.activePage.name === 'page2') {
if (survey.activePage.name === 'page2' || survey.activePage.name === 'page1') {
const nextButton = document.querySelector('#sv-nav-next > div > input');
if (nextButton) {
let seconds = 20;
@@ -334,7 +322,7 @@ const survey_1 = {
},
],
},
{
{
name: 'page2',
elements: [
{
@@ -408,6 +396,54 @@ const pre_manip_info = {
},
};
const die_probe_rows = [{
text:
'I suspected that the die roll that determined captcha difficulty was rigged',
value: 'SuspicionDie1',
}, {
text:
'I suspected that the number I rolled on the die roll was predetermined',
value: 'SuspicionDie2',
}];
const difficulty_probe_rows = [{
text:
'I suspected that the captcha difficulty was unrelated to the die roll',
value: 'SuspicionDifficulty1',
}, {
text:
'I suspected that the number I rolled did not determine the captcha difficulty',
value: 'SuspicionDifficulty2',
}];
//shuffle the probe rows:
die_probe_rows.sort(() => Math.random() - 0.5);
difficulty_probe_rows.sort(() => Math.random() - 0.5);
let page_1_probe
let page_2_probe
const catch_row = {
text: 'Attention check: please select "Disagree for this statement.',
value: 'AttentionCheck',
};
if (Math.random() < 0.5) {
die_probe_rows.splice(1, 0, catch_row);
} else {
difficulty_probe_rows.splice(1, 0, catch_row);
}
if (probe_order === 'die_first') {
page_1_probe = die_probe_rows
page_2_probe = difficulty_probe_rows
} else {
page_1_probe = difficulty_probe_rows
page_2_probe = die_probe_rows
}
const survey_2 = {
type: jsPsychSurvey,
survey_function: survey_function,
@@ -427,18 +463,7 @@ const survey_2 = {
alternateRows: true,
isAllRowRequired: debug ? false : true,
rowOrder: 'random',
rows: [
probe_order === 'die_first'
? die_probe_row
: difficulty_probe_row,
{
text: `There's no question here. Select 'Disagree' to show that you're paying attention.`,
value: 'AttentionCheck',
},
probe_order === 'die_first'
? difficulty_probe_row
: die_probe_row,
],
rows: page_1_probe,
columns: [
{
value: 5,
@@ -464,23 +489,58 @@ const survey_2 = {
},
],
},
{
{
name: 'page2',
elements: [
{
type: 'comment',
title: `Please write a sentence or two on what you thought the study was about.`,
isRequired: debug == true ? false : true,
type: 'matrix',
name: "Please indicate your agreement with the following statements.",
alternateRows: true,
isAllRowRequired: debug ? false : true,
rowOrder: 'random',
rows: page_2_probe,
columns: [
{
value: 5,
text: 'Strongly agree',
},
{
value: 4,
text: 'Agree',
},
{
value: 3,
text: 'Neutral',
},
{
value: 2,
text: 'Disagree',
},
{
value: 1,
text: 'Strongly disagree',
},
],
},
{
type: 'comment',
title: ` Indicate any other thoughts or suspicions you had about the study. \n`,
isRequired: debug == true ? false : true,
}
],
},
{
name: 'page3',
elements: [
{
type: 'comment',
title: `Please write a sentence or two on what you thought the study was about.`,
isRequired: debug == true ? false : true,
},
{
type: 'comment',
title: ` Indicate any other thoughts or suspicions you had about the study. \n`,
isRequired: debug == true ? false : true,
}
],
},
{
name: 'page4',
elements: [
{
type: 'radiogroup',
@@ -531,7 +591,7 @@ const main_experiment_timeline = [
if (debug) {
timeline.push(die_roll_trial);
timeline.push(survey_2);
timeline.push(...main_experiment_timeline);
}