Actions

アンケートロジックの確認 - 高度

From LimeSurvey Manual

Revision as of 02:07, 9 January 2021 by Bravehorse (talk | contribs) (Created page with "{{Note|対応するフィールドが空でない場合、アンケートの説明、ようこそメッセージ、終了メッセージ、完了URL、アンケートデータ...")


概要

複雑なアンケートを作成し、簡単に維持するための重要な機能として、アンケートロジックの確認があります。

アンケートを開始する前の開発やテストの段階で、アンケートのロジックを検証することは非常に重要です。複雑な出現条件式、文言調整、検証式を作成するならなおさらで、アンケートが問題なく実行できるように確認する必要があります。

この機能を使用すると、アンケート、グループ、質問の正確性を素早く検証することができます。アンケート関連設定の下にあるトップバーメニューオプションからアクセスできます。ツールメニューから利用できます。



上図からわかるように、このオプションは、アンケートの中で使用されている言語ごとに4回実行することができます。

説明

アンケートロジックの確認から、個々の質問やグループに設定したすべての項目(名前、テキスト、ヘルプ、条件/出現条件、検証ルール、既定値、サブ質問、回答など)が便利な表形式で表示されます。エラーがあればハイライトされ、質問やグループのID(または式の中で使われている変数)をクリックすると、ブラウザのタブが新たに開かれ、編集することができます。これにより、エラーを手早く修正し、アンケートを開始する前に正確性を確認するためのロジックチェックページが更新されます。

表示画面は、アンケートの設計とロジックが正しいかについてアンケート実施者や依頼者が確認できるようにできています。アンケートロジックを確認すると、実施中のアンケートのすべての式のキャッシュが更新されます。

以下の列があります。

  • # - グループ、質問の順番を示します。番号は0から始まります。
  • 名前 [ID] - グループ/質問/サブ質問のコード。これらのコードは、内の変数として使用できます。IDは、質問ID(QID)またはグループID(GID)です。このフィールドには、質問タイプ(複数選択[M]など)も表示されます。


式内で使用できる変数の詳細については、こちらのウィキサブセクションを参照してください。


  • 出現条件 [検証](デフォルト値) - 以下のとおり表示されます。
    • 出現条件 - 質問またはグループについて出現条件式が構文ハイライト表示されます。常に真(いかなるシナリオでも表示)である場合、値は1となります。
    • 検証 - ExpressionScriptは選択された質問属性に基づいて検証式を自動生成します(例:回答の最小値/最大値、合計値の最小値/最大値/一致、個々の値の最小値/最大値、正規表現による検証)。このセクションには、エラー(未定義の変数など)の有無を検出できるよう、生成された検証式が表示されます。
      • 質問レベルの検証では、上述の質問属性を検証するために必要な式が表示されます。
      • サブ質問レベルの検証では、array_filterarray_filter_excludeexclusive_optionの実装に必要な式が表示されます。
    • 既定値 - 質問に既定値がある場合、ここに構文ハイライト付きで表示されます(既定値が式であることもあるため)。
  • テキスト[ヘルプ](Tip) - 以下のとおり表示されます。
    • テキスト - グループ、質問、サブ質問、回答のテキスト。文言調整されていることを示すため、構文ハイライト表示されており、文言調整で使用するすべての変数が宣言されていることを確認することができます。
    • ヘルプ - 質問に対するヘルプを示しており、構文ハイライトされています。
    • Tip - これは質問属性に基づいて内部的に生成された検証ヒントです。これと同じものがすべてのアンケートスタイル、印刷可能なアンケート、データ入力画面で使われます。
    • 質問属性 - この質問に関連する質問属性の表です。属性が式の場合は正確性を検証するため構文ハイライト表示されます。

行は以下のルールによって色づけされています。

  • グループ - 背景がライトグレー
  • 質問 - 背景がライトグリーン
  • サブ質問 - 背景が淡い黄色
  • 回答 - 背景が白

回答には、出現条件欄に追加の属性が表示されます。

  • - 計算で使用する内部の既定値です。評価機能を使う場合は評価値となります。それ以外の場合では、回答の名前と同一になります。


対応するフィールドが空でない場合、アンケートの説明、ようこそメッセージ、終了メッセージ、完了URL、アンケートデータポリシーの通知、ラベルは、Cgeckアンケートロジック(表の上)に表示されます。

使い方

At the top of the page, there is a summary message. If all is well, it will say "No syntax errors detected in this survey", or "This group" or "This question", "by itself, does not contain any syntax errors". If the opposite is true, it will say "X questions have syntax errors that need to be corrected".

Each question that has syntax errors gets the background of its leftmost column (i.e. #) color-coded red. Also, a warning stating the number of minimum errors of a question will be displayed under the Name [ID] column. The following errors are common:

  • Undefined variable - if you have not defined all of your variables, or mistyped array_filter (or different sets of answer options for array_filter), then some of your validation questions will show errors. Undefined variables are shown in red text, boxed with a red line.
  • Bad syntax - as you start to use relevance equations, you may use too many or too few parentheses. Such syntax problems are highlighted and boxed in red. If you hover the mouse over any such red-boxed text, a tool-tip will describe the error.


未定義の変数

If undefined variables are used, the respective variable name will be color-coded in red and surrounded by a red line. If you hover your mouse over the variable name, it will say "undefined variable":



  Attention : LimeSurveyでは、同じ質問コードを使用した質問を作成できません。ただし、すでに定義されている質問と同じ質問コードを使用する質問グループまたは質問をインポートすると、アンケートの中で同様の質問コードが含まれることがあります。質問IDは異なるため、質問をインポートすることはできます。ただし、(RまたはSPSSで)さらに分析するため、アンケート結果をエクスポートする場合、質問コードが変数と見なされるので注意してください。



}}

不正な構文

式にまつわる間違いのほとんどは、誤った構文に関連しています。これは、アンケート管理者は、しばしば中括弧を追加しわすれたり、正しい括弧の使用しなかったり、間違って式を使用したりするためです。



構文ハイライトの使用例を示します。


Bad custom JavaScript

The JavaScript errors will also be highlighted in the survey logic check:



編集と検証を手早く行う

All of the syntax-highlighted text has tooltips embedded, which are clickable:

  1. Tooltips
    • Functions - hovering the mouse lets you see the purpose and syntax definition of the function;
    • Variable Names - hovering the mouse lets you see the position (group, question sequence), question text, and allowable answers for the question.
  2. Actions
    • Variable Names - clicking on the variable name opens a new window that allows you to edit the question. This makes it easy to navigate and verify logic - simply keep clicking on variable names of relevance or validation criteria for the question to see where they come from and how they are used.


次の例は、ExpressionScriptサンプルアンケートから取得したものです。アンケート、説明、ダウンロードのスクリーンショットがあります。


ボディー・マス・インデックス

本例のスクリーンショットです。

This is the question-reorder view of the Body Mass Index calculation. You can see the relevance equations for weight, height, and BMI under the Question column:



For a better survey overview, check the survey logic page:



This survey example is also a good example of nested if() statements to generate the "weightstatus".


ロジックのカスケード

本例のスクリーンショットです。

It shows the subquestion validation logic that is automatically generated when you use array_filter and array_filter_exclude. This example also shows how you can substitute the tailored "Other" value (the answer for Q02_other is Q01_other).



Q05 in this example shows simultaneous use of array_filter and array_filter_exclude on Q01 and Q02, respectively. This example demonstrates cascading array_filter capabilities. Note that one of the main reasons for showing the question and subquestion level validation criteria is to help ensure you have not made any typos in specifying the array_filter or array_filter_exclude variable names (or in case you use different variable names for your list of filtered subquestions). If you have such typos, all the invalid variable names will appear in red indicating that they are undefined, letting you quickly fix the problem.



動的な出現条件

これは、質問の表示・非表示を制御する"出現条件"の動的でカスケーディングされたロジックの例を示しています。この例はここからダウンロードできます。

Also note that questions are displayed only if certain validation criteria are met. For example, if a person states that she has 2 kids, certain questions have to be filled in by the respondent (kid1 and kid2).


グループレベルの出現条件

This example shows how group-level relevance appears in the logic check. Here are screenshots of the example described below.

ご覧のように、グループレベルの関連式(cohabs > 1 && p1_rel != "")はG-2の灰色のPerson 2の行に表示されます。

You may also notice that all of the questions are mandatory. However, if the group is irrelevant, so are all its questions. As a result, those questions are only truly mandatory if the group is relevant.

先行する質問に対する回答が空でない場合にのみ表示される質問があることに注意してください。 p2_sexが記入されていない場合、必須の質問であっても、p2_nameは表示されません。 p2_nameが記入されていない場合でも、必須質問p2_ageは表示されません。これらの質問は"条件付きで必須"と見なすことができます。

Additionally, note that the tip messages are also automatically created for you. They are organized by value range (min/max), sum value range (min/max/equals), number of answers (min/max), etc (it depends on the used question type and active attributes). Sometimes you want to validate an answer range but don't want to display what might appear to be silly validation tips to the user. In such cases, you can use the hide_tip question option (as in this case, to avoid telling the user that the age must be between 0 and 115 unless they try to enter a bad value - see p2_age).


小数点としてのカンマ

LimeSurveyは実行時に小数点の区切り記号としてカンマを使用することが完全にサポートされていますが、設計時(高度な質問属性で最小値・最大値を設定するときなど)には小数点としてドットを使用する必要があることを示す例をここに示します。実際の例がこちらにあります 。

Also, remember that the validation logic is created for you automatically from the enabled question attributes. The equations may look overwhelming, but you don't need to worry about them.