Изпити
Функцията за изпити добавя режим на тест с отброяване на времето към анкетата, с незадължителна звукова обратна връзка за верни и грешни отговори.
The Exam feature turns a survey into a timed quiz. A countdown timer is displayed to the respondent, and the survey records how much time remains when they finish. Optionally, audio sounds can play for correct and incorrect answers.
This is useful for knowledge assessments, literacy tests, field staff competency checks, and any survey where time-on-task is meaningful data.
check-exam() function
Configure the exam using check-exam() in the calculation column of a calculate field placed at the start of the form:
check-exam(examTime, questionToStoreRemainingTime)
check-exam(examTime, questionToStoreRemainingTime, rightSound, wrongSound, excludeQuestion)
Параметри
| # | Parameter | Description |
|---|---|---|
| 1 | examTime | Total exam duration in seconds |
| 2 | questionToStoreRemainingTime | The name of a calculate or integer field that will store the remaining time when the exam ends |
| 3 | rightSound | (Optional) Filename of the audio file to play when a correct answer is given (attach to the form as a media file) |
| 4 | wrongSound | (Optional) Filename of the audio file to play when an incorrect answer is given |
| 5 | excludeQuestion | (Optional) Comma-separated list of field names to exclude from the exam timer (e.g., 'intro_note,consent') |
Основно setup
Step 1: Add exam fields
| type | name | label | calculation |
|---|---|---|---|
| calculate | exam_config | check-exam(600, 'remaining_time') | |
| calculate | remaining_time |
exam_config triggers the 600-second (10-minute) timer. remaining_time is populated automatically when the respondent finishes.
Step 2: Add your questions
The exam timer covers all questions in the form except those listed in excludeQuestion.
| type | name | label |
|---|---|---|
| select_one yesno | q1 | The capital of Kenya is Nairobi. True or false? |
| select_one choices | q2 | Which organ pumps blood around the body? |
| select_one choices | q3 | Water boils at 100°C at sea level. True or false? |
Step 3: Store the remaining time
The field named in parameter 2 (remaining_time) is automatically set to the number of seconds remaining when the respondent submits. A value of 0 means time ran out; a high value means they finished quickly.
With audio feedback
Attach sound files to the form (as media attachments), then reference them:
| type | name | label | calculation |
|---|---|---|---|
| calculate | exam_config | check-exam(300, 'remaining_time', 'correct.mp3', 'wrong.mp3') |
correct.mp3plays when the respondent selects the right answerwrong.mp3plays when the respondent selects a wrong answer
Sound files must be attached to the form as media files and the filename must match exactly (case-sensitive) including the extension.
Excluding questions from the timer
Pass a comma-separated list of field names to exclude from the exam (e.g., introductory notes or consent questions):
check-exam(300, 'remaining_time', '', '', 'intro_note,consent_ack,section_header')
Leave rightSound and wrongSound as empty strings '' if you do not need audio but do need exclusions.
Complete example
| type | name | label | calculation |
|---|---|---|---|
| note | intro | Welcome to the health knowledge assessment. You have 5 minutes to answer all questions. | |
| trigger | start_ack | Tap OK when you are ready to begin. | |
| calculate | exam_config | check-exam(300, 'remaining_time', 'correct.mp3', 'wrong.mp3', 'intro,start_ack') | |
| calculate | remaining_time | ||
| select_one yesno | q1 | Handwashing prevents the spread of disease. | |
| select_one yesno | q2 | You should drink at least 2 litres of water per day. | |
| select_one yesno | q3 | Malaria is caused by a virus. |
Best Practices
- Always inform respondents about the time limit before starting — use a
noteortriggerbefore thecheck-exam()field. - Exclude intro notes and consent questions from the timer using the
excludeQuestionparameter. - Use
remaining_timein a follow-up calculation to detect time-outs:if(${remaining_time} = 0, 'Timed out', 'Completed'). - Keep the number of questions proportional to the time allowed — 2–3 minutes per question is a reasonable baseline for most knowledge assessments.
- Test with audio files on the actual device before deployment — audio playback varies across Android versions and browsers.
Limitations
- The timer is display-only — the form does not automatically submit when time runs out; the respondent must still submit manually.
- Audio feedback requires the device volume to be on and not muted.
- The exam feature is an rtSurvey extension and is not part of the standard XLSForm specification.