ReturnLowestFltSel (leastfill)

Description:

script:ReturnLowestFltSel(qsid,apiToken,baselineid,analysisQuestion,qualifyingQuestion,maxNumberToPick,randomSeed)

This function is used to run real-time analysis on a dataset (questionnaire) to determine the counts for the options (categories) in the question. Based on the counts, and the codes qualifying, one or more categories are picked based on a least-fill (the categories with the lowest counts are picked first). In principle, the analysis dataset can be a different one than the one we are programming, and the analysis question can be a different one from the one we are in, so there is no automatic connection between the question/questionnaire we are in and the script function. Hence, all parameters must be carefully considered. Also the difference between static parameters that are in single quotes, and dynamic/references that are not in single quotes and are typically introduced by "\" (backslash character).

Parameters:

qsid: This is the id of the domain (account) and can be found on any link to a questionnaire. In most cases this will be the same domain, so the simple solution is to use \@sys_qsid system parameter.

apiToken: This is a token that will allow the system to run an analysis on the relevant dataset. It can be a personal token, a project token, or a dataset token.

baselineid: This is the baseline of the dataset (questionnaire) that contains the question we should use to analyze to find the least possible options. In most cases this is the same questionnaire we are in, hence use the system variable \@sys_baselineid

analysisQuestion: This is the question id of the question we are going to analyze. This should always be in single quotation, and without a backslash, but containing the subquestion letter. E.g. 'myQuestion.b' meaning the question with id: myQuestion and the subquestion "b" (second subquestion).

qualifyingQuestion:  This is a reference to the question that contains the qualifying codes (options). This must always be a reference, aka it should NOT be in single quotes, and always start with a "\". Usually, this is a sub-question within the question we are programming, and hence we can use the shorthand notation like "\.a" meaning the subquestion a (first subquestion, within the question we are programming.

maxNumberToPick: This is the maximum number of categories that we should pick of the ones qualifying.

randomSeed: This is a seed used by the random generator to pick randomly, if more several options have the same counts, or if the analysis fails.

Returns the lowest value from a question/quota to determine which answer/cell needs to get selected

Example:

script:ReturnLowestFltSel(\@sys_qsid,'abc-123-xyz-890',\@sys_baselineid,'myQuestion.b',\.a,\@sys_random)