Accessing Survey Content
There are two main approaches that can be used to retrieve Survey content, for example questions, ids, answers, texts etc. when scripting in Reportal:
- Access the Report’s data source,
- Access a Project’s definition.
In addition it is possible to access tables in Database Designer.
Methods
report.DataSource - provides access to the project(s) defined in the Report’s data source. The input parameter is the data source nodeid(s).
confirmit.GetProject - provides access to a project by using the Project Id as input to the GetProject method.
confirmit.GetDBDesignerSchema - by using the schemaid as input to the GetDBDesignerSchema you can access information in Database Designer tables. The content of Database Designer tables can be used to mask or populate dynamic lists, or control access to various components of your report.
Guidelines
The parameter type Project in Reportal allows you to use projects that are not in the Reportal data source . This may be useful if you have a portal that is used for new projects that are added on a regular basis. In this case there are three things you must do:
- Add projects to the domain of a project parameter from the parameter domain script.
- Grant users access to "your" (report designer's) projects.
- Explicitly grant access to projects from the report permission script.
When granting users access to your projects, it is important that sufficient access measures are included in the permission script to avoid unintentional access to variables in the projects that are available from the code.
Question Categories
To combine multiple questions in a project into different categories, each question in a survey can be defined to belong to one or more Question Categories. The Question Category can be used to display the questions in a drop-down menu, grouped by the defined Category, as shown in the example - . Note that this is a way to group your questions by category, and no calculations will be applied to your questions by category.
Figure 1 - Example of the Question Category drop-down
To set this up, you must first create a resource survey which will hold the question categories. Proceed as follows:
- Create a project in Professional Authoring, and insert a single question type which can be called Categories.
- Enter the different categories in the Answers tab - .
- Under Question Properties for your Grid, Multi or Single question, you have a Question Category field. Enter into this field the code of the Category to which the question is to belong - . Note that if a question is to belong to several categories, you must enter the codes separated by semi-colons. Ensure there are no spaces between the categories and semi-colons.
- Create a parameter in the Report toolbox, and name it for example p_category - .
- Under Properties, set the Type to Fixed Questionnaire Element - .
- Right-click on the p_category element and select Script. Enter a customized script based on the following - :
- Drag the p_category parameter to the List object - .
- Right-click on the List object, and select Properties, then set up the properties as required - .
Figure 2 - The Resource survey
When the resource survey is in place, you can define in your projects which category the questions belong to.
Figure 3 - The Question Category property
When all questions have been categorized in the survey, the report can be setup.
Figure 4 - he Parameter
The Parameter Values folder for this parameter should be empty.
Figure 5 - The Parameter properties
You must now script the functionality for this parameter.
Figure 6 - Example of the Category script
The GetProject method, will take in as a parameter either the data source name (which is named resource_survey in the example), or the project id. The GetQElementsGroupedByCategory method will take in as parameters the defined resource project, the question id of the categories question. The third parameter is a Boolean, where you can select if the Grid questions included in a parameter should be collapsed or expanded.
When the Parameter is in place, it must be included in a List element. The List element can be included on a Query report page where the report viewer can select a report query.
Figure 7 - The Parameter in the List object
Figure 8 - The List properties
The List properties are as follows:
- Type - defines the List type you would like to display.
- Auto Submit - should be selected if there are other elements on the page that depend on the selection made on in this List. The page will then refresh when a selection is made.
- Auto Complete - includes a type-in-box, where the letters you type in will display the list that matches.
- If Type (above) is set to Drop-down, you can add an Empty Row which will be shown by default before a selection is made; check the box as required.
- List Style - defines the style of the list frame.
- Items Style - is the style of the elements within a Category.
- Group Headers Style - is the style of the Header elements in your List.
Role Column
A Role column is included in maintenance screens for Reportal end-users and panelists. This column enables you to allocate a role to a user or panelist, giving you another method of specifying access to the report.
Note: The only place this role can be used is within Reportal scripts, by calling the user.HasRole method.