User Tools

Site Tools


csranks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
csranks [2022/09/21 11:44] – [textVar] admincsranks [2025/02/15 09:38] (current) – [otherSortArr] admin
Line 1: Line 1:
 ====== csRanks - Rank constant sum values for piping into other questions ====== ====== csRanks - Rank constant sum values for piping into other questions ======
-The csRanks function ranks constant sum values into embedded data fields for piping both labels and values into other questions. For example, the label and value of the top ranked item will be saved in embedded data fields named something like 'Q1.rank.text.1' and 'Q1.rank.value.1', the label and value of the second ranked item will be saved in embedded data fields named something like 'Q1.rank.text.2' and 'Q1.rank.value.2', etc.+The **csRanks** function ranks constant sum values into embedded data fields for piping both labels and values into other questions. For example, the label and value of the top ranked item will be saved in embedded data fields named something like 'Q1.rank.text.1' and 'Q1.rank.value.1', the label and value of the second ranked item will be saved in embedded data fields named something like 'Q1.rank.text.2' and 'Q1.rank.value.2', etc.
  
 The csRanks function gets added to the constant sum question itself, so later sorting is not needed and ranks are available for piping on the next page.  The csRanks function gets added to the constant sum question itself, so later sorting is not needed and ranks are available for piping on the next page. 
Line 11: Line 11:
   * Supports two modes: allow ties or break ties   * Supports two modes: allow ties or break ties
   * Supports tie breaking based on question randomization or one or more of these other choice fields: text, id, variable name, html, or recode. Other choices fields can be sorted ascending or descending for tie breaking purposes.     * Supports tie breaking based on question randomization or one or more of these other choice fields: text, id, variable name, html, or recode. Other choices fields can be sorted ascending or descending for tie breaking purposes.  
-  * Saves labels of choices to embedded data fields. Labels can be saved as HTML, text only, or variable names.+  * Saves labels of choices to embedded data fields. Labels can be saved as HTML, text only, variable names, or entered text.
   * Saves values of choices to embedded data fields.   * Saves values of choices to embedded data fields.
   * Ranked items can be piped on the next page - no additional questions, blocks, or survey flow logic needed.   * Ranked items can be piped on the next page - no additional questions, blocks, or survey flow logic needed.
Line 19: Line 19:
   * Sets embedded data fields for all ranked items (1, 2, 3, etc.) and last ranked item.   * Sets embedded data fields for all ranked items (1, 2, 3, etc.) and last ranked item.
  
-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.+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 ===== ===== Set-up Instructions =====
 ==== Survey Header ==== ==== Survey Header ====
-To make the function available to all questions in the survey, copy the function to the Survey Header inside a script tag: 
 Add the csRanks 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 csRanks function JS: Add the csRanks 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 csRanks function JS:
 <code> <code>
Line 36: Line 35:
 </code> </code>
  
-To override the default options, specify the desired [[csRanks#options|options]] in the second function argument as an object. For example:+To override the default options, specify the desired **[[csRanks#options|options]]** in the second function argument as an object. For example:
 <code> <code>
 Qualtrics.SurveyEngine.addOnload(function() { Qualtrics.SurveyEngine.addOnload(function() {
Line 57: Line 56:
 ===== Options ===== ===== Options =====
 ==== allowTies ==== ==== allowTies ====
-**allowTies** is a boolean that specifies if ties are allowed. When **allowTies** is true, labels of choices with the same values will be combined and given the same rank. The options [[csranks#and|and]], [[csranks#join|join]], and [[csranks#oxford|oxford]] specify how labels are to be combined. When false, ties will be broken based on [[csranks#otherSortArr|otherSortArr]].+**allowTies** is a boolean that specifies if ties are allowed. When **allowTies** is true, labels of choices with the same values will be combined and given the same rank. The options **[[csranks#and|and]]****[[csranks#join|join]]**, and **[[csranks#oxford|oxford]]** specify how labels are to be combined. When false, ties will be broken based on **[[csranks#otherSortArr|otherSortArr]]**.
  
 Default: false Default: false
 ==== and ==== ==== and ====
-**and** is text used to join the last label when [[csranks#allowTies|allowTies]] is true. If **and** is not empty, a space is added before and after if it does not start with a comma (,), colon (:), semi-colon (;), or pipe (|). For translated surveys pipe the value from a translated question. +**and** is text used to join the last label when **[[csranks#allowTies|allowTies]]** is true. If **and** is not empty, a space is added before and after if it does not start with a comma (,), colon (:), semi-colon (;), or pipe (|). For translated surveys pipe the value from a translated question. 
  
-Default: "and"+Default: %%"and"%%
 ==== delim ==== ==== delim ====
 **delim** is a delimiter used to break the embedded data field names into sections. The delimiter is placed between each section. **delim** is a delimiter used to break the embedded data field names into sections. The delimiter is placed between each section.
  
-Default: "."+Default: %%"."%%
 ==== join ==== ==== join ====
-**join** is text used to join three or more labels when [[csranks#allowTies|allowTies]] is true. +**join** is text used to join three or more labels when **[[csranks#allowTies|allowTies]]** is true. 
  
-Default: ", "+Default: %%", "%%
 ==== labelText ==== ==== labelText ====
 **labelText** is used in embedded data field names that capture labels of ranked items.  **labelText** is used in embedded data field names that capture labels of ranked items. 
  
-Default: "text"+Default: %%"text"%%
 ==== last ==== ==== last ====
 **last** is text used in embedded data field names for the last ranked item in place of a rank number (e.g., Q1.rank.text.last).  **last** is text used in embedded data field names for the last ranked item in place of a rank number (e.g., Q1.rank.text.last). 
  
-Default: "last"+Default: %%"last"%%
 ==== otherSortArr ==== ==== otherSortArr ====
-**otherSortArr** is an array used to specify the fields used for tie breaking. It also specifies to order of combined labels when [[csranks#allowTies|allowTies]] is true. An empty array (the default) means ties will be broken based on the randomized order of the choices in the question. If other fields are specified, they should be specified by field name in priority order. Add a minus sign (-) in front of the field name to specify descending order. Available fields (case sensitive) are: Text, id, VariableName, html, and Recode. For example, to specify a tie breaker of descending recode following by choice text, the function would be called like this:+**otherSortArr** is an array used to specify the fields used for tie breaking. It also specifies the order of combined labels when **[[csranks#allowTies|allowTies]]** is true. An empty array (the default) means ties will be broken based on the randomized order of the choices in the question. If other fields are specified, they should be specified by field name in priority order. Add a minus sign (-) in front of the field name to specify descending order. Available fields (case sensitive) are: Text, id, VariableName, html, and Recode. For example, to specify a tie breaker of descending recode followed by choice text, the function would be called like this:
 <code> <code>
 csRanks(this,{otherSortArr:['-Recode','Text']}); csRanks(this,{otherSortArr:['-Recode','Text']});
Line 88: Line 87:
 Default: [] Default: []
 ==== oxford ==== ==== oxford ====
-**oxford** is text used before [[csranks#and|and]] when [[csranks#allowTies|allowTies]] is true and three or more labels are joined. In the text "Item1, Item2, and Item3" the comma before "and" is called an Oxford comma. Change **oxford** to "" to remove the Oxford comma. +**oxford** is text used before **[[csranks#and|and]]** when **[[csranks#allowTies|allowTies]]** is true and three or more labels are joined. In the text "Item1, Item2, and Item3" the comma before "and" is called an Oxford comma. Change **oxford** to %%""%% to remove the Oxford comma. 
  
-Default: ","+Default: %%","%%
 ==== prefixText ==== ==== prefixText ====
 **prefixText**, if not blank, is used at the beginning of embedded data field names. **prefixText**, if not blank, is used at the beginning of embedded data field names.
  
-Default: "" (empty)+Default: %%""%% (empty)
 ==== rankText ==== ==== rankText ====
-**rankText** is the text used to in the rank section of embedded data field names.+**rankText** is the text used in the rank section of embedded data field names.
  
-Default: "rank"+Default: %%"rank"%%
 ==== rankZero ==== ==== rankZero ====
 **rankZero** is a boolean that specifies if choices with a value of zero should be included in ranking.  **rankZero** is a boolean that specifies if choices with a value of zero should be included in ranking. 
Line 107: Line 106:
  
 Default: false Default: false
 +==== textEnter ====
 +**textEnter** is a boolean used to capture entered text for the choice label when ‘Allow text’ is turned on. 
 +
 +Default: true
 ==== textOnly ==== ==== textOnly ====
 **textOnly** is a boolean used to remove HTML from labels when set to true.  **textOnly** is a boolean used to remove HTML from labels when set to true. 
Line 112: Line 115:
 Default: false Default: false
 ==== textVar ==== ==== textVar ====
-**textVar** is a boolean used to save choice variable names instead of choice text when [[csranks#textOnly|textOnly]] AND **textVar** are true. +**textVar** is a boolean used to save choice variable names instead of choice text when **[[csranks#textOnly|textOnly]]** AND **textVar** are true. 
  
 Default: false Default: false
Line 118: Line 121:
 **valueText** is used in embedded data field names that capture values of ranked items.  **valueText** is used in embedded data field names that capture values of ranked items. 
  
-Default: "value"+Default: %%"value"%%
 ====== Qualtrics Wiki ====== ====== Qualtrics Wiki ======
 [[start|Qualtrics Wiki]] [[start|Qualtrics Wiki]]
csranks.1663775080.txt.gz · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki