如何解决Qualtrics 中的 Java
嗨,我正在使用以下代码对 Qualtrics 进行联合实验。这些问题要求受访者根据他们的属性在两名政治候选人之间进行选择。这些属性是随机选择的。我想分析受访者在两个选项之间的选择,尤其是政策选项。但是,每次运行代码时都会遇到代码问题。我很乐意收到有关此代码的一些反馈!
// seed random number generator from embedded data fields
// conjoint profile 1
//Math.seedrandom('${e://Field/seed1}');
// conjoint profile 2
//Math.seedrandom('${e://Field/seed2}');
// conjoint profile 3
//Math.seedrandom('${e://Field/seed3}');
// conjoint profile 4
//Math.seedrandom('${e://Field/seed4}');
// conjoint profile 5
//Math.seedrandom('${e://Field/seed5}');
// seed random number generator from embedded data fields
// conjoint profile 1
Math.seedrandom('${e://Field/seed1a}' * '${e://Field/seed1b}');
Math.seedrandom('${e://Field/seed1}');
// conjoint profile 2
//Math.seedrandom('${e://Field/seed2a}' * '${e://Field/seed2b}');
//Math.seedrandom('${e://Field/seed2}');
// conjoint profile 3
//Math.seedrandom('${e://Field/seed3a}' * '${e://Field/seed3b}');
//Math.seedrandom('${e://Field/seed3}');
// conjoint profile 4
//Math.seedrandom('${e://Field/seed4a}' * '${e://Field/seed4b}');
//Math.seedrandom('${e://Field/seed4}');
// conjoint profile 5
//Math.seedrandom('${e://Field/seed5a}' * '${e://Field/seed5b}');
//Math.seedrandom('${e://Field/seed5}');
这是我定义尺寸的地方
//Define the dimensions
var attRaw=["sex","ethnicity","family","experience","status","policy"];
var att=["sex","policy"];
var attributes=["","",""];
// Create Variables for Traits associated with each dimension.
var sex_raw = ["Male","Female"];
var ethnicity_raw=["American Indian","White","Asian","Black","Latino"];
var family_raw= ["Belongs to a political family","Does not belong to a political family"];
var experience_raw = ["Inexperienced","Experience of 1 to 3 years","Experience of 3 to 5 years"];
var status_raw = ["Incumbent","Non-incumbent"];
var policy_raw=["Agriculture","Education","Roads and Infrastructure"];
再次,这是我随机化订单的地方
//randomize order of dimensions
for (i=0,i<attRaw.length,i++){
var rand1=Math.floor(Math.random()*((attRaw.length-i-)0));
attributes[i]=att[rand1];
att.splice (rand1,1);
}
// Functions for setting race and religion approximately proportionately
function getEthnicity(){
// 20% American Indian,20% White,20% Asian,20% Black,20% Latino
var n = Math.floor(Math.random()*100);
if (n<20) {
var out = 4;
} else if (n <40) {
var out = 3;
} else if (n<60) {
var out = 2;
} else if (n< 80) {
var out=1;
} else {
var out = 0;
}
var ethnicity_raw = ["American Indian","Latino"];
return ethnicity[out];
}
接下来我选择候选A的属性
// Use math.random to randomly select traits for each dimension for candidate A
var sex_a = sex_raw[Math.floor(Math.random()*sex_raw.length)];
var ethnicity_a= getEthnicity();
var family_a= family_raw[Math.floor(Math.random()*family_raw.length)];
var status_a= status_raw[Math.floor(Math.random()*status_raw.length)];
var experience_a=experience_raw [Math.floor(Math.random()*experience_raw.length)];
var policy_a=policy_raw[Math.floor(Math.random()*policy_raw.length)];
候选人 B 的下一个
// Use math.random to randomly select traits for each dimension for candidate B
var sex_b = sex_raw[Math.floor(Math.random()*sex_raw.length)];
var ethnicity_b= getEthnicity();
var family_b= family_raw[Math.floor(Math.random()*family_raw.length)];
var status_b= status_raw[Math.floor(Math.random()*status_raw.length)];
var experience_b=experience_raw [Math.floor(Math.random()*experience_raw.length)];
var policy_b=policy_raw[Math.floor(Math.random()*policy_raw.length)];
索引
//order of dimension variable
var sex_index = attributes.indexOf("sex");
var ethnicity_index=attributes.indexOf("ethnicity");
var family_index=attributes.indexOf("family");
var status_index=attributes.indexOf("status");
var experience_index=attributes.indexOf("experience");
var policy_index=attributes.indexOf("policy");
//Now place the attribute in the right order for candidate a
att_a_traits[sex_index]=race_a;
att_a_traits[ethnicity_index]=ethnicity_a;
att_a_traits[family_index]=family_a;
att_a_traits[status_index]=status_a;
att_a_traits[experience_index]=experience_a;
att_a_traits[policy_index]=policy_a;
//doing the same for b
att_b_traits[sex_index]=race_b;
att_b_traits[ethnicity_index]=ethnicity_b;
att_b_traits[family_index]=family_b;
att_b_traits[status_index]=status_b;
att_b_traits[experience_index]=experience_b;
att_b_traits[policy_index]=policy_b;
这是我将它映射到 HTML 的地方
// Create list of variables to use when setting attributes
att_list=["att1","att2","att3","att4","att5","att6"];
a_list = ["a1","a2","a3","a4","a5","a6"];
b_list = ["b1","b2","b3","b4","b5","b6"];
// set html values in conjoint table
for(i=0;i<7;i++){
document.getElementById(att_list[i]).innerHTML=traits_att[i];
document.getElementById(a_list[i]).innerHTML = att_a_traits_a[i];
document.getElementById(b_list[i]).innerHTML = att_b_traits_b[i];
}
不幸的是,这段代码不起作用,我有不同的变体,但它甚至没有显示选项。有什么可能是错误的线索吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。