我不确定为什么我的代码无法正常工作/输出。我有硬编码和简化的东西让它在Qualtrics中运行。它看起来很长,但它主要只是处理变量。
Qualtrics.SurveyEngine.addOnload(function () {
var response1 = "${q://QID4/SelectedAnswerRecode/1}"
var response2 = "${q://QID4/SelectedAnswerRecode/2"
var response3 = "${q://QID4/SelectedAnswerRecode/3}"
var response4 = "${q://QID4/SelectedAnswerRecode/4}"
var response5 = "${q://QID4/SelectedAnswerRecode/5}"
var response6 = "${q://QID4/SelectedAnswerRecode/6}"
var response7 = "${q://QID4/SelectedAnswerRecode/7}"
var response8 = "${q://QID4/SelectedAnswerRecode/8}"
var response9 = "${q://QID4/SelectedAnswerRecode/9}"
var response10 = "${q://QID4/SelectedAnswerRecode/10}"
R1 = parseInt(response1);
R2 = parseInt(response2);
R3 = parseInt(response3);
R4 = parseInt(response4);
R5 = parseInt(response5);
R6 = parseInt(response6);
R7 = parseInt(response7);
R8 = parseInt(response8);
R9 = parseInt(response9);
R10 = parseInt(response10);
block_1 = [R1, R2, R3, R4, R5, R6, R7, R8, R9, R10]
var switchpoint1 = R1 - R2;
var switchpoint2 = R2 - R3;
var switchpoint3 = R3 - R4;
var switchpoint4 = R4 - R5;
var switchpoint5 = R5 - R6;
var switchpoint6 = R6 - R7;
var switchpoint7 = R7 - R8;
var switchpoint8 = R8 - R9;
var switchpoint9 = R9 - R10;
var all_switchpoints = [switchpoint1, switchpoint2, switchpoint3,
switchpoint4, switchpoint5, switchpoint6, switchpoint7,
switchpoint8, switchpoint9];
var lambda_mat;
lambda_mat = [.7, .9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3];
var find_1_lambda;
find_1_lambda = all_switchpoints * lambda_mat;
var filtered_switchpoint;
filtered_switchpoint = all_switchpoints.filter(0);
var l_block_1
if (filtered_switchpoint.length > 1) {
l_block_1 = 0;
}
else {
l_block_1 = filtered_switchpoint;
}
Qualtrics.SurveyEngine.setEmbeddedData("Lambda_Block_1", l_block_1)
Qualtrics.SurveyEngine.setEmbeddedData("b1_responses", block_1)
Qualtrics.SurveyEngine.setEmbeddedData("the_switchpoints",
all_switchpoints)
});
这看起来不错吗?提前谢谢!