Variables in template builder

Dear friends
I need to list the whole team involved in a class in reports. We have two tutors, sometimes two assistant tutors etc.
In the student info bit of the template builder only the main tutor is listed. The code in the template is:
{% set tutor = tutors|first %}
{{ tutor.title }} {{ tutor.preferredName|first }}. {{ tutor.surname }}

Can somebody help me with the right code for listing the other tutors etc. Note that this code says “tutors|FIRST”, “tutors |SECOND” does not work and I am very good at coding. So I need to know which variables would work, if any.

Any help is very much appreciated

@pllabreu try check available data using the “debug mode” in reports and under generate reports for individual students use the “inspect” action. You will see the array of tutors where you can loop through the array displaying the tutors you want in your template builder prototyped component.


1 Like

Hi @pllabreu

No problem, here is an example of the template code that would help you loop through and display all the tutors in a comma separated list

{% for tutor in tutors %}
    {{- tutor.title }} {{ tutor.preferredName|first }}. {{ tutor.surname -}}
    {{ not loop.last ? ', ' }}
{% endfor %}

Also, if you want the tutor’s full preferred name rather than the first letter, change {{ tutor.preferredName|first }} into {{ tutor.preferredName }}

Hope this helps!

1 Like

Dear Sandra, Thanks a million!

1 Like