Screening Questionnaire
Answer all questions using the drop-down menus. Your total score is calculated automatically when you finish.
0 of 0 answered
Your total score
0
Score breakdown
| # | Question | Answer | Points |
|---|
Scoring Rules
In Craft this lives in the Control Panel: each question is an entry, and each answer row (Table / Matrix field) carries its own point value. Editors change points or score bands with no code deploy.
Calculation version:
Score bands
| Band | From | To | Message |
|---|
Questions & answer points
| # | Question | Answers → points | Weight |
|---|
How it works in Craft CMS
Content model
- Section “Questionnaire Questions” (Structure – sortable)
- Fields: question text, category, weight, and a Table field of answers (label + points)
- Global set “Scoring Settings”: score bands, messages, calculation version
Calculation
- Twig renders the drop-downs; answer IDs, not point values, go to the browser
- Total is calculated server-side in a small Craft module (no tampering) and shown on completion
- A calculation change = edit the rule in one place, covered by test cases
Example – Twig template
{% set questions = craft.entries.section('questionnaireQuestions').all() %}
<form method="post">
{{ csrfInput() }}
{{ actionInput('screening/score/calculate') }}
{% for q in questions %}
<label>{{ loop.index }}. {{ q.title }}</label>
<select name="answers[{{ q.id }}]" required>
<option value="">Select…</option>
{% for row in q.answers %}
<option value="{{ loop.index0 }}">{{ row.label }}</option>
{% endfor %}
</select>
{% endfor %}
<button>Calculate my score</button>
</form>
Example – scoring module (PHP)
public function actionCalculate(): Response
{
$answers = $this->request->getRequiredBodyParam('answers');
$total = 0;
foreach (Entry::find()->section('questionnaireQuestions')->all() as $q) {
$row = $q->answers[$answers[$q->id] ?? -1] ?? null;
$points = (int)($row['points'] ?? 0);
$total += ScoringRules::apply($points, $q); // amended rule lives here
}
return $this->renderTemplate('screening/_result', [
'total' => $total,
'band' => ScoringRules::band($total),
]);
}