Skip to content

Commit

Permalink
fix: working on lang
Browse files Browse the repository at this point in the history
  • Loading branch information
CMonnin committed Jul 25, 2024
1 parent d6ca14b commit 714487e
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 66 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"@jspsych/plugin-survey-html-form": "^2.0.0",
"@jspsych/plugin-survey-text": "^2.0.0",
"@types/node": "^20.14.12",
"i18next": "^23.12.2",
"i18next-http-backend": "^2.5.2",
"jspsych": "^8.0.1",
"papaparse": "^5.4.1",
"pure-rand": "^6.1.0",
Expand Down
75 changes: 75 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 88 additions & 44 deletions public/data.csv
Original file line number Diff line number Diff line change
@@ -1,45 +1,89 @@
stimulus,difficultyLevel,correctResponse,language
level1/addressplate.jpg,1,addressplate,EN
level1/bandage.jpg,1,bandage,EN
level1/bowrake.jpg,1,bowrake,EN
level1/bracelet04.jpg,1,bracelet04,EN
level1/broccoli01a.jpg,1,broccoli01a,EN
level2/africanelephant.jpg,2,africanelephant,EN
level2/almond.jpg,2,almond,EN
level2/bandaid01.jpg,2,bandaid01,EN
level2/bathtub.jpg,2,bathtub,EN
level2/belt02a.jpg,2,belt02a,EN
level3/acousticguitar02.jpg,3,acousticguitar02,EN
level3/apple07.jpg,3,apple07,EN
level3/asparagus.jpg,3,asparagus,EN
level3/bagel01.jpg,3,bagel01,EN
level3/blackbear.jpg,3,blackbear,EN
level4/accordion01.jpg,4,accordion01,EN
level4/binder03b.jpg,4,binder03b,EN
level4/birdnest.jpg,4,birdnest,EN
level4/bridge.jpg,4,bridge,EN
level4/cactus.jpg,4,cactus,EN
level5/baguette01.jpg,5,baguette01,EN
level5/bed.jpg,5,bed,EN
level5/blackberry.jpg,5,blackberry,EN
level5/boatmotor.jpg,5,boatmotor,EN
level5/bowl02a.jpg,5,bowl02a,EN
level6/ant.jpg,6,ant,EN
level6/barn.jpg,6,barn,EN
level6/baseboardheater01.jpg,6,baseboardheater01,EN
level6/birdie.jpg,6,birdie,EN
level6/bleachers.jpg,6,bleachers,EN
level7/aircompressor.jpg,7,aircompressor,EN
level7/arm.jpg,7,arm,EN
level7/arugula.jpg,7,arugula,EN
level7/atm.jpg,7,atm,EN
level7/barrel01.jpg,7,barrel01,EN
level8/aquarium.jpg,8,aquarium,EN
level8/ashtray01.jpg,8,ashtray01,EN
level8/avcable.jpg,8,avcable,EN
level8/axe01.jpg,8,axe01,EN
level9/anchor.jpg,9,anchor,EN
level9/awning.jpg,9,awning,EN
level9/badmintonracket.jpg,9,badmintonracket,EN
level9/bagofpowder.jpg,9,bagofpowder,EN
level9/banana01.jpg,9,banana01,EN
level1/addressplate.jpg,1,addressplate,en
level1/bandage.jpg,1,bandage,en
level1/bowrake.jpg,1,bowrake,en
level1/bracelet04.jpg,1,bracelet04,en
level1/broccoli01a.jpg,1,broccoli01a,en
level2/africanelephant.jpg,2,africanelephant,en
level2/almond.jpg,2,almond,en
level2/bandaid01.jpg,2,bandaid01,en
level2/bathtub.jpg,2,bathtub,en
level2/belt02a.jpg,2,belt02a,en
level3/acousticguitar02.jpg,3,acousticguitar02,en
level3/apple07.jpg,3,apple07,en
level3/asparagus.jpg,3,asparagus,en
level3/bagel01.jpg,3,bagel01,en
level3/blackbear.jpg,3,blackbear,en
level4/accordion01.jpg,4,accordion01,en
level4/binder03b.jpg,4,binder03b,en
level4/birdnest.jpg,4,birdnest,en
level4/bridge.jpg,4,bridge,en
level4/cactus.jpg,4,cactus,en
level5/baguette01.jpg,5,baguette01,en
level5/bed.jpg,5,bed,en
level5/blackberry.jpg,5,blackberry,en
level5/boatmotor.jpg,5,boatmotor,en
level5/bowl02a.jpg,5,bowl02a,en
level6/ant.jpg,6,ant,en
level6/barn.jpg,6,barn,en
level6/baseboardheater01.jpg,6,baseboardheater01,en
level6/birdie.jpg,6,birdie,en
level6/bleachers.jpg,6,bleachers,en
level7/aircompressor.jpg,7,aircompressor,en
level7/arm.jpg,7,arm,en
level7/arugula.jpg,7,arugula,en
level7/atm.jpg,7,atm,en
level7/barrel01.jpg,7,barrel01,en
level8/aquarium.jpg,8,aquarium,en
level8/ashtray01.jpg,8,ashtray01,en
level8/avcable.jpg,8,avcable,en
level8/axe01.jpg,8,axe01,en
level9/anchor.jpg,9,anchor,en
level9/awning.jpg,9,awning,en
level9/badmintonracket.jpg,9,badmintonracket,en
level9/bagofpowder.jpg,9,bagofpowder,en
level9/banana01.jpg,9,banana01,en
level1/addressplate.jpg,1,addressplate,fr
level1/bandage.jpg,1,bandage,fr
level1/bowrake.jpg,1,bowrake,fr
level1/bracelet04.jpg,1,bracelet04,fr
level1/broccoli01a.jpg,1,broccoli01a,fr
level2/africanelephant.jpg,2,africanelephant,fr
level2/almond.jpg,2,almond,fr
level2/bandaid01.jpg,2,bandaid01,fr
level2/bathtub.jpg,2,bathtub,fr
level2/belt02a.jpg,2,belt02a,fr
level3/acousticguitar02.jpg,3,acousticguitar02,fr
level3/apple07.jpg,3,apple07,fr
level3/asparagus.jpg,3,asparagus,fr
level3/bagel01.jpg,3,bagel01,fr
level3/blackbear.jpg,3,blackbear,fr
level4/accordion01.jpg,4,accordion01,fr
level4/binder03b.jpg,4,binder03b,fr
level4/birdnest.jpg,4,birdnest,fr
level4/bridge.jpg,4,bridge,fr
level4/cactus.jpg,4,cactus,fr
level5/baguette01.jpg,5,baguette01,fr
level5/bed.jpg,5,bed,fr
level5/blackberry.jpg,5,blackberry,fr
level5/boatmotor.jpg,5,boatmotor,fr
level5/bowl02a.jpg,5,bowl02a,fr
level6/ant.jpg,6,ant,fr
level6/barn.jpg,6,barn,fr
level6/baseboardheater01.jpg,6,baseboardheater01,fr
level6/birdie.jpg,6,birdie,fr
level6/bleachers.jpg,6,bleachers,fr
level7/aircompressor.jpg,7,aircompressor,fr
level7/arm.jpg,7,arm,fr
level7/arugula.jpg,7,arugula,fr
level7/atm.jpg,7,atm,fr
level7/barrel01.jpg,7,barrel01,fr
level8/aquarium.jpg,8,aquarium,fr
level8/ashtray01.jpg,8,ashtray01,fr
level8/avcable.jpg,8,avcable,fr
level8/axe01.jpg,8,axe01,fr
level9/anchor.jpg,9,anchor,fr
level9/awning.jpg,9,awning,fr
level9/badmintonracket.jpg,9,badmintonracket,fr
level9/bagofpowder.jpg,9,bagofpowder,fr
level9/banana01.jpg,9,banana01,fr
4 changes: 2 additions & 2 deletions public/experimentSettings.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
totalNumberOfTrialsToRun,advancementSchedule,regressionSchedule,language, seed
5,2,0,EN, 42
totalNumberOfTrialsToRun,advancementSchedule,regressionSchedule,language,seed,initalDifficulty
5,2,0,fr,42,1
26 changes: 14 additions & 12 deletions src/fetchAndParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import Papa from "papaparse";
import "./style.css";

async function fetchAndParse(path: string) {
console.log('path')
console.log(path)
console.log("path");
console.log(path);
try {
const response = await fetch(path, {
headers: { Accept: "text/csv" },
method: "GET",
});
if (!response.ok) {
console.log(response)
console.log(response);
const container = document.createElement(`div`);
const p = document.createElement("p");
const msg = document.createElement(`h1`);
Expand All @@ -32,31 +32,32 @@ async function fetchAndParse(path: string) {

const responseText = await response.text();
const data = Papa.parse(responseText, { header: true });
console.log('fetch and parse got data')
console.log("fetch and parse got data");
console.log(data);
return data;
} catch (error) {
console.log('error:')
console.log("error:");
console.log(error);
}
}
const baseUrl = import.meta.env.BASE_URL;
const dataPath = baseUrl + 'data.csv'
const experimentSettingsPath = baseUrl + 'experimentSettings.csv'
console.log(`BaseUrl: ${baseUrl}`);
const dataPath = baseUrl + "data.csv";
const experimentSettingsPath = baseUrl + "experimentSettings.csv";

const parsedImageDB = await fetchAndParse(dataPath);
if (!parsedImageDB) {
throw new Error("Failed to fetch and parse the data.csv.");
} else {
console.log('parsedImageDB')
console.log("parsedImageDB");
console.table(parsedImageDB);
}
const parsedExperimentSettings = await fetchAndParse(experimentSettingsPath)
const parsedExperimentSettings = await fetchAndParse(experimentSettingsPath);
if (!parsedExperimentSettings) {
throw new Error('Failes to fetch and parse the experimentSettings.csv.')
throw new Error("Failes to fetch and parse the experimentSettings.csv.");
} else {
console.log('experimentSettings')
console.table(parsedExperimentSettings)
console.log("experimentSettings");
console.table(parsedExperimentSettings);
}
interface ImageBank {
stimulus: string;
Expand All @@ -71,6 +72,7 @@ interface Settings {
regressionSchedule: number | string;
language: string;
seed: number;
initialDifficulty: number | string;
}

const experimentSettings: Settings = parsedExperimentSettings
Expand Down
Loading

0 comments on commit 714487e

Please sign in to comment.