====== answersPrint() ======

A whole range of questions that are asked in the questionnaire can be displayed with the help of the ''answersPrint()'' function. This means the participant can be shown a print view of their own questionnaire. 

Use the ''[[:en:create:functions:option|option()]]'' function to define a section of the questionnaire (see example). 

''void **answersPrint**(string //section//)''


===== Tips =====

The ''answersPrint()'' function calls up ''answers'' repeatedly. Therefore, information for ''[[:en:create:functions:answers|answers()]]'' also applies fully for ''answersPrint()''.

If you enable the back button in the questionnaire and use filter questions, the following situation may occur: The respondents is shown a filtered question, then uses the back button, changes an earlier answers, and due to the filter, the other question is not displayed in the subsequent questionnaire, anymore. Nonetheless, ''answersPrint()'' will display the question in the print view, because it has been asked.

===== Example 1 =====

In the following example, the participant should get a print view of all questions in the questionnaire.


In **Compose Questionnaire**, insert a //PHP code// element on the first page with the following content:


<code php>
option('part', 'all');
</code>

This command informs SoSci Survey that a section begins with the ''all'' ID right from the outset.


Following this, insert a new page at the end of the questionnaire -- with a //PHP code// element and a text element.

<code php>
answersPrint('all');
text('printButton');
</code>

The "printButton" text element has the following content.


<code>
<div>
  <button type="button" onclick="window.print();">Print</button>
</div>
</code>


===== Example 2 =====

The questionnaire consists of two parts: after a couple of questions regarding the master data (pages 1 and 2), there is a section concerning the respondent's company (pages 3 to 5), and then a section regarding their employment situation. The respondent should get both parts separately in print view,  page 6 should not appear in print view.

At the top of page 3 a //PHP code// element with the following content is inserted in order to do this:


<code php>
option('part', 'company');
</code>

The following PHP code is inserted on page 6:

<code php>
option('part', false);
</code>

and the following PHP code on page 7.

<code php>
option('part', 'job');
</code>

At the end of the questionnaire, two pages with the following content will be inserted.

<code php>
answersPrint('company');
</code>

<code php>
answersPrint('job');
</code>


The ''buttonPrint'' text element from the above example can be optionally inserted under the PHP code for each one.
