Skip to content

Commit

Permalink
choose first trial when no trial chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
erasta committed Dec 24, 2024
1 parent 46ee3b8 commit c00532d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "npm run dev",
"name": "Client",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}/client"
},
{
"name": "Server",
"type": "debugpy",
Expand All @@ -23,5 +30,14 @@
"--prod"
]
},
],
"compounds": [
{
"name": "Server/Client",
"configurations": [
"Client",
"Server",
]
}
]
}
24 changes: 19 additions & 5 deletions client/src/Context/TrialChoosing.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@ export class TrialChoosing {
const experimentIndex = allExperiments.findIndex(t => t.name === experimentName);
if (experimentIndex >= 0) {
const experiment = allExperiments[experimentIndex];
const trialTypeIndex = ((experiment || {}).trialTypes || []).findIndex(t => t.name === trialTypeName);
const trialTypes = (experiment || {}).trialTypes || [];

if (!trialTypeName && trialTypes.length > 0) {
const trialType = experiment.trialTypes[0];
const trials = (trialType || {}).trials || [];
if (trials.length > 0) {
return {
experimentName, experimentIndex,
trialTypeName: trialType.name, trialTypeIndex: 0,
trialName: trials[0].name, trialIndex: 0,
};
}
}

const trialTypeIndex = trialTypes.findIndex(t => t.name === trialTypeName);
if (trialTypeIndex >= 0) {
const trialType = experiment.trialTypes[trialTypeIndex];
const trialIndex = ((trialType || {}).trials || []).findIndex(t => t.name === trialName);
Expand All @@ -26,11 +40,11 @@ export class TrialChoosing {
trialName, trialIndex,
};
}
} else {
return {
experimentName, experimentIndex,
};
}

return {
experimentName, experimentIndex,
};
}
}
return {};
Expand Down
4 changes: 3 additions & 1 deletion client/src/Experiment/ExperimentList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export const ExperimentList = ({ fullscreen, showConfig, setShowConfig }) => {

const foundExperiment = findExperimentByUuid(newlyExpanded[0]);
if (foundExperiment) {
setCurrTrial({ experimentName: foundExperiment.name });
if (experiment.name !== foundExperiment.name) {
setCurrTrial({ experimentName: foundExperiment.name });
}
const newNodes = [
foundExperiment.trackUuid,
...nodeIds.filter(u => !findExperimentByUuid(u)),
Expand Down

0 comments on commit c00532d

Please sign in to comment.