====== autoAnswer - Automatically answer follow-up questions with one choice or answer====== The **autoAnswer** function automatically answers follow-up questions with only choice or answer. The single choice or answer may be due to carryforward or display logic. It supports both 'New Experience' and all legacy layouts. It works with the following types of questions: * Multiple choice (single or multi-select) * Constant Sum (text entry or slider) * Rank Order (any format: Drag and drop, Radio buttons, Text box, Select box) * Slider * Matrix (formats: Likert, Bipolar, and Constant sum) * Pick, Group, and Rank with one group (not supported for New Experience) It includes support for: * Optionally advancing to the next page * Previous button with auto advance (see **[[autoAnswer#Previous Button Support]]**) * Hiding the page with auto advance (see **[[autoAnswer#autoAnswer Question]]**) * Constant sums of any total * Sliders of any range Here is a demonstration of a typical implementation: {{ :0:autoanswer_autonext.mp4?650 |autoAnswer Demo}} The following demonstrates the different question types and formats autoAnswer works with: {{ :autoanswer_questiontypes.mp4?650 | autoAnswer Question Types Demo}} This function is available for a reasonable fee. Contact **[[https://community.qualtrics.com/inbox/conversation?with=373|TomG]]** on the Qualtrics Community to learn more. ===== Set-up Instructions ===== ==== Add Function To Survey ==== To make the function available to all questions in the survey, copy the function to the Survey Header inside a script tag. Go to Look & Feel -> General -> Header edit -> {{::icon_source.jpg?20|}} and paste the provided autoAnswer function JS: Alternatively, paste the autoAnswer function JS into a question's JS outside the existing Qualtrics functions to make it available to questions on the page. ==== autoAnswer Question ==== The autoAnswer question can be a Multiple Choice, Constant Sum (text entry or slider), Rank Order, Slider, Matrix (likert, bipolar or constant sum), or Pick/Group/Rank question. To prevent the auto answer question from flashing on the screen when automatically advancing to the next page (see **[[autoAnswer#next]]**), add the following html to the question text: Then, add the following to the last question in the survey that is displayed to all respondents so that View Response displays properly in the Data & Analysis tab. ==== JavaScript Function Call ==== Add JS to call the autoAnswer function to apply it to the follow-up question as follows: Qualtrics.SurveyEngine.addOnload(function() { autoAnswer(this); }); To override the default options, specify the desired options in the second function argument as an object. For example: Qualtrics.SurveyEngine.addOnload(function() { autoAnswer(this, {next:false}); }); ==== Previous Button Support ==== To support the Previous Button, add this JS to the question that immediately follows the follow-up question: Qualtrics.SurveyEngine.addOnReady(function() { if("${e://Field/__js_noPrevFlag}"=="1") this.hidePreviousButton(); }); Where the embedded data field name matches the name of the noPrevFlag option in the autoAnswer function call with __js_ added as a prefix. ===== Options ===== ==== next ==== **next** boolean that specifies if the survey should advance to the next page. Default: true ==== noPrevFlag ==== **noPrevFlag** is that name of the embedded variable that will be used to hide or show the Previous Button on the next page following the autoAnswer question. Applicable when **[[autoAnswer#next]]** is true. Default: %%""%% (empty) ==== value ==== **value** specifies the value for constant sum, slider, or matrix constant sum questions. Default: %%"100"%% ====== Qualtrics Wiki ====== [[start|Qualtrics Wiki]]