From cbf475723a4abbaa38aadbbf0a5a270c28794331 Mon Sep 17 00:00:00 2001 From: Thomas Pronk Date: Wed, 28 Jul 2021 08:45:25 +0200 Subject: [PATCH] ENH: Converted any string values for method to corresponding QuestHandler.Method values --- src/data/QuestHandler.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/data/QuestHandler.js b/src/data/QuestHandler.js index 57def2b..806ae45 100644 --- a/src/data/QuestHandler.js +++ b/src/data/QuestHandler.js @@ -88,6 +88,28 @@ export class QuestHandler extends TrialHandler this._estimateQuestValue(); } + /** + * Setter for the method attribute. + * + * @param {mixed} method - the method value, PsychoPy-style values ("mean", "median", + * "quantile") are converted to their respective QuestHandler.Method values + * @param {boolean} log - whether or not to log the change of seed + */ + setMethod(method, log) + { + let methodMapping = { + "quantile": QuestHandler.Method.QUANTILE, + "mean": QuestHandler.Method.MEAN, + "mode": QuestHandler.Method.MODE + }; + // If method is a key in methodMapping, convert method to corresponding value + if (methodMapping.hasOwnProperty(method)) + { + method = methodMapping[method]; + } + this._setAttribute("method", method, log); + } + /** * Add a response and update the PDF. *