0 votes
in SoSci Survey (English) by s332786 (135 points)
edited by SoSci Survey

Hi,

I have a project that includes 4 different questionnaire versions (each shown to a different participant group). All versions are managed within the same project.

I would like to:

Set a quota of 35 completed responses per questionnaire version.

I tried the code below in PHP, and it works fine (except that the count is wrong!! ).

// Completed questionnaires count
**$finished = statistic('count', 'FINISHED');**

//Filter for quota stop
**if ($finished >= 20) {**
  // Text display
  **text('A014');**
  // Hide Next button
  **buttonHide();**
  // Show no further content from this page
  **pageStop();
}**

However:

Even though I only have 2 completed responses, the quota limit triggers at 19.

In the dataset view, all responses across all versions appear together, and it’s unclear how the statistic() function filters them internally.

My questions:

How can I ensure that statistic() only counts the completed responses (FINISHED=1) for each specific questionnaire version, not across the whole project?

Is there a recommended way to manage quotas independently for each version, especially if they are in the same project?

I only want to stop each survey once it reaches 35 completed responses.

Thank you for any guidance!

1 Answer

+1 vote
by SoSci Survey (352k points)

How can I ensure that statistic() only counts the completed responses (FINISHED=1) for each specific questionnaire version, not across the whole project?

Set a filter for the statistic() function, please:

statistic('filter', null, 'QUESTNNR="alpha"');
$finished = statistic('count', 'FINISHED');

Is there a recommended way to manage quotas independently for each version, especially if they are in the same project?

A very simple choice would be using the new Quota element, available under "New Question". In order to just count completed questionnaires, you should also create an "internal variable" with defined options (1=complete) and set the variable via put() on the first last page of the questionnaire. Just above the quota element.

put('IV01_01', 1);

Then create 4 quota questions, one for each questionnaire, and check the counts for this variable.

by s332786 (135 points)
Thank you very much for the detailed answer.
It works !!
by s332786 (135 points)
Hi,
I encountered another problem now.

I have created an internal variable (A022) and assigned it a value of 1. I placed the put() code on the first page and placed the internal variables on the last page of the questionnaire.

//This is the code I used


put('A022_01', 1);
statistic('filter', null, 'QUESTNNR="QuotaCheck"');
$finished = statistic('count', 'FINISHED');

//Filter for quota stop
if ($finished >= 13) {
  // Text display
  text('A020');
  // Hide Next button
  buttonHide();
  // Show no further content from this page
  pageStop();
}

This time, it refers to the count in the current questionnaire (which resolved my initial issue), but responses are being counted even when the survey is not fully completed. Which means incomplete responses are included in the quota count.
Please help me with how to count only completed responses.

I really appreciate your time and assistance.
Thank you
by SoSci Survey (352k points)
> and placed the internal variables on the last page of the questionnaire.

Placing the "internal variable" in the questionnaire only makes sense when you want to change its content via JavaScript. Otherwise, this has no effect.

Also refers my recommendation with the internal variable to using the "Quota" element instead (!) of the statistic() code. Any code except for the put() would be removed, if you would like to try that solution.
by s332786 (135 points)
Thank you very much

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...