An Introduction to Automation Scripts
This article details the new scripting language and interface in AskiaAnalyse which allows users to run a script that builds a portfolio.
Firstly, you'll need to ensure you're on the latest version of AskiaAnalyse 5.5.3 for all discussed functionality and examples to work.
There is a new top menu, 'Automation', where we open the new script interface:
To see which keywords are applicable to this new scripting language please review the summary tables in our AskiaAnalyse Script Appendix. (See columns named 'Automation scripts').
The idea when writing a script is that each script is generic i.e. there should be no references to shortcut names. Instead we use:
1. Various keywords to identify different types of questions e.g.
IsCalculated - isolates Calculated questions
IsCoding - isolates grouped response, grouped value and change level questions:
IsDeveloped - isolates all developed questions in a loop:
IsVisibleDuringDataEntry - isolates all questions which have the option 'Visible during data entry' selected in AskiaDesign:
'Type' of the variable - isolates questions by their type e.g. . .
myQuestion.Type = "chapter"
2. 'Tags' Defined in askia Design to classify groups of questions or responses for particular analysis
Tag menus in askia Design:
Questions and Responses are permitted to have multiple tags assigned to them:
You can also set a tag to several questions or responses in one go as shown below:
For the purposes of introducing Automation Scripts, shortcut names are included in one or two of the simplest examples (solely for ease of explanation) before going on to talk about tags and question types.
The examples in this article can be tested on the .QES file here. It has all the question types and tags required to run the example scripts and demonstrate the functionality. In order to run the the same scripts on your data files, you'll need to add tags to your .QES or .QEW. If the tags you add have different names, you'll need to update tag references in the scripts provided.
Remember that all these examples can be run from the command line using the /"automate:" parameter e.g. . .
Analyse.exe "c:\Qes\ex.qes" /"automate:c:\Scripts\myScript.txt"
To use any of the examples, click on the screenshot to download the script in a .txt file. Then in AskiaAnalyse, go to the Automation menu > Open and select the file.
- Add one question to rows and columns
- Add a chapter to the portfolio first, then add the above tab definition to it
- Add two empty tab definitions in each of two chapters
- Add ten empty tab definitions in each of eight chapters using for-loops
- Add all questions containing data to the rows of a single tab definition i.e. create a simple hole-count
- Use tags to add the demographics questions to the rows
- Deselect Responses for Profile Questions
- Add Questions With Specific Responses & Reorder Responses
- Update settings in the General tab of an existing portfolio and save it as a new portfolio
- Create a new sub-population & select specific developed questions
- Add groups, calculated responses and scaled values using clones
- Adding groups and calculated responses using script
- Creating summary tables for all loops in your data file
Example 1 - Add one question to rows and columns.
Example 2 - Add a chapter to the portfolio first, then add the above tab definition to it.
Example 3 - Add two empty tab definitions in each of two chapters.
Example 4 - Add ten empty tab definitions in each of eight chapters using for-loops.
Example 5 - Add all questions containing data to the rows of a single tab definition i.e. create a simple hole-count.
Example 6 - Use tags to add the demographics questions to the rows.
Example 7 - Deselect responses of questions added by tag to a profile.
Example 8 - Reorder responses and add questions with specific responses to rows.
Example 9 - Update settings in the General tab of an existing portfolio and save it as a new portfolio.
N.B. We loop through portfolio.items so we can apply the required settings to every tab definition in the portfolio.
Existing portfolio vs updated portfolio:
Click on the 'Existing portfolio' image to download the xml.
Example 10 - A more complex scenario with multiple automated tasks.
- Create a new sub-population from scratch and apply it to your tab definitions.
- Use chained / nested tags to select specific developed questions from your loops to your rows.
- Add all non-numeric Demographics questions to your columns.
Example 11 - Add groups, calculated responses and scaled values using clones:
We check which question shortcut falls into which tag category; NPS, 5pt scale or 7pt scale. Then we apply the correct clone to all filtered questions and put them in the rows. Click on the screenshot below to download all the clones (and the .QES file used to create them).
Example 12 - Adding groups and calculated responses using script.
Click the animation below to download both example script files that have been demonstrated.
Example 13 - Creating summary tables for all loops in your data file.
- The child question of the loop goes in the rows.
- The next parent (loop) variable goes in the columns.
- All remaining parent (loop) variables go in the edges.
- Apply a global tab template which has the 'Nest edges' options selected for loops of three or more parent levels.