Terminating interviews when targets have been met
The quota control system normally increments the count of interviews that are in progress for each cell as long as the sum of completed plus pended interviews does not exceed the cell target. When the target is very close to being met and there are several interviews running, that would, if they all completed, cause the target to be exceeded, only some of those interviews will be allowed to run to completion. Which interviews those are depends entirely on which ones reach the quota check first; it has nothing to do with which interview started first. If you want all interviews that start to be allowed to complete, you will need to switch on the Allow OverQuota flag. You can do this when you define quotas (see
Defining table quotas)or at any time during the course of the project.
The most common reason for pending counts not being incremented is because the targets have already been met when the interview starts, but this can also happen due to some other failure with either the questionnaire script or the quota database. To ensure that interviews run smoothly you are advised always to write code to cater for these situations whenever you pend quota cells. The most common action is to terminate the interview immediately, flagging it as terminated due to quota control. Here's some general code that you can use as a basis for your own scripts:
If Not (IsSet(Result, QuotaResultConstants.qrWasPended)) Then
IOM.Texts.InterviewStopped = InfoName.Label
IOM.Terminate(Signals.sigOverQuota)
End If
In this code:
▪Result is the name of a variable whose value stores the result of the pend request. For more information, see
Pending quota cells
▪InfoName is the name of an information item containing a message explaining why the interview is being terminated. (Text in IStandardTexts.InterviewStopped is shown on the page that the interviewing program displays when an interview is stopped.)
If the metadata section contains:
Region "What part of the country do you live in?" categorical [1..1]
{North, South, East, West};
Full "We already have enough interviews for the {#Region} region."
info;
your routing section might be as follows:
Dim RegionPendResult
RegionPendResult = QuotaEngine.QuotaGroups["Region"].Pend()
If Not(IsSet(RegionPendResult, QuotaResultConstants.qrWasPended)) Then
IOM.Texts.InterviewStopped = Full.Label
IOM.Terminate(Signals.sigOverQuota)
End If
When the quota for people who live in the south has been met, the next interview for that region will be terminated with the message "We already have enough interviews for the South region." and the DataCollection.Status field in the interview's case data will show that the interview was terminated due to quota control. For more information about sigOverQuota and signals, see
Signals.
See also