fixed survey
This commit is contained in:
124
index.js
124
index.js
@@ -27,13 +27,13 @@ function delayed_redirect(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const jsPsych = initJsPsych({
|
const jsPsych = initJsPsych({
|
||||||
on_finish: function() {
|
on_finish: function () {
|
||||||
jsPsych.getDisplayElement().innerHTML = textStimuli.complete;
|
jsPsych.getDisplayElement().innerHTML = textStimuli.complete;
|
||||||
},
|
},
|
||||||
on_close: function() {
|
on_close: function () {
|
||||||
delayed_redirect(import.meta.env.VITE_CLOSED_URL);
|
delayed_redirect(import.meta.env.VITE_CLOSED_URL);
|
||||||
},
|
},
|
||||||
on_data_update: function() {
|
on_data_update: function () {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
console.log(jsPsych.data.get().json());
|
console.log(jsPsych.data.get().json());
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ const consent_form = {
|
|||||||
type: jsPsychHtmlButtonResponse,
|
type: jsPsychHtmlButtonResponse,
|
||||||
stimulus: stimulusMap.get('consent'),
|
stimulus: stimulusMap.get('consent'),
|
||||||
choices: ['Exit', 'Continue'],
|
choices: ['Exit', 'Continue'],
|
||||||
on_finish: function(data) {
|
on_finish: function (data) {
|
||||||
if (data.response === 0) {
|
if (data.response === 0) {
|
||||||
jsPsych.abortExperiment(stimulusMap.get('no_consent'));
|
jsPsych.abortExperiment(stimulusMap.get('no_consent'));
|
||||||
}
|
}
|
||||||
@@ -242,22 +242,10 @@ const captcha_trials = Array.from({ length: CAPTCHA_TRIAL_COUNT }, (_, index) =>
|
|||||||
create_captcha_trial(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 => {
|
const survey_function = survey => {
|
||||||
survey.onAfterRenderPage.add(function(sender, options) {
|
survey.onAfterRenderPage.add(function (sender, options) {
|
||||||
console.log('Survey page rendered:', sender.currentPage);
|
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');
|
const nextButton = document.querySelector('#sv-nav-next > div > input');
|
||||||
if (nextButton) {
|
if (nextButton) {
|
||||||
let seconds = 20;
|
let seconds = 20;
|
||||||
@@ -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 = {
|
const survey_2 = {
|
||||||
type: jsPsychSurvey,
|
type: jsPsychSurvey,
|
||||||
survey_function: survey_function,
|
survey_function: survey_function,
|
||||||
@@ -427,18 +463,7 @@ const survey_2 = {
|
|||||||
alternateRows: true,
|
alternateRows: true,
|
||||||
isAllRowRequired: debug ? false : true,
|
isAllRowRequired: debug ? false : true,
|
||||||
rowOrder: 'random',
|
rowOrder: 'random',
|
||||||
rows: [
|
rows: page_1_probe,
|
||||||
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,
|
|
||||||
],
|
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
value: 5,
|
value: 5,
|
||||||
@@ -466,6 +491,41 @@ const survey_2 = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'page2',
|
name: 'page2',
|
||||||
|
elements: [
|
||||||
|
{
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'page3',
|
||||||
elements: [
|
elements: [
|
||||||
{
|
{
|
||||||
type: 'comment',
|
type: 'comment',
|
||||||
@@ -480,7 +540,7 @@ const survey_2 = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'page3',
|
name: 'page4',
|
||||||
elements: [
|
elements: [
|
||||||
{
|
{
|
||||||
type: 'radiogroup',
|
type: 'radiogroup',
|
||||||
@@ -531,7 +591,7 @@ const main_experiment_timeline = [
|
|||||||
|
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
timeline.push(die_roll_trial);
|
timeline.push(survey_2);
|
||||||
timeline.push(...main_experiment_timeline);
|
timeline.push(...main_experiment_timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user