Skip to content

Quizzes and Scoring

Formspace supports secure quizzes, tests, assessments, and graded forms by grading submissions on the server. Correct answers and question scores are removed from the respondent form payload, so respondents cannot inspect the browser network response to find the answer key.

  • Add correctAnswer to make a question part of a quiz.
  • Add score only when overriding the default 1 point value.
  • Use {score}, {totalScore}, and {scorePercent} in completion HTML.
  • Do not use choices[].score for secure quiz grading.

Add a correctAnswer property to any value-producing question to make it part of a quiz.

{
"type": "radiogroup",
"name": "capital",
"title": "What is the capital of France?",
"choices": ["Berlin", "Madrid", "Paris", "Rome"],
"correctAnswer": "Paris"
}

Formspace computes quiz results when the response is submitted. Response views, PDFs, and the submissions table can then show correct and incorrect answers.

Complete example:

{
"elements": [
{
"type": "radiogroup",
"name": "capital",
"title": "What is the capital of France?",
"choices": ["Berlin", "Madrid", "Paris", "Rome"],
"correctAnswer": "Paris"
},
{
"type": "radiogroup",
"name": "security",
"title": "Which approach protects the answer key?",
"choices": ["Client-side scoring", "Server-side grading", "Theme variables"],
"correctAnswer": "Server-side grading",
"score": 5
}
],
"completedHtml": "<h3>Your score: {score}/{totalScore} ({scorePercent}%)</h3>"
}

Quiz questions are worth 1 point by default. To give questions different point values, add a numeric score property to a question that also has correctAnswer.

{
"type": "radiogroup",
"name": "advanced_security",
"title": "Which control prevents respondents from seeing the answer key?",
"choices": ["Client-side scoring", "Server-side grading", "Theme variables"],
"correctAnswer": "Server-side grading",
"score": 5
}

Points are awarded only for correct answers. A correct 5-point question earns 5 points; an incorrect answer earns 0 points. A correct question without an explicit score earns 1 point.

In the form builder, the Score property appears in the Data section after you set a Correct Answer.

You can use quiz result variables in completedHtml and completedHtmlOnCondition after the response is submitted.

Available post-submit variables:

Variable Description
{correctAnswers} Number of quiz questions answered correctly.
{correctedAnswers} Alias for {correctAnswers}.
{correctedAnswerCount} Alias for {correctAnswers}.
{incorrectAnswers} Number of quiz questions answered incorrectly.
{incorrectedAnswers} Alias for {incorrectAnswers}.
{incorrectedAnswerCount} Alias for {incorrectAnswers}.
{questionCount} Number of quiz questions.
{score} Points earned from correct quiz questions.
{totalScore} Maximum available points from quiz questions.
{maxScore} Alias for {totalScore}.
{scorePercent} Percentage score from 0 to 100.

Example:

{
"completedHtml": "<h3>Your score: {score}/{totalScore}</h3>",
"completedHtmlOnCondition": [
{
"expression": "{scorePercent} >= 70",
"html": "<h3>You passed with {scorePercent}%.</h3>"
}
]
}

These variables are available after submit or after completing the form builder preview. They are not available for live pre-submit logic because Formspace does not send correct answers or score metadata to respondent browsers.

Submitted quiz responses include:

  • An overall correct-answer count.
  • An overall point score when scored quiz questions are present.
  • Per-question correct or incorrect indicators.
  • Per-question point details for scored quiz questions.

PDF exports include a quiz summary near the top of the response and per-question quiz indicators.