Sample Exercise for Repeat Loops

Sample Exercise: Repeat Loops

 

This exercise was designed to teach you the basics of repeat loops in A2J Author, creating both an A2J Guided Interview and an A2J Text Template.

 

There are two components to a completely automated document - the A2J Guided Interview which interacts with the end user and asks them questions, and the A2J Text Template, which creates the actual document for the end user.

 

A2J Guided Interview

 

We are first going to create an A2J Guided Interview that will be paired with your A2J Template. For the purposes of this Sample Exercise, the interview will be fairly short.

 

  1. Log into your www.a2jauthor.org account. If you aren’t sure how to create an account, check out this resource.

  2. Once logged in, go to the “Author” tab and click it. Home page.png

  3. Then click “Run A2J Author”.

  4. A2J Author will open on the “Interviews” Tab. Under “Create a new interview” double click on “Blank Interview.” This will open up a blank A2J Guided Interview. To learn more about authoring in A2J Author 6.0, check out our Authoring Guide.

  5. Go to the About tab and change the title of your interview to Sample Exercise: Repeat Loops. You can select any guide avatar options to customize the Guide avatar. You should also click over to the Author tab inside the About tab in order to add your information as the author of this interview.

  6. A new A2J Guided Interview comes pre-populated with 4 questions. We’re going to have a total of 9 questions in this interview. Click the New Page button New page button.pngat the top of the screen 5 times. Your screen should something look like this:

  7. Now we’re going to create the Steps that will organize our questions. Go to the Steps Tab. By default, there are 4 steps in each A2J Guided Interview. That is all that we will need for this Sample Exercise. Rename the steps as follows:

    1. Step 0 : Introduction

    2. Step 1: Ask for Number First

    3. Step 2: Ask to Add More

    4. Step 3: The End

It should look like this:

  1. Go to the Variables tab and create the following variables.

    1. Asset value TE; type: number; repeating: yes (Check the box next to “Check if multiple values”)

    2. AssetCount; type: number; repeating: no

    3. Asset name TE; type: text; repeating: yes

    4. Child birth date DA; type: date; repeating: yes

    5. Child name first TE; type: text; repeating: yes

    6. ChildCount; type: number; repeating: no

    7. Have assets TF; type: true false; repeating: no

    8. Have children TF; type: true false; repeating: no

    9. Number of children NU; type: number; repeating: no

  2. Go back to the Pages tab. Double click on 1-Introduction.

    1. Rename it 1-Name and Gender

    2. Question text: Welcome to the sample A2J Guided Interview for Repeat Loops. Please enter your name and gender.

    3. Create two fields.

      1. Field 1-Type: Text; Label: Name; Variable: Client first name TE

      2. Field 2 - Type: Gender; Label: Gender; Variable:User Gender

    4. Don’t worry about the button for now. The Continue label is sufficient and we will update the destinations at the end of this section.

  3. Double click on 2-Name. Change the question name to 2-Have children?

    1. Question text: Do you have any children?

    2. Delete the 3 fields in the question. You won’t need them.

    3. Scroll down to the Buttons section and create 1 additional button (by default all questions come with 1 button).

      1. Button 1- Label: Yes; Variable: Have children TF; Default value: true

      2. Button 2 - Label: No; Variable: Have children TF; Default value: false

  4. Double click on 3-Gender. Change the question step to Step 1; change the page name to 1-How Many Children?

    1. Question text: How many children do you have?

    2. Go to the 1 existing field and make the following changes:

      1. Field type: Number (Pick from list)

      2. Label: none

      3. Variable: Number of children NU

      4. Required: yes

      5. Min Value: 1

      6. Max Value: 9 (the min and max create the list of options that the end user can pick from)

    3. Go to the Buttons section (this is where we will initialize the counting variable to be used in the repeat loop about the user’s children)

      1. Label: Continue

      2. Repeat options: Set Counting Variable to 1

      3. Counting Variable: ChildCount

  1. Double click on 1-Question 1in Step 1. Change the name to 2-Child’s name.

    1. Question text: What is the name of the %%ordinal([ChildCount])%% child?

      1. This will display the ordinal version of the counting variable. Ex. What is the name of your 8th child?

    2. Create 1 field.

      1. Field- Type: Text; Label: First name:; Variable: Child first name TE; check the “Required” box.

  2. Double click on a new question page. Change the Step to Step 1. Change the question name to 3-Child’s birthdate.

    1. Question text: What is %%[Child name first TE#ChildCount]%%’s date of birth?

      1. This macro will call out the name the user just gave you in 2-Child’s name.

    2. Create 1 field.

      1. Field- Type: Date MM/DD/YYYY; Label: Birth date:; Variable: Child birth date DA; Check the required box.

    3. Go to the Buttons section

      1. Label: Continue

      2. Repeat Options: Increment Counting Variable

      3. Counting Variable: ChildCount

    4. Go to the Advanced Logic section, the After box. Type the following logic statement into that box (make sure to type it in, not copy and paste).

  1. Double click on a new question page. Change the Step to Step 2. Change the name to 1-Do you have any?

    1. Question text: Do you have any assets over $100?

    2. Create two buttons.

      1. Button 1- Label:Yes; Variable: Have assets TF; Default value: true

        • Repeat Options: Set Counting Variable to 1

        • Counting Variable: AssetCount

      2. Button 2- Label: No; Variable: Have assets TF; Default value: false

    3. Advanced logic-Before section: SET [ChildCount] to [Number of children NU]

      1. This will lock the child count to the number of children, now that the end user has completed the repeat loop about children.

  2. Double click on a new question page. Change the Step to Step 2. Change the name to 2-Assets name.

    1. Question text: What is your %%ordinal([AssetCount])%% asset over $100 and the estimated value?

    2. Create two fields.

      1. Field 1- Type: Text; Label: Asset name; Variable: Asset name TE

      2. Field 2- Type: Number Dollar; Label: Value; Variable: Arrest no charges TF; Default value: true

  3. Double click on a new question page. Change the Step to Step 2. Change the name to 3-Any more?

    1. Question text: Do you have another asset over $100 to add?

    2. Learn More prompt: What assets have I told you about already?

    3. Help: You’ve told me about your %%[Asset name TE]%%.

    4. Create two buttons.

      1. Button 1- Label: Yes; Repeat Options: Increment Counting Variable; Counting Variable: AssetCount

      2. Button 2- Label: No

  4. Double click on the final new question page. Change the Step to Step 3. Change the name to 1-All done

    1. Question text: The end!

    2. Button 1- Label: Get my document

      1. Destination: [Assemble - Generate PDF document]

  5. Now that we have created all of our questions, we need to connect them to one another.

    1. Open up each question and go to the Buttons section. The questions should be connected through the Destination option as follows. Change any that are not connected this way.

      1. 1-Name and Gender to 2-Have children?

      2. 2-Have children? (yes button) to 1-How Many Children?

      3. 2-Have children? (no button) to 1-Do you have any?

      4. 1-How Many Children? To 2-Child’s name

      5. 2-Child’s name to 3-Child’s birthdate

      6. 3-Child’s birthdate to 1-Do you have any?

      7. 1-Do you have any? (yes) to 2-Asset name

      8. 1-Do you have any? (no) to 1-All done

      9. 2-Asset name to 3-Any more?

      10. 3-Any more? (yes) to 2-Asset name

      11. 3-Any more? (no) to 1-All done

      12. 1-All done to [Assemble - Generate PDF Document]

  6. Go back to the Steps tab and ensure that your Starting Point question is set to 1-Name and Gender. When we changed 1-Introduction’s name, A2J Author may have gotten confused. If it’s not 1-Name and Gender, click the “Set Start Point” button and a list of your questions will appear. Pick 1-Name and Gender. ​​​​​​​

 

A2J DAT Text Template

 

Now we’re going to create the A2J DAT Text Template that will create the document for your end user.

  1. Go to the Templates tab. Click the “Create Text Template” button in the top right hand corner. It will take you into the Text Template tool.

  2. Name your template. In the “Untitled Template” field in the top panel, delete “Untitled Template” and type in “Simple Template with three elements”. Your template is automatically saved every 5 minutes, but it doesn’t hurt to hit the “Save Template” button every so often, particularly after making several changes.

  3. Now we will create a rich text element. That will be assembled for everyone, regardless of their answers for the children and asset repeat loops. Click the “Rich Text” button in the “Add Elements” section to the right of the screen. This will add a text editor box to the template.

  4. Click into the text editor and type: This document was created by a template within A2J Author as part of a sample exercise to learn how to create repeat loops. The two repeat loops deal with children and assets. If the user does not have children or assets over $100, this is all that will print on the form. If the user does have children, a section with their names and birthdates will appear. If the user does have assets over $100, a list of those assets will appear. The user said that their name was:

    1. After the word “was:” in the last sentence we want to insert the variable for the user’s first name. To do so, click the [P] button in the editor and select the variable [Client first name TE]. A2J Author will then insert that variable’s value into the assembled document. Hit “Save & Close” in the box labeled “Text” next to the editor to close the rich text element. The following gif demonstrates the insertion of a variable.

  1. Now we’re going to add the first IF/Else element and repeat loop. Click the “If/Else” button in the Add Elements section. In the blank field above “is true” start typing Have children TF. A2J Author should give you a list of variables that match the characters you typed to select from. Pick Have children TF. Leave “is true” in the field below it. This is the conditional statement that A2J Author will test against in order to insert the information about the children repeat loop.

  2. Click into the “Add elements here” field within the If/Else element. Add a Repeat Loop. See the following gif for steps 5 and 6.

  3. These are the default repeat loop options.

  4. We’re going to have to make the following changes. Make your element look like this one:

  1. When your element looks like the one above, hit the “Save & Close” button. We’re going to duplicate the above steps for the asset repeat loop.

  2. Add an If/Else element. The condition is if Have assets TF is true.

  1. Add a repeat loop element to the If/Else element.

  1. Make your repeat loop element match the following:

The tricky part is to switch the repeat display from table to list. See the following gif.

  1. When you’ve matched your element to the one above, hit “Save & Close”. You’ve completed your template!

  2. Now that we have created both the interview and the template, we need to test our complete A2J Guided Interview. Go back to the Pages tab.

    1. Open 1-Name and Gender. Click Preview Preview button.png and open the Variables/Script window Variables_script button in preview.png

    2. Go through your A2J Guided Interview and make sure that all of your variables populate and that your advanced logic works properly.

      1. When you get to the end, don’t click the “Get my document” button. When you’re in Preview Mode, A2J Templates don’t assemble. Go to the Variables Box and click “Save”. This will download your answer file.

  1. Go to the Template Tab and click “Test Assemble” button . It’ll prompt you to load the answer file that you saved in the step above. Once it’s loaded, click “Get PDF”.

  2. Congratulations! You’ve successfully created your A2J Guided Interview and A2J DAT PDF Template. It should look like this when Test Assembled:

 

 

If you have any questions, feel free to reach out to A2J Author’s Project Manager Jessica Frank (jessica@cali.org).

 

You can find the completed A2J Guided Interview for this exercise here

You can find a sample answer file here.