Submit a ticket My Tickets
Login  Sign up
Open navigation

Enhance Personalized Learning using Variables in Assessments & Forms

Pro Trainer
Learning Center
High Volume & Corporate

Online course creators who achieve success prioritize customizing learning experiences to enhance user engagement and satisfaction. However, personalization is usually a demanding and time-consuming task. In this article, we will discuss the potential to automate and efficiently personalize interactions for a more tailored learning experience, using Liquid Variables in Assessments, Certificates, and Forms.

Liquid is a template language created by Shopify. A template language allows you to create a single template to host static content, and dynamically insert information depending on where the template is rendered. 

In simple words, if you write {{user.username}} depending on who the user is, they will see their own name. If you write {{submission.self.score}} each user will see their score from an exam. 

We support liquid variables in the LearnWorlds Site Builder custom code editor , text editors in the Assessments, Certificates, and Forms, and in the automated feedback editor. Integrating variables enables real-time updates to assessments, like adjustments to questions, instructions, or grading criteria. This level of personalization and flexibility enhances engagement, comprehension, and the effectiveness of Assessments and Surveys/Forms within the online course. Keep in mind that some familiarity with code is required. 

Variables Categories 

Variables can be used in:

1. The text editor of all text widgets in Assessments, Certificates, and Forms, with a list of the available variables 

2. In the automated feedback text editor

This adds the variables in the text widgets in line with the rest of the text, meaning you can write a sentence and have the value of the variable printed inside a sentence. 

E.g. Hello, {{user.username}} this is a great day, would look like "Hello, Jane this is a great day."

There are three kinds of variables:

1. System variables regarding:

  1. The school name
  2. School's URL
  3. School's description
  4. User's username
  5. User's email

2. Previous submission variables, that recall the question or the answer of a user to a question (of this or another form/assessment similar to our “Previous submission” widget).

3. Ending screen. Those variables are available only in the context of the ending screen and include:

- Attempts count

- Correct answers

- Date submitted

- Max tries

- Passing grade

- Points

- Score

- Time spent

- Time spent in seconds

- Total number of questions

- Total points

For the Certificate of Completion, the variable available in the ending screen is the Date Submitted.

Variable applications in Assessments

Our more advanced users with some coding experience can utilize the variables option within the Form and Assessment editors. The use cases can vary from:

  1. Personalization (display the username of this specific user, Showing different elements based on the users’ tags) 
  2. Displaying exam scores in different score metric systems
  3. Use “previous submission” variables, similar to our reference widget (that recalls previous questions and answers) with some extra benefits compared to the widget 
  4. Creating even more custom logic using if statements 

Differences between Previous Response Variables and Widget

Another useful feature located in assessments is the previous submission widget, here are the differences between the previous submission widget and the variables:

  1. The “previous submission” variables can be printed in the PDF report while the reference widget cannot.
  2. The reference widget occupies separate lines, while the reference to previous answers with the use of our new liquid variables can be in line with other text, thus allowing the creation of sentences incorporating variables. 
  3. A great advantage of the reference widget is that it is easy to use without writing a single line of code.

Example Applications & Code snippets

Our team has created some code snippets to give you ideas on how to use variables in forms and assessments. These snippets can be copied/pasted into a text widget on your ending screen or in your automated feedback and work. 

Letter grading system

In order to create this result, you will need to deactivate the following settings in your assessment settings:

Afterward, you can use this snippet in a text widget on your ending screen.  Feel free to adjust the percentage ranges according to your needs.


{% if submission.self.score >= 0 and submission.self.score < 60 %} 

Grade: E 

{% elsif submission.self.score >= 60 and submission.self.score < 70 %}

Grade: D

{% elsif submission.self.score >= 70 and submission.self.score < 80 %}

Grade: C

{% elsif submission.self.score >=80 and submission.self.score < 90 %}

Grade: B {% elsif submission.self.score >= 90 %}

Grade: A


The result of this snippet is that the user will see a letter grade instead of a percentage on their ending screen.

GPA system 

Use this snippet in a text widget on your ending screen to show the percentage score in GPA format. You will need to deactivate the following settings in your assessment settings:

{% assign score = submission.self.score | integer | divided_by:100.0 | times: 4.0 %}

Your score is {{score}}/4.

The result in the student’s ending screen will look like this:

Speed test
In a scenario where you are interested in time spent by your user, you can disable this setting and use the snippet code in a text widget in your ending screen as shown below:

{% assign score=submission.self.score | integer %}{% assign pass_grade=submission.self.pass_grade | integer %}{% if score> pass_grade %}You passed your test in {{submission.self.time_spent_seconds}} seconds with a score of {{submission.self.score}}.

{% assign time_spent=submission.self.time_spent_seconds | integer %}

{% if time_spent <180 %}

Congratulations! That's extremely fast!

{% else %}

Congratulations on passing, but let's work on speeding up a bit.

{% endif %}

{% else %}You didn't pass. Let's try again.{% endif %}

Customize automated feedback based on the number of attempts

You might allow students to attempt an exam for a limited number of times. You could customize the feedback you display to students upon failing their second to last attempt, to encourage them to study and point them to the specific material they need to check before going for their last attempt at the exam. 

{% assign attempt_count=submission.self.attempt_count | integer %}

{% assign max_attempts_before_last=2 | integer %}

{% if  attempt_count < max_attempts_before_last %}

This is the normal question feedback.

{% else %}

This was your last try, you need to study the following sections

{% endif %}

Using the previous submission variables

For these cases, we will describe the workflow below, however, keep in mind that these are examples since the variables for “previous responses” are different for different assessments, users, and schools. Thus, the snippets used below are not universal and cannot be simply copied - pasted.

Weekly journal

Enable students to easily monitor their feelings about the course through a user-friendly weekly journal learning activity. 

You can ask students how they are feeling about taking this course on week 1 with a “Diary” learning activity:

On week 2, create another Diary activity, but this time, use variables to help the student recall their answer from the previous week and jot down how they are feeling about the course this week. 

Share your thoughts

Both previous submission widgets and variables support self-reference: this means that you can recall the student's answers as described earlier, even from previous questions in the same assessment, while they are filling it out! This way you can create a "conversation" with the user, which can be extremely powerful, especially in self-assessments.

An example could be a "Write your goals" learning activity, where you can help students detect their specific emotions regarding their course goals, which you can then review and provide personal feedback to each user.

It is recommended to paste the code snippets directly into the code editor in order to avoid any formatting issues. 

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.