Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/interactive/TMB_LN_SWITCHING/TestMyBrain.12.18.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function showFrame() {
for (
tmbObjs.frames.length || (tmbObjs.frames = document.getElementsByTagName('div')), t = tmbObjs.frames.length;
t--;

)
((e = n.indexOf(tmbObjs.frames[t].id) > -1 ? 'block' : 'none'),
tmbObjs.frames[t].style.display !== e && (tmbObjs.frames[t].style.display = e));
Expand All @@ -70,7 +69,6 @@ function showFrameClass() {
for (
tmbObjs.frames.length || (tmbObjs.frames = document.getElementsByTagName('div')), t = tmbObjs.frames.length;
t--;

)
((e = n.indexOf(tmbObjs.frames[t].className) > -1 ? 'block' : 'none'),
tmbObjs.frames[t].style.display !== e && (tmbObjs.frames[t].style.display = e));
Expand Down Expand Up @@ -517,7 +515,6 @@ function imagePreLoad(e, t) {
(t.addEventListener('load', c, !0), t.addEventListener('error', c, !0), (t.id = e), (t.src = e));
};
l > 0;

)
(l--, d(n.shift()));
}
Expand Down Expand Up @@ -3362,7 +3359,6 @@ var saveTextAs =
s = void 0 === a ? n : a >> 0,
u = 0 > s ? Math.max(n + s, 0) : Math.min(s, n);
u > i;

)
((t[i] = e), i++);
return t;
Expand Down Expand Up @@ -3472,7 +3468,6 @@ var zen = tmbObjs,
r = n.length,
o = (window.console = window.console || {});
r--;

)
((e = n[r]), o[e] || (o[e] = t));
})(),
Expand Down
27 changes: 20 additions & 7 deletions lib/interactive/TMB_LN_SWITCHING/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@

export default defineInstrument({
kind: 'INTERACTIVE',
language: 'en',
tags: ['TestMyBrain'],
language: ['en', 'fr'],
tags: {
en: ['TestMyBrain'],
fr: ['TestMyBrain']
},
internal: {
edition: 1,
name: 'TMB_LN_SWITCHING'
Expand All @@ -53,17 +56,27 @@
},
html,
render,
staticAssets
staticAssets,
enableLanguageLock: true,

Check failure on line 60 in lib/interactive/TMB_LN_SWITCHING/index.ts

View workflow job for this annotation

GitHub Actions / lint

Object literal may only specify known properties, and 'enableLanguageLock' does not exist in type '{ readonly __injectHead?: { readonly scripts?: readonly string[] | undefined; readonly style?: string | undefined; } | undefined; defaultFullscreen?: boolean | undefined; html?: string | undefined; meta?: { [name: string]: string; } | undefined; render: (done: (data: { accuracy?: number | undefined; meanRTc?: number | undefined; medianRTc?: number | undefined; sdRTc?: number | undefined; responseDevice?: string | undefined; testVersion?: string | undefined; conflictAccuracy?: number | undefined; conflictMeanRTc?: number | undefined; conflictMedianRTc?: number | undefined; conflictSDRTc?: number | undefined; noConflictAccuracy?: number | undefined; noConflictMeanRTc?: number | undefined; noConflictMedianRTc?: number | undefined; noConflictSDRTc?: number | undefined; conflictAccuracyCost?: number | undefined; conflictRtCost?: number | undefined; score?: number | undefined; type?: string | undefined; }) => void) => Promisable<void>; staticAssets?: { [key: string]: string; } | undefined; }'.
enableLanguageSelect: true
},
clientDetails: {
estimatedDuration: 1,
instructions: ['Instructions will be presented on screen in the task.']
instructions: {
en: ['Instructions will be presented on screen in the task.'],
fr: ["Les instructions seront présentées à l'écran pendant la tâche."]
}
},
details: {
description:
'A task switching test that evaluates cognitive flexibility by alternating between letter and number categorization.',
description: {
en: 'A task switching test that evaluates cognitive flexibility by alternating between letter and number categorization.',
fr: 'Un test d’alternance de tâches qui évalue la flexibilité cognitive en alternant entre la catégorisation de lettres et de chiffres.'
},
license: 'LGPL-3.0',
title: 'Letter/Number Switching'
title: {
en: 'Letter/Number Switching',
fr: 'Alternance lettres/chiffres'
}
},
measures: {},
validationSchema: z
Expand Down
86 changes: 47 additions & 39 deletions lib/interactive/TMB_LN_SWITCHING/render.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
// @ts-nocheck
/* eslint-disable */

import { translator } from './translator.ts';

export function render(onComplete) {
translator.init();

function tFormat(key, vars) {
var s = translator.t(key);
if (vars) {
for (var k in vars) s = s.replace(new RegExp('\\{' + k + '\\}', 'g'), vars[k]);
}
return s;
}

var testVersion; // version identifier for this test
var images = []; // images to load
var chain; // chain of timeouts for stimulus presentation
Expand Down Expand Up @@ -60,17 +72,18 @@ export function render(onComplete) {
// and repeating the trial
if (~frame.type.indexOf('practice') && !correct) {
errorMessage =
'Your target was the <b>' +
frame.judgement +
' ' +
frame.target +
'</b>:<br>' +
tFormat('practiceError.target', {
judgement: translator.t('judgement.' + frame.judgement),
target: frame.target
}) +
'<br>' +
(frame.response === 'R'
? 'you should have clicked<br>' + 'the <b>right</b> button.<br><br>'
: 'you should have clicked<br>' + 'the <b>left</b> button.<br><br>');
? translator.t('practiceError.shouldRight')
: translator.t('practiceError.shouldLeft')) +
'<br><br>';
showAlert(
errorMessage,
'Click here to retry',
translator.t('buttons.clickRetry'),
function () {
frameSequence.unshift(frame);
showFrame('null');
Expand All @@ -89,8 +102,8 @@ export function render(onComplete) {
frameSequence.unshift(frame);

showAlert(
'Please respond as quickly as you can.<br><br>' + 'Click the left or right button.<br><br>',
'Click here to retry',
translator.t('timeout.message') + '<br><br>',
translator.t('buttons.clickRetry'),
function () {
showFrame('null');
setTimeout(function () {
Expand All @@ -117,7 +130,7 @@ export function render(onComplete) {
if (frame.type === 'begin')
showAlert(
frame.message,
'Click here for instructions',
translator.t('buttons.clickInstructions'),
function () {
nextTrial();
},
Expand All @@ -127,7 +140,7 @@ export function render(onComplete) {
else if (frame.type === 'message')
showAlert(
frame.message,
'Click here to continue',
translator.t('buttons.clickContinue'),
function () {
showFrame('null');
nextTrial();
Expand All @@ -141,7 +154,9 @@ export function render(onComplete) {
function () {
requestAnimationFrame(function () {
getID('sequence').innerHTML = frame.LN;
getID('judgement').innerHTML = frame.judgement.toString().toUpperCase();
getID('judgement').innerHTML = frame.judgement
? translator.t('judgement.' + frame.judgement).toUpperCase()
: '';
showFrame(null);
});
},
Expand Down Expand Up @@ -244,40 +259,33 @@ export function render(onComplete) {
// for a single trial/frame
function setFrameSequence() {
var TestMessage;
var instructionsHeading = '<h3>' + translator.t('instructions.heading') + '</h3>';
TestMessage = {
begin: '<h2>Letter/Number Switching</h2>' + "<img src='images/Inst0.jpg' alt='Title'><br><br>",
begin: '<h2>' + translator.t('instructions.title') + '</h2>' + "<img src='images/Inst0.jpg' alt='Title'><br><br>",
instructions: [
'<h3>Instructions</h3>' +
instructionsHeading +
"<img src='images/Inst1.jpg' alt='Instructions'><br><br>" +
'Here your job is to report<br>' +
'either the number or the letter<br>' +
'in this letter/number pair.<br><br>',
'<h3>Instructions</h3>' +
translator.t('instructions.step1') +
'<br><br>',
instructionsHeading +
"<img src='images/Inst2.jpg' alt='Instructions'><br><br>" +
'The word above the letter-number pair<br>' +
'tells you what to report<br>' +
"(here it's the <b>number</b>).<br><br>",
'<h3>Instructions</h3>' +
translator.t('instructions.step2') +
'<br><br>',
instructionsHeading +
"<img src='images/Inst3.jpg' alt='Instructions'><br><br>" +
'To report the number <b>1</b>, you click<br>' +
'the button that has that number (<b>left</b>).<br><br>',
'<h3>Instructions</h3>' +
translator.t('instructions.step3') +
'<br><br>',
instructionsHeading +
"<img src='images/Inst4.jpg' alt='Instructions'><br><br>" +
'To report the letter <b>z</b>, you click<br>' +
'the button that has that letter (<b>right</b>).<br><br>',
'<h3>Instructions</h3>' +
translator.t('instructions.step4') +
'<br><br>',
instructionsHeading +
"<img src='images/Inst4.jpg' alt='Instructions'><br><br>" +
"Let's do some practice.<br><br>",
'Excellent!<br>' + 'You have completed the practice.<br><br>' + "Now let's do more.<br><br>"
translator.t('instructions.letsPractice') +
'<br><br>',
translator.t('instructions.excellent') + '<br><br>'
],
test: [
'Remember!<br><br>' +
'Look at the word on top, then <br>' +
'click the button that has<br>' +
'the letter or number in the pair below.<br><br>' +
'Please try to be QUICK,<br>' +
'but also ACCURATE.<br><br>'
]
test: [translator.t('test.remember') + '<br><br>']
};

// type of frame to display
Expand Down
90 changes: 90 additions & 0 deletions lib/interactive/TMB_LN_SWITCHING/translator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Translator } from '/runtime/v1/@opendatacapture/runtime-core';

export const translator = new Translator({
translations: {
buttons: {
clickContinue: {
en: 'Click here to continue',
fr: 'Cliquez ici pour continuer'
},
clickInstructions: {
en: 'Click here for instructions',
fr: 'Cliquez ici pour les instructions'
},
clickRetry: {
en: 'Click here to retry',
fr: 'Cliquez ici pour réessayer'
}
},
judgement: {
letter: {
en: 'letter',
fr: 'lettre'
},
number: {
en: 'number',
fr: 'chiffre'
}
},
practiceError: {
target: {
en: 'Your target was the <b>{judgement} {target}</b>:',
fr: 'Votre cible était : <b>{judgement} {target}</b>'
},
shouldRight: {
en: 'you should have clicked<br>the <b>right</b> button.',
fr: 'vous auriez dû cliquer<br>sur le bouton de <b>droite</b>.'
},
shouldLeft: {
en: 'you should have clicked<br>the <b>left</b> button.',
fr: 'vous auriez dû cliquer<br>sur le bouton de <b>gauche</b>.'
}
},
timeout: {
message: {
en: 'Please respond as quickly as you can.<br><br>Click the left or right button.',
fr: 'Veuillez répondre aussi vite que possible.<br><br>Cliquez sur le bouton de gauche ou de droite.'
}
},
instructions: {
title: {
en: 'Letter/Number Switching',
fr: 'Alternance lettres/chiffres'
},
heading: {
en: 'Instructions',
fr: 'Instructions'
},
step1: {
en: 'Here your job is to report<br>either the number or the letter<br>in this letter/number pair.',
fr: 'Ici, votre tâche est de rapporter<br>soit le chiffre, soit la lettre<br>de cette paire lettre/chiffre.'
},
step2: {
en: 'The word above the letter-number pair<br>tells you what to report<br>(here it’s the <b>number</b>).',
fr: 'Le mot au-dessus de la paire lettre-chiffre<br>vous indique quoi rapporter<br>(ici, c’est le <b>chiffre</b>).'
},
step3: {
en: 'To report the number <b>1</b>, you click<br>the button that has that number (<b>left</b>).',
fr: 'Pour rapporter le chiffre <b>1</b>, vous cliquez<br>sur le bouton qui contient ce chiffre (<b>gauche</b>).'
},
step4: {
en: 'To report the letter <b>z</b>, you click<br>the button that has that letter (<b>right</b>).',
fr: 'Pour rapporter la lettre <b>z</b>, vous cliquez<br>sur le bouton qui contient cette lettre (<b>droite</b>).'
},
letsPractice: {
en: 'Let’s do some practice.',
fr: 'Faisons quelques essais d’entraînement.'
},
excellent: {
en: 'Excellent!<br>You have completed the practice.<br><br>Now let’s do more.',
fr: 'Excellent !<br>Vous avez terminé l’entraînement.<br><br>Passons à la suite.'
}
},
test: {
remember: {
en: 'Remember!<br><br>Look at the word on top, then <br>click the button that has<br>the letter or number in the pair below.<br><br>Please try to be QUICK,<br>but also ACCURATE.',
fr: 'Rappel !<br><br>Regardez le mot en haut, puis <br>cliquez sur le bouton qui contient<br>la lettre ou le chiffre de la paire ci-dessous.<br><br>Essayez d’être RAPIDE,<br>mais aussi PRÉCIS.'
}
}
}
});
5 changes: 0 additions & 5 deletions lib/interactive/TMB_MOT/TestMyBrain.12.18.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function showFrame() {
for (
tmbObjs.frames.length || (tmbObjs.frames = document.getElementsByTagName('div')), t = tmbObjs.frames.length;
t--;

)
((e = n.indexOf(tmbObjs.frames[t].id) > -1 ? 'block' : 'none'),
tmbObjs.frames[t].style.display !== e && (tmbObjs.frames[t].style.display = e));
Expand All @@ -70,7 +69,6 @@ function showFrameClass() {
for (
tmbObjs.frames.length || (tmbObjs.frames = document.getElementsByTagName('div')), t = tmbObjs.frames.length;
t--;

)
((e = n.indexOf(tmbObjs.frames[t].className) > -1 ? 'block' : 'none'),
tmbObjs.frames[t].style.display !== e && (tmbObjs.frames[t].style.display = e));
Expand Down Expand Up @@ -517,7 +515,6 @@ function imagePreLoad(e, t) {
(t.addEventListener('load', c, !0), t.addEventListener('error', c, !0), (t.id = e), (t.src = e));
};
l > 0;

)
(l--, d(n.shift()));
}
Expand Down Expand Up @@ -3362,7 +3359,6 @@ var saveTextAs =
s = void 0 === a ? n : a >> 0,
u = 0 > s ? Math.max(n + s, 0) : Math.min(s, n);
u > i;

)
((t[i] = e), i++);
return t;
Expand Down Expand Up @@ -3472,7 +3468,6 @@ var zen = tmbObjs,
r = n.length,
o = (window.console = window.console || {});
r--;

)
((e = n[r]), o[e] || (o[e] = t));
})(),
Expand Down
Loading
Loading