This article describes how to use a QScript to Hide or Unhide variable sets by selecting them from a list. This can be convenient to use when you have a large number of variables in your project, or when you need to hide a number of variable sets at the same time.
Requirements
A Displayr Enterprise user license which includes the ability to add custom analysis menu items and QScripts. See How to Use QScripts in Displayr for more details.
Please note these steps require a Displayr license.
Method
To run the QScript to hide variable sets selected from a list:
1. From the toolbar menu, select Anything > [Your account name] > Open QScript Editor.
2. Paste the following code into the QScript editor:
// Hide/Unhide - Hide Selected Questions
includeWeb('QScript Selection Functions');
if (!main()) log("QScript cancelled.");
function main() {
var data_file = requestOneDataFileFromProject(false);
if (data_file == null) { return false;
};
var questions = data_file.questions;
var not_hidden_questions = questions.filter(function (q) { return !q.isHidden; });
if (not_hidden_questions.length > 0) {
var selected_questions = selectManyQuestions("Which questions do you want to hide?", not_hidden_questions).questions;
selected_questions.forEach(function (q) { q.isHidden = true; }); log(selected_questions.length + " question(s) hidden.");
return true;
}
else log("There are no questions to hide in " + data_file.name);
}
3. Click the Play button in the QScript Editor toolbar to run the QScript:
4. A list of variable sets in your document will be shown.
5. Select the variable sets you want to hide and click OK.
6. If you want to save the QScript for future use, click OK then enter a file name for the QScript and click OK. This will save the QScript to your Displayr cloud drive and will then be available in all of your documents by selecting Anything > [Your account name] > Open QScript from Displayr Cloud Drive > [QScript Name]. If you don't wish to save the QScript to the cloud drive, click Cancel in the QScript Editor.
To unhide variable sets, follow the same steps above with the following QScript code:
// Hide/Unhide - Unhide Selected Questions
includeWeb('QScript Selection Functions');
if (!main()) log("QScript cancelled.");
function main() {
var data_file = requestOneDataFileFromProject(false);
if (data_file == null) {
return false;
};
var questions = data_file.questions;
var hidden_questions = questions.filter(function (q) { return q.isHidden; });
if (hidden_questions.length > 0) {
var selected_questions = selectManyQuestions("Which questions do you want to unhide?", hidden_questions).questions;
selected_questions.forEach(function (q) { q.isHidden = false; });
log(selected_questions.length + " question(s) unhidden.");
return true;
}
else log("There are no hidden questions in " + data_file.name);
}
Next
How to Hide a Category in a Pick One Question
How to Hide/Unhide Questions with Many Categories
How to Unhide All Hidden Questions