Skip to content

Commit

Permalink
Merge branch 'Psych-DS-v8' of https://github.com/vzhang03/jsPsych int…
Browse files Browse the repository at this point in the history
…o Psych-DS-v8
  • Loading branch information
Bankminer78 committed Jun 11, 2024
2 parents d548bac + 10e27a5 commit d2cdcb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions packages/metadata/src/VariablesMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ export class VariablesMap {
const trial_type_var = {
type: "PropertyValue",
name: "trial_type",
description: { default: "The name of the plugin used to run the trial." },
description: {
default: "unknown",
jsPsych: "The name of the plugin used to run the trial.",
},
value: "string",
};
this.setVariable(trial_type_var);

const trial_index_var = {
type: "PropertyValue",
name: "trial_index",
description: { default: "The index of the current trial across the whole experiment." },
description: {
default: "unknown",
jsPsych: "The index of the current trial across the whole experiment.",
},
value: "numeric",
};
this.setVariable(trial_index_var);
Expand All @@ -51,7 +57,8 @@ export class VariablesMap {
type: "PropertyValue",
name: "time_elapsed",
description: {
default:
default: "unknown",
jsPsych:
"The number of milliseconds between the start of the experiment and when the trial ended.",
},
value: "numeric",
Expand Down
4 changes: 3 additions & 1 deletion packages/metadata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,13 @@ export default class JsPsychMetadata {
private async generateObservation(observation) {
// variables can be thought of mapping of one column in a row
const pluginType = observation["trial_type"];
const ignored_fields = new Set(["trial_type", "trial_index", "time_elapsed"]);

for (const variable in observation) {
const value = observation[variable];

if (this.containsVariable(variable)) {
if (ignored_fields.has(variable)) this.updateFields(variable, value, typeof value);
else if (this.containsVariable(variable)) {
// logic updates existing variable
await this.generateUpdate(variable, value, pluginType);
} else {
Expand Down

0 comments on commit d2cdcb1

Please sign in to comment.