Logic Dictionary: Difference between revisions
(New page: This page includes a basic break down of all the different logic commands available in the authoring tool along with basic examples to illustrate. Key Commands (text in red) and Commands ...) |
No edit summary |
||
Line 208: | Line 208: | ||
== <code> to </code> == | == <code> to </code> == | ||
The <code>to</code> key command is used with <code>set</code> key command to set variables. | The <code>to</code> key command is used with the <code>set</code> key command to set variables. | ||
== <code> value </code> == | == <code> value </code> == | ||
Line 217: | Line 217: | ||
The <code>add</code> command is used when performing calculations in the logic. This may also be written as <code>sum</code> or <code>+</code>). | The <code>add</code> command is used when performing calculations in the logic. This may also be written as <code>sum</code> or <code>+</code>). | ||
'''Example 1''' | |||
This can be used to perform a calculation using the end-user's responses to specific numeric value interactions: | |||
<code>set score1 to add (page1.interaction1, page1.interaction2, page1.interaction3)</code> | |||
'''Example 2''' | |||
The <code>add</code> or <code>sum</code> commands can also be used to calculate variables that have been set earlier in the session: | |||
<code>set overallscore to sum (score1, score2, score3)</code> | |||
== <code> and </code> == | == <code> and </code> == |
Revision as of 13:21, 17 September 2010
This page includes a basic break down of all the different logic commands available in the authoring tool along with basic examples to illustrate.
Key Commands (text in red) and Commands (text in pink) should be written as they appear in the examples.
Key commands (red)
after
The after
key command is used after a page to perform functions that relate to that page.
The most common way of user the after key command is with the if
and goto
key commands in the following formula:
show page1
after page1 if (any commands you want to relate to this page) goto page2
Example
after page1 if (any functions you want to relate to this page) goto page2
Note: the after
key command is also used at the end of the logic formula for save
and graph
begin
The begin
key command is always used with the end
key command
If your intervention has separate sessions or groups (e.g. different weekly sessions in your behavioural intervention, or a different set of pages for different user groups) then splitting your pages into sections can make it easier for you to organise parts of your intervention and find sections easily.
Things to remember when splitting you intervention into sections:
- If you begin a section, you should always end the section.
- All the logic related to the section must be between begin sectionname and end
- The name of the section should not be the same as any unique name that has been given to an object or page in your intervention.
- As you can only ever end the section that you are currently in you do not need to write the section name after end.
Example 1
begin session1
show page1
show page2
end
This will begin session1, show page1 and page2, and will end session1. All the pages related to session1 (page1 and page2) are between begin session1 and end.
Example 2 – Beginning and ending a section within another section
begin stress
begin causes
show page1
show page2
end
begin relieve
show page3
show page4
end
end
This will begin the section stress. The section causes will then begin and page1 and page2 in the section causes will be shown. he first end will end the section causes. The section relieve will then begin and page3 and page4 will be shown. The next end will end the section relieve. The final end will end the section stress.
default
end
See begin
for
The for
key command is used with the save
and graph
key commands.
goto
The goto
key command always follows the after
key command. See above.
graph
The graph
key command is used when you have used the graph interaction. It is used to plot the information given by end-users to the graph.
This key command always follows the same formula and requires users to set up a user account.
graph value to "data variable determined on the graph interact" for unique identifier for the end-user e.g. username after the page that the value has been generated from
Another line of logic is then needed for the page where the graph occurs. This will also always follow the same formula:
set pagename.graph-1 to graph "data variable determined on the graph interact" for username
Here, pagename.graph-1 is the automatically generated name of the graph that has been put on the page where the graph occurs.
Example1
In this example the number entered in the interaction ‘kg’ on the page ‘progresschart’ will be used as the data for the “weight” variable for the graph. The variable username has been set earlier in the logic as the unique identifier for the end-user (see the set
key command for more information).
show progresschart
graph progresschart.kg to "weight" for username after progresschart
Later in the logic the following line is needed after the page where the graph occurs:
show weightgraph
set weightgraph.graph-1 to graph "weight" for username
A full tutorial for using graphs will soon be available.
if
The if
key command is always used with the set
or after
key commands.
load
named
Use this key command to re-show a page you have already shown.
For example, if you had a page that you need to keep showing back to your users you could use the named
key command as so (note that in the example below the line [etc, etc] has been used to indicate that there would be other lines of logic here).
Example
show page1
[etc, etc]
show page1 named page2
[etc, etc]
show page1 named page3
of
save
saveandload
set
The set
key command can be used to set variables within the logic or for performing calculations.
Example 1
The most common use of setting variables will be to set a username for the user. Many of the logic commands such as save
will need a username to be set. This will need to be done at the start of your logic file.
Set username to login.loginuname
This will set the variable username to whatever the end-user enters into the interaction uniquely named loginuname on the login page. The word username can then be used any time throughout the logic to mean whatever the person entered in that interaction.
Example 2
The set
key command can also be used to set a variable based on how end-users respond to certain interactions. This can then be used to tailor the intervention based on this variable.
show page1
set condition1 to and (page1.chooseoptions contains "optiona", page1.chooseoptions contains "optiond")
after page1 if condition1 goto page3
So in example 2, the variable ‘condition1’ is set if end-users select options a and d from the interaction ‘chooseoptions’ on page1. Then those that are in this condition are sent to page 3 where they will receive tailored information based on the options they selected.
Example 3
In this example, the set
key command is used to set a score based on the calculation that follows. In this calculation the number that the end-user selects in the interaction ‘dailyexercise’ on page1 is multiplied by 5 to create their exercise score
set exercisescore to (page1.dailyexercise * 5)
show
The show
key command is the first and most important logic command you will need to know. It is also probably the most common one that you will use.
This key command shows each of the pages that you have created. Pages will be shown in the order they are mentioned in the logic. When an end-user clicks on a Next button on a page, they will be moved to the next page written in the logic.
Example 1
show page1
show page2
show page3
show page4
In the example above the end-user will first be presented with the page uniquely named ‘page1’. Then, when they click on the next button on page1 they will see the page called ‘page2’. This is followed by ‘page3’ and finally ‘page4’.
Note: Before you can preview your intervention you will need to have the show key command in the logic file for each page you want to view.
As the logic requires you to use unique names for each page in your logic, you can only use the show key command once for each page. However, see the named
key command above for how to re-show the same page to users.
You can also reshow pages to your end-user by using a jump button on a previous page.
then
to
The to
key command is used with the set
key command to set variables.
value
Commands (pink)
add
The add
command is used when performing calculations in the logic. This may also be written as sum
or +
).
Example 1
This can be used to perform a calculation using the end-user's responses to specific numeric value interactions:
set score1 to add (page1.interaction1, page1.interaction2, page1.interaction3)
Example 2
The add
or sum
commands can also be used to calculate variables that have been set earlier in the session:
set overallscore to sum (score1, score2, score3)
and
The and
command can be used for a number of reasons:
- . if there is more than one response that is involved in presenting tailored advice to end-users, i.e. if one response and another response is needed to show feedback to an end-user.
- . if you need to perform a number of logic commands after a page
Example 1
show page6 if (and(page3.exercise = yes, page3.intensity = moderate, page3.frequency = three)
End-users will be shown pagename6 if they selected yes to the interaction exercise on page3, moderate to the interaction intensity on page3 and three to the interaction frequency on page3.
Example 2
append
The append
command allows you to attach strings of logic together or to attach a variable within a string.
Example 1
In this example the append function is used to attach a person's username (which has been set in a previous part of the logic) to the text used in an email message:
after login if sendemail ("welcomeemail", login.uname, "Welcome to the lifestyle study", append ("Thank you for registering for the study", username, "remember to chart your progress everyday"), 60) goto page1
authenticateuser
This is important logic for ensuring that a user is registered with the intervention and is usually found after the login page of an intervention.
The authenticateuser
command can be used in the logic (intervention.lgil) file or in the error message logic.
cancelemail
This command is used to cancel an email that has already been set up earlier on in the logic. For example if you set up e-mail reminders for people to login to upcoming sessions in the intervention then you will need to then cancel them if they subsequently login before the e-mail is due to be sent out.
This command uses the same basic formula:
after pagename if cancelemail ("unique name for email", e-mail address) goto nextpage
Example
after session2welcome if cancelemail ("session 2 reminder", login.email) goto session2page1
cancelsms
This command cancels an SMS message that has already been set up earlier on in the logic.
It uses the same basic formula that is used for cancelling emails except it uses the cancelsms
command:
after pagename if cancelsms ("unique name for email", e-mail address) goto nextpage
changepassword
This command enables users to change their password. The formula for using this command would be:
after pagename1 if changepassword (username, pagename1.name_of_interaction_for_entering_old_password, pagename1.name_of_interaction_for_entering_new_password) goto pagename2
Example
after passworddetails if changepassword (username, passworddetails.old, passworddetails.new) goto confirmchange
checkemailvalidity
Checks that the e-mail that a user has entered is valid (i.e. contains an @ symbol).
checkphonenumbervalidity
checkuserenabled
checkuserexists
comparetimes
contains
countif
currenttime
divide
hasseen
hasseen
is used to show end-users pages based on what they have or have not seen before.
Example 1
If you wanted to show end-users a different page each time they logged in depending on what sessions they had seen before you may use the hasseen command like so:
show login
show s1welcome if (not(hasseen (username, "s1welcome")))
show s2welcome if (not(hasseen (username, "s2welcome")))
show s3welcome if (not(hasseen (usernme, "s3welcome")))
This would mean that the first time they login they would see the session 1 welcome page which is labelled s1welcome. The next time they log in, because they have already seen the s1welcome page the logic will skip that line of logic and show them s2welcome because they have not yet seen the s2welcome page.
isempty
or
lessthan
This command can be used when performing calculations in the logic to check if one value is lower than another. The symbol <
can also be used.
lessthanequal
This command can be used when performing calculations in the logic to check if one value is lower than or equal to another. The symbol <=
can also be used.
loadvalue
makenewuser
The makenewuser
is very important; it is used to set up an account for the user using a username (or e-mail address) and password.
Example
show signup
after signup if (makenewuser(signup.signup_username, signup.signup_password)) goto thankyou
So in the example above the information that the end-user enters into the interactions 'signup_username' and 'signup_password' is used to create a user account.
morethan
morethanequal
multiply
not
patternmatch
printtime
The printtime
converts a value from a number to a string
randomnumber
This command allows you to randomise your users into different groups.
replaceall
This command can be used to do text replacements inside a string.
Example
In the following example the replaceall
command is used to replace all the 'a's in a string to 'b's. So this would change 'I like apples a lot' to 'I like bpples b lot'
replaceall ("a", "b", "I like apples a lot")
resetpassword
savevalue
sendemail
sendtext
size
stringlength
sum
timesincelogin