我有一个多项选择题,很简单:
您参加了以下哪一年(选择所有适用项)? 2019年 2020年 2021年 2022年 2023
后来的问题问:
相对于 ${e://Field/largestYear},您如何评价以下内容?
很明显,我只想将前一个问题中选定的最高年份作为largestYear输入到第二个问题中。
这是第一个问题附带的jscript:
Qualtrics.SurveyEngine.addOnload(function() {
// Wait until the respondent has interacted with the question
this.questionclick = function(event, element) {
// Initialize max value
var max = 2019;
// Loop through selected choices
jQuery("#"+this.questionId+" .ChoiceStructure tbody tr").each(function() {
// Check if choice is selected
if (jQuery(this).find(".Selected").length > 0) {
// Retrieve numerical value of choice
var value = parseFloat(jQuery(this).find("td:first").text());
// Update max value if necessary
if (value > max) {
max = value;
}
}
});
// Set the embedded data with the largest value
Qualtrics.SurveyEngine.setEmbeddedData('largestYear', max);
}
});
问题二中生成的嵌入数据始终等于 jscript 行中的赋值
var max = 2019
,无论我在该语句中输入什么(数字)值。我没有编写 java 的经验,也没有在 Qualtrics 下进行调试的经验,但我认为 var value = parseFloat(jQuery(this).find("td:first").text())
行是问题所在。所以我尝试重新编码响应,使其成为从 1 到 5 的编号列表,但这不起作用,我尝试了变量命名 - 想知道,到底是什么?此时不会有什么伤害。
我希望这里有人对我做错的事情有一些想法。我尝试在 Qualtrics 社区上询问这个问题,但它似乎将我锁定在过多的登录尝试之外。
任何想法将不胜感激。 史蒂夫
我最终在 Qualtrics 用户组上发布了这个问题,其中一位海报建议了以下代码,该代码能够根据选择的顺序(从早年到晚年)完成此任务:
Qualtrics.SurveyEngine.addOnload(function() {
this.questionclick = function(event, element) {
Qualtrics.SurveyEngine.setEmbeddedData('RecentYear', this.getQuestionInfo().Choices[this.getSelectedChoices().last()].Text);
}
});