Updates from Belen Toggle Comment Threads | Keyboard Shortcuts

  • Belen 3:33 am on December 15, 2021 Permalink  

    Feature update – Using the keyword *for to iterate through the elements of a list 


    Going through the elements in a collection or association is now easier than ever! These examples will guide you in using the *for keyword:


    Looping through the elements in a collection


    >> farmAnimals = ["dog", "pig", "goat"]
    *for: animal in farmAnimals
    	There is a {animal} on the farm!
    

    The code indented under the *for keyword will be executed as many times as elements there are in the collection farmAnimals (3 in the example). On each iteration, animal will be the element on the position of the current iteration. 

    The output of the code above is:

     There is a dog on the farm!

     There is a pig on the farm!

     There is a goat on the farm!

     

    Retrieving both the elements and their position inside a collection


    In the previous example we generated a variable (animal) that, on each iteration, was set to the element in that position. But there may be cases where you want to store also the iteration number. Look at the example below:
    >> highestPeaks = ["Everest", "K2", "Kangchenjunga"]
    
    Here are the highest mountains on Earth:
    *for: index, name in highestPeaks
    	{index}. {name}

    The *for loop will go through the collection highestPeaks, setting index to the iteration number and name to the element in that position. This is what the output looks like:

     Here are the highest mountains on Earth:

     1. Everest

     2. K2

     3. Kangchenjunga


    In summary, when you are using *for to loop through the elements of a collection, you can either retrieve each of the elements in it using the syntax *for: element in collection or both the element and its position if you write *for: position, element in collection.

     

    Looping through associations


    In this example, my friend’s birthdays are stored in an association. The key of each element is my friend’s name, and the value is the date that they were born:
    >> friendsBirthdays = {"Justin" -> "March 1, 1994", "Kim" -> "October 21, 1980", "Taylor" -> "December 13, 1989", "Beyonce" -> "September 4, 1981", "Michael" -> "August 29, 1958"}
    
    *header: My friend's birthdays
    *for: name, date in friendsBirthdays
    	{name} was born on {date}
    

    Alternatively, you may only want to get the value of each element, without the key. Here is how you can do that:
    >> potluckSignup = {"Peter" -> "Deviled eggs", "Joan" -> "Hummus and carrots", "Kelly" -> "Cookies", "Andrew" -> "Pico de gallo"}
    
    *header: Potluck dishes
    *for: dish in potluckSignup
    	- {dish}
    

     

    Generate multiple pages using a *for loop


    Suppose you have a program where the user has been asked to enter their favorite restaurants, which are stored in the collection favRestaurants. The code below will generate as many questions as restaurants they entered:
    *for: restaurant in favRestaurant
    	*question: What is your favorite food at {restaurant}? 
    

     

    Loop through characters in a text variable


    The *for keyword also allows you to go through all the characters in a string. For example, this is program displays a text variable called word letter by letter:
    *for: character in word
    	*clear
    	*header: {character}
    	*wait: 2.seconds
    

    You could also retrieve the position of each character as well:
    *question: Enter a word and I will spell it out for you!
    	*save: word
    
    *for: index, char in word
    	*clear
    	*header: The letter in position {index} is {char}
    	*wait: 2.seconds
    
     
  • Belen 12:37 pm on November 6, 2021 Permalink  

    Feature update – Two-factor authentication and new documentation site 

    Here’s what’s new:

    Two factor authentication


    Now you can enable two-factor authentication (2FA) on your GuidedTrack account. This will add an extra security layer to protect the code of your programs and the data your users generate.

    In order to do so, you’ll need to access your Profile page:


    Once there, go to your Account tab and you will find the button to enable two-factor authentication under Security.

    You need to have an authentication app on your phone or tablet. If you need to install one, we recommend Authy, 1Password or LastPass Authenticator.

    Follow the instructions on the screen to:
    • copy or print the recovery code and store it somewhere that’s safe where it can’t get taken or lost.
    • scan the QR code with your device,
    • and finalize the setup by entering the numeric code generated by the app.
    After enabling two-factor authentication, you will be prompted to enter the code generated by the app in addition to your username and password every time you log into GuidedTrack from a new browser or device.
     

    Revamped documentation


    GuidedTrack’s documentation is now in https://docs.guidedtrack.com

    You can find it too clicking on Help -> Manual on GuidedTrack’s navigation bar, and the Search Bar results of the type “Help” are now linking to this site.

    This new site has a search engine and is much faster to load and more pleasant to read and use that the document we were using before.

    It has three sections:
    • The GuidedTrack Manual, with detailed explanations of all the GuidedTrack features and lots of code snippets you can easily copy and paste into your own program.
    • The Research Guide, which contains tips on how to design user-friendly studies, how to recruit, screen and reimburse study participants and how to share participant data across different platforms. You will also find code samples that you can customize to meet the needs of your survey.
    • The Function and Keyword API, a quick guide with the syntax and examples for every function an keyword in GuidedTrack.
     
  • Belen 9:40 am on September 20, 2021 Permalink  

    Feature update – Locally scoped data for components and program templates 

    Locally scoped data for *components


    This new functionality allows you to create similar buttons with different click handlers on the same page. Let’s demonstrate how it works by looking at an example!

    Suppose you have a collections of associations, each association contains the name and age of all your friends:
    >> people = [{"name" -> "Peter", "age" -> 24}, {"name" -> "Josh", "age" -> 37}]
    
    The size of this collection can change, as you have a module in your program to add or remove friends.

    You can dynamically generate the components using the following code:
    *for: person in people
    	*component
    		*header: {person["name"]}
    
    
    On each iteration of the *for loop, we retrieve an element from the list of friends (the association of data about a person), save it into the variable person and generate a component that displays the value of the key “name” for that association.

    Now let’s make these components clickable! Since the code under *click gets executed only when the user of your program clicks on a component in particular, we use the following syntax to be able to retrieve each person’s data:
    *label: people
    *for: person in people
    	*component
    		*header: {person["name"]}
    		*with: person
    		*click
    			Name: {it["name"]}
    			Age: {it["age"]}
    			*button: Back
    			*goto: people
    
    
    We use the keyword *with to tell GuidedTrack what variable it needs to store for when the user clicks on the component being generated. We can use any type of variable: in this case, person is an association. Afterward we access that data in the code indented under *click by invoking it, as shown on the example. 

    Note that you cannot access the name of the person whose component you have clicked using Name: {person["name"]} because, as mentioned before, the code under *click gets executed when the user clicks on the component. This can only happen after all the components have been rendered, so person by then will contain the data of the last person in the collection of friends (since that is what person ends being assigned to in the last iteration of the loop).
     

    Use a template to create a program


    You may have already noticed that, when creating a new program, you are given the option to start from scratch or use a template:


    If you choose a template, the program you create is preloaded with a fully functional program. You can run/preview it as soon as it is created to evaluate what changes you need to make to the template to meet your needs. You will also notice that the code of the template has a lot of comment lines which should make it easy for you to adapt the template.
     
     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel