Last active
April 16, 2019 01:31
-
-
Save jwatzek/ec268673a29f636572f9d0a901ca3c58 to your computer and use it in GitHub Desktop.
Interpolate yr. and mos. from slider on log scale. Save to Embedded Data field for piping. If "Not applicable" (renamed "Keep the same") box checked, copy previous value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Qualtrics.SurveyEngine.addOnload(function() | |
{ | |
var answer = "${q://QID62/ChoiceNumericEntryValue/1}"; | |
var sqrt32 = Math.pow(2, 1/3); | |
answer = parseFloat(answer); | |
answer = Math.pow(sqrt32, answer - 1); | |
var years = Math.floor(answer); | |
var months = answer % 1; | |
months *= 12; | |
months = Math.floor(months); | |
if (isNaN(years)) { | |
Qualtrics.SurveyEngine.setEmbeddedData('Punishment2', "${e://Field/Punishment1}"); | |
} else { | |
Qualtrics.SurveyEngine.setEmbeddedData('Punishment2', years.toString() + ' yr. and ' + months.toString() + ' mos.'); | |
} | |
$('Buttons').hide(); | |
this.clickNextButton(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment