This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
en:create:transfer-responses [19.03.2016 21:51] – created hotaitde | en:create:transfer-responses [01.04.2016 15:44] – Formatting admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Insert Answer Texts in Follow-up Questions | + | ====== |
- | Placeholders allow you to use participants‘ text inputs elsewhere in the questionnaire. This chapter provides you with a number of examples. | + | |
- | Note: If in a follow-up question you only want to display specific scale items or select options dependent on the participant’s response, please refer to Use Selected Items In Another Question. | + | [[:: |
- | Note: If you haven’t worked with filters and PHP code, please refer to chapters | + | |
- | Use Single Answers | + | **Note:** If in a follow-up question you only want to display specific scale items or select options dependent on the participant’s response, please refer to [[: |
- | On page 2 the participant mentioned the name of a TV presenter in a text input field (tagging TX01_01). Answer validation was applied to ensure the participant did enter something. The entered name is now to be included in following question texts or scale items. | + | |
- | In the first step, create a placeholder replace() for the name, e. g. %tvpresenter. In order to do so, place the following PHP code on a page of the questionnaire following the text input question (e. g. in the example on page 3 or later): | + | **Note:** If you haven’t worked with filters and PHP code, please refer to chapters |
+ | |||
+ | |||
+ | ===== Use Single Answers | ||
+ | |||
+ | On page 2 the participant mentioned the name of a TV presenter in a text input field (tagging | ||
+ | |||
+ | In the first step, create a placeholder | ||
+ | |||
+ | <code php> | ||
+ | replace(' | ||
+ | </ | ||
+ | |||
+ | This placeholder can then be inserted anywhere in the questionnaire -– of course, only after it was created via PHP code. For example, the question text of a question on page 3 could be as follows: | ||
+ | |||
+ | < | ||
+ | Please assess < | ||
+ | </ | ||
+ | |||
+ | **Note:** It is not possible to use '' | ||
+ | |||
+ | **Note:** In order to check if the placeholder functions correctly, you need to re-start the questionnaire from the beginning – or at least from the page with the text input field where the relevant name was entered (in the example on page 2). | ||
+ | |||
+ | **Tip:** Once a placeholder has been created, it remains valid for any following pages in the questionnaire. Repeating the PHP code on every page is __not__ required. | ||
+ | |||
+ | **Tip:** The above described PHP code also allows you to enter predefined answers (e.g. from a multi-choice question) in follow-up questions. | ||
+ | |||
+ | **Tip:** As an alternative, | ||
+ | |||
+ | <code php> | ||
+ | $name = value(' | ||
+ | replace(' | ||
+ | </ | ||
+ | |||
+ | ===== Insert Several Answer Texts ===== | ||
+ | |||
+ | A question of the question type "Text Input" ('' | ||
+ | |||
+ | The problem in this example is that the participant might complete only part of the input fields. Consequently, | ||
+ | |||
+ | In order for the follow-up question to function (e. g. '' | ||
+ | |||
+ | < | ||
+ | %text1% | ||
+ | %text2% | ||
+ | %text3% | ||
+ | %text4% | ||
+ | %text5% | ||
+ | %text6% | ||
+ | %text7% | ||
+ | %text8% | ||
+ | %text9% | ||
+ | %text10% | ||
+ | </ | ||
+ | |||
+ | **Tip:** Of course, additional text may be added to the placeholders, | ||
+ | |||
+ | Via '' | ||
+ | |||
+ | **Important: | ||
+ | |||
+ | ^Text Input^Free Mentions^ | ||
+ | |<code php> | ||
+ | $question = ' | ||
+ | $items = array(); | ||
+ | for ($i=1; $i<=10; $i++) { | ||
+ | $itemID = $question.' | ||
+ | $answer = value($itemID); | ||
+ | if (trim($answer) != '' | ||
+ | replace(' | ||
+ | $items[] = $i; | ||
+ | } | ||
+ | } | ||
+ | // Folgefrage anzeigen | ||
+ | if (count($items) > 0) { | ||
+ | question(' | ||
+ | } | ||
+ | </ | ||
+ | $question = ' | ||
+ | $items = array(); | ||
+ | for ($i=1; $i<=10; $i++) { | ||
+ | $itemID = $question.' | ||
+ | $answer = value($itemID); | ||
+ | if (trim($answer) != '' | ||
+ | replace(' | ||
+ | $items[] = $i; | ||
+ | } | ||
+ | } | ||
+ | // Folgefrage anzeigen | ||
+ | if (count($items) > 0) { | ||
+ | question(' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Explanatory note on the PHP code: The IF filter at the end ensures that the follow-up question is skipped if the participant has not completed the relevant field. Through '' | ||
+ | |||
+ | **Note:** If the PHP code does not provide the required results, please refer to chapter [[: | ||