显示在 Qualtrics 中选择的单选按钮的数量

Displaying count of radio buttons selected in Qualtrics

我让 Qualtrics 调查的受访者选择将两种不同金额的钱分配给一组人。所以对于每个人,受访者必须选择给予 0 美元或 10 美元。

对于特定的外观和功能,我们决定使用 "Scaled Response (Likert)" 的并排问题,只有这两个选项和一个答案,所以我们只有一列有两个答案选项每一行,只能选择其中一个。此外,我们特别希望受访者给一半的人 10 美元,给另一半的人 0 美元,并通过自定义验证实现了这一点。因为有相当数量的选项,我们只想在页面上实时显示有多少人获得了 10 美元,有多少人获得了 0 美元(即在两个答案中分别选择了多少个单选按钮列)。

我见过很多人询问选中的单选按钮总数,但不确定对这些问题(涉及某种点击事件侦听器)的回答是否适用于并排问题而且,至关重要的是,我认为这两个组之间没有区别(即,如果它们并排工作,它们只会显示总共单击了多少个单选按钮,而不是按组)。对于自定义验证,显然 Qualtrics 准确地保留了我想要的计数,因为“$10(计数)”等于 X,“$0(计数)”等于 X,其中 X 是总数的一半的人,但我不确定自己在某些 Javascript.

中使用哪个代码片段

关于如何计算在并排问题的任何一列中选择的单选按钮数量的任何建议或想法?谢谢!

UPDATE:我试过一些 Javascript 肯定行不通的东西。我正在尝试遍历并排问题的每一列,并在发现该列中选择了一个单选按钮时将 +1 添加到计数器(我在代码中尝试了两种不同的方法下面看看是否有效)。然后我在问题文本的 HMTL 中有以下内容:

You have allocated [=10=] to this number of groups: <span id="total2">0</span></span>

我的Javascript:

Qualtrics.SurveyEngine.addOnReady(function()
{
    var total1 = 0;
    var total2 = 0;

document.observe( 'mousemove', function(event,element){
/*
Element ID (element.id) for SBS question type
QR~QID9#1~[row number (i.e. social group)]~[answer column number (i.e. 0 is 1, [=11=] is 2)]
*/

    if (element.type == 'radio')
    {
        sumCol1();

        function sumCol1() {
            for(var i = 1; i <= 20; i++) {
                if (jQuery("input[name="+'QR\~QID9\#1'+'\~'+i+'\~'+'1'+"]").is(":checked")) total1 = total1 + 1;
                else total1=total1;
            }
        }

        sumCol2();

        function sumCol2() {
            for(var i = 1; i <= 20; i++) {
                if ($("input[name="+'QR\~QID9\#1'+'\~'+i+'\~'+'2'+"]:checked")) total2 = total2 + 1;
                else total2=total2;
            }
        }
        }
    })
});

如果有人好奇或需要类似的东西,我已经解决了这个问题,以下内容对我有用。希望以后对其他人有用!

Qualtrics.SurveyEngine.addOnReady(function()
{
var total1 = 0;
var total2 = 0;

var alloclarge=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var allocsmall=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];

/*
Element ID (element.id) for SBS question type
QR~QID9#1~[row number (i.e. social group)]~[answer column number (i.e. 0 is 1, [=10=] is 2)]
*/

this.questionclick = function(event,element){
//for a single answer multiple choice question, the element type will be radio
if (element.type == 'radio')
{
  var qType = this.getQuestionInfo().QuestionType;    // get the question type code (SBS=side by side question)
        if (qType=='SBS') {
            // we need to split the element ID first by #
            // var sbsElement = element.id.split('#')[1];
            var matrxTQid = element.id.split('#')[0].split('~')[1]; // get question ID
            var matrx = element.id.split('#')[1];
            var colNum = matrx.split('~')[0]; // since column is first we need to separate it from the question ID by splitting at the # sign
        }
        var rowNum = element.id.split('~')[2];  // get row number
        var eleNum = element.id.split('~')[3]; // get element number        

    for(var i = 1; i < 21; i++) {
        if (eleNum==1 && rowNum==i && alloclarge[i-1]==0 && allocsmall[i-1]==0) {
            total1=total1+1;
            alloclarge[i-1]=1;
            groupSum();
            document.getElementById("total1").innerHTML=total1;
            document.getElementById("total2").innerHTML=total2;             
        } else if (eleNum==2 && rowNum==i && alloclarge[i-1]==0 && allocsmall[i-1]==0) {
            total2=total2+1;
            allocsmall[i-1]=1;
            groupSum();
            document.getElementById("total1").innerHTML=total1;
            document.getElementById("total2").innerHTML=total2; 
        } else if (eleNum==1 && rowNum==i && alloclarge[i-1]==0 && allocsmall[i-1]==1) {                            
            total1=total1+1;                
            total2=total2-1;
            alloclarge[i-1]=1;              
            allocsmall[i-1]=0;
            groupSum();
            document.getElementById("total1").innerHTML=total1;
            document.getElementById("total2").innerHTML=total2; 
        } else if (eleNum==2 && rowNum==i && alloclarge[i-1]==1 && allocsmall[i-1]==0) {                            
            total1=total1-1;                
            total2=total2+1;
            alloclarge[i-1]=0;              
            allocsmall[i-1]=1;
            groupSum();
            document.getElementById("total1").innerHTML=total1;
            document.getElementById("total2").innerHTML=total2; 
        } else {
            total1=total1;
            total2=total2;
            alloclarge[i-1]=alloclarge[i-1];                
            allocsmall[i-1]=allocsmall[i-1];
            document.getElementById("total1").innerHTML=total1;
            document.getElementById("total2").innerHTML=total2; 
        }   
    }

    function groupSum() {
        if (total1 > 10) {
            alert('You have allocated 0 to more than 10 groups');
        }
        else if (total2 > 10) {
            alert('You have allocated [=10=] to more than 10 groups');
        }
    }
}

}});

在我的问题 HTML 中包含以下内容:

<div><br />
<span style="color:#000000;"><span style="font-size:16px;"><span style="font-family:arial,helvetica,sans-serif;">You have allocated 0 to this number of groups: 
<strong><span id="total1" style="color:#E73F61;">0</span></span></span></span> </strong></div>
<span style="color:#000000;">You have allocated [=11=] to this number of groups: <strong><span id="total2" style="color:#E73F61;">0</span></span></strong>