QScript Question

From Q
Jump to navigation Jump to search

Question

A question from one of the data files in your project, corresponding to a question in Q. A question is made up of one or more variables.

dataFile

Gets the DataFile object that this question is part of.

dataReduction

Gets the DataReduction object for this question.

deleteQuestion()

Deletes this question.

duplicate(name)

Duplicates this question and its variables. This is the same as using "Copy and Paste Question(s) | Exact" in Q.
nameThe name for the new question.
Returns:The new Question object.

equals(obj)

Whether two objects are the same.
objThe object to compare against.
Returns:true or false
Example:
data_file.getQuestionByName('Q2').equals(data_file.questions()[0])

flatteningType

Get and set the flattening Type of a question. Flattening Type is only applicable to PickAnyGrid,PickOneMulti and NumberGrid questions. Can be assigned by the string values 'By Columns', 'By Rows' or 'None'.

guid

Get the question's internal unique identifier.

isBanner

Returns true if this question is a banner, false otherwise. Banner questions and their variables cannot be modified directly, as they are simply a combination of their input questions.

isFilter

Gets/sets whether this question can be used as a filter in crosstabs, etc.

isHidden

Gets/sets whether this question is hidden in edit mode, and thus cannot be used in crosstabs, etc.

isHiddenInExplore

Gets/sets whether this question is hidden in explore mode, and thus cannot be used in crosstabs, etc.

isHiddenInView

Gets/sets whether this question is hidden in view mode, and thus cannot be used in crosstabs, etc.

isValid

Returns true is this question is valid, false otherwise. A question will be invalid if any of its variables are invalid, or it is a Grid type and Q cannot determine the 2D structure in the variable labels.

isWeight

Gets/sets whether this question can be used as a weight in crosstabs, etc.

lastKnownDataReduction

Gets the DataReduction object for this question, but may return old data if the underlying variables are out of date. This makes it safe to call from R GUI JavaScript code. Will return null if we have no data reduction stored for this Question or for banner questions. This may happen if the data reduction is in its default state (in which case the categories can be found using variable.knownValues and variable.valueAttributes). It may also happen if the data reduction is Reverted by the user, or the variables constituting the Question change. The data reduction returned can only be used for read operations.

name

Get/set the question's name.

needsCheckValuesToCount

A flag that determines whether a Pick Any question has had its Values to Count checked or not. Set to false to remove the CHECK status from a newly created Pick Any Question.

questionType

Deprecated for Displayr - see variableSetStructure. Get or set the Question's type. This can be one of 'Text', 'Number', 'Pick One', 'Text - Multi', 'Number - Multi', 'Pick Any', 'Pick One - Multi', 'Pick Any - Compact', 'Pick Any - Grid', 'Number - Grid', 'Experiment', 'Ranking', 'Date' (date/time).

reorderVariables(variables)

Reorders the variable in a Question object. If any variables are omitted then they will be at the end. If variables from multiple questions are included then each question will have its consitituent variables reordered, but the ordering of the questions themselves will not change.
variablesAn array of variables, in the order you want them.
Example:
q.reorderVariables([q.variables[1], q.variables[0])

type

Returns 'Question'.

uniqueValues

Returns the unique source values found in this question, as an array. The values in the array are sorted in ascending order, with any missing data (NaN) first. The values are source values (prior to any Value Attributes or Recode Rules being applied).

valueAttributes

Gets the ValueAttributes object for a question. Typically you use this to adjust the values to count (for Pick Any questions), category names, or to remap values.

variables

Gets an array of all the Variable objects that constitute this question.

variableSetStructure

Get the Question's type as used in Displayr, which is a combination of questionType and (for Pick One questions) its variable types. This can be one of 'Text', 'Numeric', 'Nominal', 'Ordinal', 'Text - Multi', 'Numeric - Multi', 'Binary - Multi', 'Nominal - Multi', 'Ordinal - Multi', 'Binary - Multi (Compact)', 'Binary - Grid', 'Numeric - Grid', 'Experiment', 'Ranking', 'Date/Time'.