Variable fields allow you to calculate and display scores, totals, or other custom outputs based on user input.
They are highly versatile and can be used for various purposes, such as score calculations in quizzes, estimations for pricing, and more.
This tutorial will guide you step-by-step on how to set up variable fields for calculating scores in your forms.
Step 1: Create a form
Navigate to the dashboard:
Click on + New Formaloo and select either a form or a survey for your project.
Add question fields:
Add different types of question fields in your form.
A combination of text fields (for basic info like the name), single-choice fields (for quiz questions), and variable fields (for score calculation).
Add an ID for the variable field:
Assign a unique ID to each variable field. This ID is essential because it allows you to reference the variable in formulas and success messages, enabling you to display calculated scores or other values dynamically (e.g., showing the total score to the user after submission).
For this tutorial, we will be creating a self-grading quiz, therefore, we will need the following fields:
Short/long text fields - to gather basic information, like the student's name;
Single-choice fields - to add quiz questions;
Content fields - for section introductions, like Geography, History, Science and Math;
Variable fields with ID - for calculating the score.
Step 2: Add scores to each question
Open the form editor:
Select the question you want to score, then click on the Logic tab on the right sidebar.
Set a score for correct answers:
In the Advanced Logic section, click on + Add Condition and set the logic for correct answers.
For example, if the answer is Option 1, assign a score of 5.
Repeat for all quiz questions:
For each quiz question, repeat the process of assigning a score to the correct answer.
Step 3: Add Variable fields to calculate the total score
Create variable fields for individual scores:
For different categories (e.g., Science, Math), create variable fields that store the scores.
Assign an ID to each field (e.g., science_score, math_score).
Set up the formula for the total score:
Create a Variable field to calculate the total score.
Select the type of variable field as Formula, and in the Default value section, use the sum of all score variables (e.g., science_score + math_score + history_score).
Assign an ID to the total score field (e.g., total_score).
Step 4: Display the total score on the success page
Customize the success message:
After the user submits the form, you can display the total score on the success page.
Use answer piping to show the score dynamically by adding the ID in the success message:
Your Total Score is {{total_score}} or @total_score
2. Add multiple success pages (optional):If desired, create additional success pages and display different results based on the total score.
Additional use cases for Variable fields
Estimation forms: Use variable fields to estimate project costs or pricing structures.
Product recommendation forms: Customize pricing or recommendations based on selections.
Variable fields can enhance user interaction by providing personalized results, making your forms more dynamic and tailored to the user’s input.