Constants for reports and questionnaires

From Catglobe Wiki
Jump to: navigation, search

Constants for reports and questionnaires

One of the things that make Catglobe unique, is it's ability to reuse templates. It is possible to both create templates for reports and questionnaires and with minor additional reuse these again and again. Let us imagine that you have a standard employee satisfaction that you ask the same questions for almost every single company who carries it out. There may be a few differences, like company name in text, reference to different people, groupings of questions which are not needed to be asked, and perhaps some more advanced processes deciding what questions will be shown depending on users ongoing answers.

Instead of copying the questionnaire template each time and then changing the elements that differ, you can instead update the the template to react to values externally from the template (located on the questionnaire) or merge texts located in the questionnaire into the template. Since a template can have multiple questionnaires related, then when you need a new questionnaire, you can just add this and link it to the template, and change the elements that differ on the constants tab of the questionnaire - and with little effort - you have a completely new questionnaire in no time!

The logic is exactly the same for reports and report templates. Since you will probably also want to report on those values which were collected from the questionnaire, you will also need to create customized reports for each client. By adding possible constants to the report template and defining their values for each report, you can make sure that each report will look different. The advantages for report are although even more pronounced, since you can benefit from using constants even when you are using data from the same questionnaire.

A short example will here be given to present some ideas on how you can utilize constants for reports:

A questionnaire was asked for a company with offices in 20 cities in the same country. In order to see how each office's answers compared with the average results across all offices we can not only put a filter on the entire report (please read about advanced report setups to learn more on filters), since this will also affect the results of the 'average' calculation across offices. What we can do is make sure that a constant exists that is called office which accepts numbers. When creating a report for any of the company's offices we ensure that a constant called 'OfficeNumber' receives a number consistent with the answer option value to the question asking which office the answering user is from.

Throughout all the calculations in the report defining what the scores of an office is, we will filter the result by using the OfficeNumber constant value; e.g. like 'average (customerscore) where Office==OfficeNumber' compared with a country wide average like 'average (customerscore) where true' (wherte true means there is no filter on the calculation)!

So let us initially learn how to add constant options to a template (both questionnaire templates and report templates).

Adding constants to templates

To add constants to templates please go to questionnaire template or report template resource lists, highlight a template and click on the icon with a C.

Constants11

This will open up the constants dialogue for the template which you can see below.

Constants1

On this dialogue you can add any number of constants to your template. You must also choose what data type each constant is. There are currently 6 options:

  • Number: accepts any numeric value
  • String: accepts any string
  • Boolean: accepts true or false
  • Datetime: accepts dates or dates and times
  • Single: accepts one answer from a list of options
  • Multi: accepts one or more answers from a list of options

Notice that you cannot edit constants option when a constant value has been applied to it in a related resource.

You can set the constant to required if you want to make sure that any user adding/updating a report using the template (or questionnaire using the questionnaire template) will be required to specify a value for the constant before continuing. Finally you can provide a description to ensure that the user making a report will understand what values to put in the constant value. If a constant value must be between 0 and 10 there is no way that you can validate this is done - so the description can help the user against making such mistakes.

The up and down buttons make it possible to index the constants, so they will be shown in the same order when users have to fill values in for them. Finally the copy button allows you to copy constants from other templates. This is especially useful when you are making a report template that is the outcome of activities done in a related questionnaire template.

Copy is done by finding the template you want to copy from:

Constants 2

And then choosing which constants to copy:

Constants3

The copied constants will then be added to your list as shown below:

Constants4

Using constants inside the template editors

One thing is making the constants in relation to the template, another thing is using it. We will in this chapter explain how you can insert Constants into both report templates' and questionnaire templates' editors, and also how the diagrams of the report templates can utilize them.

To insert constants into the text of a report editor; simply place your cursor where you want the constant inserted, choose the constants button and finally insert the relevant constant.

Constants7

An inserted constant will appear as below in the text of the report (we call the small image showing the constant a 'placeholder').

Constants 8

When adding diagrams to the report you will find the same constants button on the spreadsheet tool bar. Being able to add constants into cells of spread sheets (static diagrams) enables you to affect the calculations of reports by adding external values into the results.

Constants9

Using constants inside questionnaire template editor is a bit more tricky, since the editor does not yet have an insertion feature for constants. Instead you must insert the constant into the text using CGScript. The script to use for inserting string constants is as follows {{getStringConstant("Constant name")}} where 'constant name' is to be replaced by the name you gave the constant you want to insert.

Constant5-6-2

In the same way you can use this format to get Constant values inside the Properties CGScript area. Please read more about CGScript in the help file for this. It is also possible to place constants as parts of condition expressions as in the example below.

Constant5-6-1

There is a small difference in how the format for inserting constants into conditions as opposed to placing them in the questionnaire editors text areas:

In text areas you must enclose your CGScript function in brackets as follows {{function("constant");}}. When using constants in conditions there is not a need for using brackets and semicolon.

The functions that exist for collecting constants are shown below together with the syntax you need to use.

First an example is shown of how the function should look if used inside text parts of the questionnaire. Secondly an example of how the function should look if used as part of a condition:

Boolean values: {{getBoolConstant(”ConstantName”);}} getBoolConstant(”ConstantName”)

Date values: {{getDateTimeConstant(”ConstantName”);}} getDateTimeConstant(”ConstantName”)

Multi values: {{getMultiConstant(”ConstantName”);}} getMultiConstant(”ConstantName”)

Single values: {{getSingleConstant(”ConstantName”);}} getSingleConstant(”ConstantName”)

Numeric values: {{getNumberConstant(”ConstantName”);}} getNumberConstant(”ConstantName”)

Text string values: {{getStringConstant(”ConstantName”);}} getStringConstant(”ConstantName”)

Specifying values for constants

Finally we need to specify the values that should be used for the constants for every single report using the specific template. In the below example we see how we need to specify 4 constants in order to generate the report. One of the constants is although not required. Once we have inserted the constants to the report we are ready to view it!

Constants6

Once you view any report or questionnaire, the constant place holders will be replaced with the constant value to reflect a customized view for the viewer.