Likert Demo Experiment Run Experiment

Likert

Jaap Murre

Gives a variant on the scale() control but with the ability to provide labels per choice above or below.

Instead of message1, give an array of brief labels like ['never','rarely',...] leaving message2 the empty string "". If you want to show the labels below, leave message1 the empty string and messag2 the array of labels.

If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.

It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.

The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.

window._checkLikert = function(name) // TODO: change back to _checkRadios when releasing
{
    var radios = document.getElementsByName(name),
        value;

    for (var i = 0, length = radios.length; i < length; i++) {
        if (radios[i].checked)
        {
            value = radios[i].value;
            exec.log(value,name);
            break;
        }
    }
}


var likert = function(message,message1,message2,response_name,size,id,querystring)
{
    var choices1, choices2;
    
    if (Array.isArray(message1)) {
        choices1 = message1;
    } 
    
    if (Array.isArray(message2)) {
        choices2 = message2;
    }
    
    size = (choices1 ? choices1.length : (choices2 ? choices2.length : size) ) || 5;

    exec.required(message,"scale","message");
    exec.required(response_name,"scale","response_name");

    id = id || response_name;
    
    var s = "<div style='margin-bottom:1em;'><label for='" + id + "'>" + message.format(exec.response)
            + "</label></div>"
            + "<div id='radiocontainer1' style='font-size:smaller;' "
            + "onkeypress='_inputKeyPress(event);'>",
        payload;

    if (!choices1 && !choices2) {
        s =+ message1.format(exec.response) + " ";
    }

    for (var i = 0; i < size; i++)
    {
        if (choices1 || choices2) {
            s += "<div style='display:inline-block;padding:0.5em;font-size:smaller;'>";
        }
        if (choices1) {
            s += choices1[i] + " <br />";
        }
        s += "<input style='margin-left:0.5em;margin-right:0.5em;width:.7em;height:0.7em;' type='radio' name='"
             + response_name;
        if (i === 0)
        {
            s += "' id='" + id + "' checked='checked' ";
        }
        s += "' value='" + (i+1) + "'></input>";
        if (choices2) {
            s += "<br />" + choices2[i];
        }
        if (choices1 || choices2) {
            s += "</div>";
        }
    }

    if (!choices1 && !choices2) {
        s += " " + message2.format(exec.response);
    }
    
    s += "</div>";

    if (!exec.groupactive)
    {
        s += "<button style='margin-top:1em;' id='inputbutton' "
            + "onclick='_checkLikert(\"" + id + "\");'>OK</button>";
    }
    else
    {
        payload = function()
        {
            var number = exec.addharvester(function()
            {
                _checkRadios(id);
            });

            if (number === 1) // If this is the first control in the 
            {
                document.getElementById(id).focus();
            }
        }
    }

    this.text(s,querystring,payload);

    if (!exec.groupactive)
    {
        // controls.focus(id); // TODO: reactive when releasing
    }
    return this;
}

main.centerblock.likert = likert;


main.setfontsize(70);
main.centerblock.likert("How well do you sleep at night?",
    "",["Badly","Not well","Average","OK", "Very well"],
    "sleep_quality"); 
main.centerblock.await("button:click");
text("Your sleep quality was {sleep_quality}");
awaitkey(' ');
await(3000);

You can download the files as follows: Click on the file (link) and then right-click and choose Save as... from the menu. Some media files (e.g., sound) will have a download button for this purpose.

This experiment has no files of this type
This experiment has no files of this type
This experiment has no files of this type
This experiment has no YouTube links
This experiment has no files of this type