Quota functions allow you to programmatically access and utilize quota data within the survey script. Returns an array of all quota objects for the specified question, indexed by choiceCode.
Quota Object Structure
When working with quota functions that return quota objects, each quota object contains the following properties:
Properties | Type | Description |
label | String | Label of the choice of quota question |
choiceCode | Number | The choice code identifier. |
quotaCount | Number | Number of completes recorded for the specified choice. |
target | Number | Quota target set for the specified choice. Returns -1 if no target set. |
getAllQuotas(label)
Fetches quota status for all choices associated with a given label, allowing logic to be built around fill status—particularly for managing concept exposure in concept testing studies.
Argument | Required | Description |
label | ✔️ | Label of the question, or hidden variable on which the quota is defined. |
Example
local quotas = getAllQuotas("Single_Choice_1")
quotas -- Returns: [[{label: "18-25", choiceCode:1,Target:1, Count:1}]
local i=0
quotas[i].label -- returns choice label
quotas[i].choiceCode -- returns choice code
quotas[i].quotaCount -- returns the quota count for the first choice
quotas[i].target -- returns the target quota count for the first choice
getUnfilledQuotas(label)
Fetches quota status for all unfilled choices associated with a given label, allowing logic to be built around fill status—particularly for managing concept exposure in concept testing studies.
Argument | Required | Description |
label | ✔️ | Label of the question, or hidden variable on which the quota is defined. |
Example
local quotas = getUnfilledQuotas("Single_Choice_1")
-- Returns only quotas that still have available capacity
quotas -- Returns: [[{label: "18-25", choiceCode:1, Target:1, Count:1}]
local i=0
quotas[i].label -- returns choice label
quotas[i].choiceCode -- returns choice code
quotas[i].quotaCount -- returns the quota count for the first available choice
quotas[i].target -- returns the target quota count for the first available choice
getQuotaCount(label, choiceCode)
Fetches the current fill count and target for a specific quota cell, enabling quota-aware logic at the choice level.
Argument | Required | Description |
label | ✔️ | Label of the question, or hidden variable on which the quota is defined. |
choiceCode | ✔️ | Code of the specific choice option |
Example
local c= getQuotaCount("Single_Choice_1", 1)
c.label -- returns choice label "Concept 1"
c.choiceCode -- returns choice code
c.quotaCount -- returns the quota count for the first choice
c.target -- returns the target quota count for the first choice
Usage Examples
Checking Available Quotas
-- Get all unfilled quotas for a question
local availableQuotas = getUnfilledQuotas("Demographics_Age")
-- Check if any quotas are still available
if size(availableQuotas) > 0 then
log("Quotas still available")
else
log("All quotas are filled")
end
Monitoring Quota Status
-- Check current quota for a specific choice
local currentCount = getQuotaCount("Demographics_Gender", 1)
log("Current quota data for option 1: " .. currentCount)
-- Get all quotas to check overall status
local allQuotas = getAllQuotas("Demographics_Gender")
local quota = allQuotas[0] -- use the choiceCode to get the quota object
log("Choice " .. quota.choiceCode .. ": " .. quota.quotaCount .. "/" .. quota.target)