Desktop User Guides > Professional > Interview scripting > Writing interview scripts > More than one question per page > Displaying the same questions at the top of every page
Displaying the same questions at the top of every page
Questionnaire scripts can contain global questions that are displayed at the top of every page. In most cases, these are not ordinary questions that the respondent answers as a matter of course. Instead, they provide facilities for respondents to interact with the interviewing program in a certain way at any point during the interview. Typical examples are:
To change the appearance of the page so that it is easier to use, for example, by choosing a template that provides more contrast between the page background color and the color of the text, or that uses a larger or smaller text size.
To enter general comments that cannot be entered anywhere else in the interview.
To use global questions
Define the questions in the metadata section in the normal way and then, in the routing section, type:
at the point at which you want to start adding the question called QName to each page.
You might need to write additional code to process the answers to the global questions. In the case where respondents can choose a different template, you need code that checks whether the user has chosen a different template and, if so, sets that template to be the layout template for the rest of the interview. You can place this code in an OnAfterQuestionAsk event, as shown in the following examples.
To remove a global question
where Position is the question’s position in the current list of global questions. For example:
to remove the first question in the global question list.
To remove all global questions
Choosing a different layout template
This example shows how to use a global question to allow respondents to change the page layout template during the course of the interview. The change is made in the OnAfterQuestionAsk event so it will affect the next page of the interview, not the current one. The global question is defined as:
ChangeTemplate "Change layout template" categorical [1..1]
NoChange "No change",
CardBlue "Blue card",
PeopleWorkingRed "Red image of people working",
RectangleGreen "Green rectangle",
BlueSlide "Blue slide"
} defaultanswer(NoChange);
Notice that the question has a “No Change” response that is set as the default, so respondents who are satisfied with the current template can ignore the question.
The question is defined in the routing section as a global question and the response list is set up to display in two rows across the page, thus reducing the amount of space it takes up.
ChangeTemplate.Style.Orientation = Orientations.orRow
ChangeTemplate.Style.Rows = 2
The response to the global question is checked and any template change is implemented using an OnAfterQuestionAsk event:
Sub OnAfterQuestionAsk(Question, IOM)
  If IOM.Questions["ChangeTemplate"].Response.Value =
      {CardBlue} Then
IOM.LayoutTemplate = "Card_Blue.htm"
End If
If IOM.Questions["ChangeTemplate"].Response.Value =
      {PeopleWorkingRed} Then
IOM.LayoutTemplate = "People_Working_Red_Layout.htm"
End If
If IOM.Questions["ChangeTemplate"].Response.Value =
      {RectangleGreen} Then
IOM.LayoutTemplate = "Rectangle_Green.htm"
End If
If IOM.Questions["ChangeTemplate"].Response.Value =
      {BlueSlide} Then
IOM.LayoutTemplate = "Slide_Blue.htm"
End If
End Sub
Grid with global “Change template” question above it
This illustration shows the global question on a typical interview page:
This graphic is described in the surrounding text.
Gathering general comments
This example shows how to gather general comments throughout the interview and then forward them to the project manager at the end of the interview. The metadata section defines the following questions:
YourComments "General comments" text [..50];
AllComments "" text; SendComments "You entered some general
  comments during the interview. Please click
  <a href='
  comments&amp;body={#AllComments}'>here</a> to review them and
  send them to the project manager.
  <br/>Thank you for your help." info;
YourComments is the global question that respondents see. AllComments will contain a concatenation of all comments so far, and SendComments is the message that respondents see at the end of the interview.
The routing section is as follows:
YourComments.MustAnswer = False
Sub OnAfterQuestionAsk(Question, IOM)
IOM.Questions["AllComments"].Response.Value = _
IOM.Questions["AllComments"].Response.Value + _
End Sub
This displays pages for Cares, Respect, and Profits, each with YourComments at the top of the page. The global question is removed before the last page (on which the respondent can review the comments message) is displayed.
Displaying page level errors
A page with a global question is a dynamic page and does not use the layout template in the same way. If you want to set ShowErrors="All" for the layout template, you must set ShowErrors in the question template, as follows:
<mrData QuestionElement='Error' ShowErrors="All" />
See also
More than one question per page