Category:Updating and Automation

From Q
Jump to navigation Jump to search

Although Q has a very powerful scripting language, most common objectives that users have when they automate are better addressed using the many automation tools built into Q.

Automatic updating tools

Multiple selection

In various parts of Q it is possible to simultaneously change multiple things at the same time. For example:


Merging projects

Where multiple researchers have been working on the same data file, the data and outputs in the Q projects can be combined by dragging and dropping (see Merging Projects).


Find Replace gives a high level of control about both where it searches and replaces and also about how to perform the search and replace. For example, you can:

  • Use wildcards (e.g., have Q replace all text that starts with Please rate your).
  • Use it to modify Expressions in JavaScript Variables.

Replication/Templating tools

  • Where there are many similar questions in a project, and there is a need to modify each in the same way (e.g., merging together top 2 boxes and setting Don't Know as Missing Data), you can do this by:
    1. Creating a table of the question, and modifying it as per your needs.
    2. Automate > Online Library > Modifying Data - Use a Question as a Template for Modifying Other Questions.
  • Where there is a need to create many similar JavaScript Variables, this can be done by first creating one variable, and then having Q automatically reproduce and modify this variable (see Use as Template for Replication).
  • Charts can be saved as templates using View > Save as Template and reapplied to other charts in this and other projects using the View > Show Data as drop-down menu at the top of the screen.
  • If exporting to Microsoft Office:
    • Q can export using Microsoft Chart Templates.
    • Q also automatically uses the page layout and theme settings within PowerPoint presentations (see Exporting to PowerPoint).
    • Q allows you to select the Table style to use when exporting to Excel.

Rules and QScripts in the Online Library

Many things that users need to automate have already been automated in the form of Rules and QScripts, and can be found by selecting Automate > Online Library and searching for whatever is of interest.

Writing code (JavaScript)

In addition to its use for creating variables from within the Variables and Questions tab (see Creating New Variables), JavaScript can be used to:

  • Automate the setup or modification of a project. For example, automatically create new variables, import data files, create tables, etc. JavaScript written for this purpose is referred to in Q as QScript. It is essentially equivalent to the idea of a Macro in Excel. Many QScripts have been created in the Online Library, and you can tailor them to your own purposes.
  • Customizing tables and charts. For example, conditional formatting rules, modifying how significance tests are performed, etc. JavaScript written for this purpose is referred to as Table JavaScript and Plot JavaScript. Table JavaScript and Plot JavaScript is principally used for the creation of Rules. As with QScripts, many Rules are available from within the Online Library and you can use these or customize them as per your needs.
  • Automating uploading of projects for online reporting (i.e., the API) - see Q API.