====== mcPointAllocation - Assign points or cost to each choice and calculate a total ====== The **mcPointAllocation** function enables points or cost to be assigned to each choice in a multiple choice question and calculates, displays and saves the total for the choices selected. It supports setting a maximum total and can be used to do a weighted allocation or build a product with specific features. Features include: * Dynamically calculates and displays a total * Easy to configure * Supports a maximum total * Supports a base point allocation (e.g., base price) * Total displayed based on locale (e.g., thousands separator, decimal point, etc.) * Customizable total formatting * Supports choice groups Here is a quick video demonstration:\\ {{ ::mcpointallocation.mp4?650 |mcPointAllocation Demonstration}} This function is available for a reasonable fee. Contact **[[https://community.qualtrics.com/XMcommunity/messages/add/TomG|TomG]]** on the Qualtrics Community to learn more. ===== Set-up Instructions ===== ==== Survey Header ==== Add the mcPointAllocation function to the survey header to make it available to any question in the survey. Go to Look & Feel -> General -> Header edit -> {{::icon_source.jpg?20|}} and paste the provided mcPointAllocation function JS: Alternatively, paste the mcPointAllocation function JS into a question's JS outside the existing Qualtrics functions to make it available to questions on the page. ===== Question Setup ===== The mcPointAllocation function uses two questions: the multiple choice question itself and a text entry question immediately following the multiple choice question to capture the total. The text entry question is not visible to the respondent. ==== MC Choices ==== Add the points or cost of each choice to the choice label inside a %%%% with the class %%"pts"%%. ONLY numbers should be inside the %%%%. All other text, such as currency symbols, should be outside the %%%%. 5 ==== MC Custom Validation ==== If there is a maximum point allocation or price, add custom validation to the multiple choice question to pass validation if the hidden text entry question is less than or equal to the maximum. ==== MC Question JavaScript ==== Add JS to call the mcPointAllocation function to apply it to the multiple choice question as follows: Qualtrics.SurveyEngine.addOnload(function() { mcPointAllocation(this); }); To override the default options, specify the desired **[[mcsubchoices#options|options]]** is the second function argument as an object. For example: Qualtrics.SurveyEngine.addOnload(function() { mcPointAllocation(this,{max:1000,prefix:"$"}); }); ==== Text Entry Question ==== A single line text entry question with any question text. No requirements, validation or JavaScript is needed. ===== Options ===== ==== base ==== **base** is a numeric field containing a starting total before any choices are selected. Default: 0 ==== debug ==== **debug** is a boolean that turns on display of the hidden total question when true. Default: false ==== decimals ==== **decimals** is numeric field specifying the number of decimal places the total should have. Default: 0 ==== label ==== **label** is a string that specifies the text label of the total. Default: %%"Total: "%% ==== labelStyle ==== **labelStyle** is a string that specifies CSS style of the %%
%% that contains the total label and total. Default: %%"text-align:right;font-weight:bold;"%% ==== max ==== **max** is a numeric field containing the maximum total. When max=0 there is no maximum. When the total exceeds max, the total (including **[[mcpointallocation#prefix|prefix]]** and **[[mcpointallocation#prefix|suffix]]**) will be displayed in **[[mcpointallocation#overmaxcolor|overMaxColor]]**. Default: 0 ==== overMaxColor ==== **overMaxColor** is a string that specifies the CSS color to be used for the total when the max is exceeded. Default: %%"red"%% ==== prefix ==== **prefix** is a string that specifies the text to be shown after the label and before the total (e.g., $). Default: %%""%% ==== suffix ==== **suffix** is a string that specifies the text to be shown after the total (e.g., %%"€"%%). Default: %%""%% ====== Qualtrics Wiki ====== [[start|Qualtrics Wiki]]