Qualtrics:Show All Questions

Show All Questions on Qualtrics (use in edit mode of survey)

目前為 2016-03-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Qualtrics:Show All Questions
// @description Show All Questions on Qualtrics (use in edit mode of survey)
// @include https://*.qualtrics.com/ControlPanel/*Edit*
// @grant none
// @version 0.0.1.20160301185027
// @namespace https://greasyfork.org/users/4252
// ==/UserScript==  
//Note: Only been tested in firefox
function OutputQuestions() {

    Questions = document.getElementsByClassName("QuestionText");

    var output;
    output = ' <button id="button" type="button" onclick="ShowHideNAN()">Show/Hide Questions without numbers</button>';
    output += '<table border="1">';
    for (i = 0; i < Questions.length; i++) {
        if (!document.getElementById("TrashArea").contains(Questions[i])) //don't include questions in trash (section at end)
        {
            if (!isNaN(Questions[i].textContent.trim().substr(0, 1))) { //if it starts with a number then show automatically (and ignore whitespace and html)
                output += "<tr><td>" + Questions[i].innerHTML + "</td></tr>";
            } else //if it doesnt start with a number then hide it
            {
                output += '<tr class="hidden"><td>' + Questions[i].innerHTML + '</td></tr>';
            }
        }
    }
    output += "</table>";


    var myWindow = window.open("", "_blank", "scrollbars=yes, menubar=yes");

    var newStyle = document.createElement('style');
    newStyle.innerHTML = ".hidden{ display:none;}";
    myWindow.document.head.appendChild(newStyle);

    var newScript = document.createElement('script');
    newScript.type = 'text/javascript';
    newScript.innerHTML = 'function ShowHideNAN() { rule = document.styleSheets[0].cssRules[0]; if (rule.style.display == "none") rule.style.display = "inline"; else rule.style.display = "none"; }';
    myWindow.document.head.appendChild(newScript);

    myWindow.document.body.innerHTML = output;
}

window.addEventListener('load', WindowLoadedOQ, false);

function WindowLoadedOQ() {

    if (document.getElementsByClassName("EditSection")[1].classList[0] == "active") //if on edit tab
    {
        var OutputQuestionsButton = document.createElement('a');
        OutputQuestionsButton.id = "OutputQuestionsButton";
        document.getElementById("StatusBarLeftContainer").appendChild(OutputQuestionsButton);
        ReadyButton();
    }
}

function ReadyButton() {

    OutputQuestionsButton = document.getElementById("OutputQuestionsButton");
    OutputQuestionsButton.innerHTML = "Output Questions";
    OutputQuestionsButton.className = "toggleButton";
    OutputQuestionsButton.onclick = OutputQuestions;
}