Actions

Expression Manager/ja: Difference between revisions

From LimeSurvey Manual

(Created page with "その質問のグループレベルの関連を編集する画面は次のとおりです。")
(Created page with "==式マネージャーの統計関数==")
 
(167 intermediate revisions by 4 users not shown)
Line 2: Line 2:
__TOC__
__TOC__


<div class="simplebox"> 注意: この機能はLimeSurvey 1.92以降で利用できます。</div>
<div class="simplebox"> 注意 : この機能は LimeSurvey 1.92 以降で利用できます。</div>


<span id="Quick_Start_Tutorial"></span>
=クイックスタート=
=クイックスタート=


<span id="Overview"></span>
==概要==
==概要==


アンケートをカスタマイズするには、通常次のことを決めます。
アンケートをカスタマイズするには、通常、次のことを指定する方法が必要です :
#'''ナビゲーション/分岐''' - 質問の順番を変更します。
#'''ナビゲーション・分岐''' - アンケート参加者の回答によって質問の順番を変更できるようにします。
#'''テーラーリング/パイピング''' - 質問の文言調整(先行する回答の引用、数や性別による文の結合など)、カスタムレポートの生成(評価点数、アドバイスの提示など)
#'''テーラーリング・パイピング''' - 質問の表現方法(先行する回答の参照、調査の課題による参加者数や性別に合わせた語句の変化など)、(評価スコアやカスタマイズしたアドバイスなど)カスタマイズしたレポートを生成する方法
#'''検証''' - 回答が条件(最大値、最小値、入力パターンなど)を満たすようにします。
#'''検証''' - 最小値と最大値、または入力パターンの一致など、回答が特定の基準を満たしていることを確認します。


式マネージャー(EM)では、各機能のロジックを指定する直感的な方法が提供されています。関数を呼び出しているものであっても、標準的な数式として書くことができるものは、ほとんどが有効な式になります。 EMは現在、70の関数が利用でき、より多くの機能をサポートするよう、簡単に拡張することができます。また、(SGQA名ではなく)人間が読める変数名を使用して変数にアクセスすることもできます。
式マネージャー(EM)では、各機能のロジックを指定する直感的な方法が提供されています。関数を呼び出しているものであっても、標準的な数式として書くことができるものは、ほとんどが有効な式になります。EMは現在、70の関数が利用でき、より多くの機能をサポートするよう、簡単に拡張することができます。また、(SGQA名ではなく)人間が読める変数名を使用して変数にアクセスすることもできます。


以下のセクションで、式マネージャーを使う主な場面を紹介します。
以下のセクションで、式マネージャーを使う主な場面を紹介します。


<span id="Relevance_(Controlling_Navigation/Branching)"></span>
==関連(ナビゲーション制御/分岐)==
==関連(ナビゲーション制御/分岐)==


アンケートによっては、"Gotoロジック"を使用して、質問1でCと答えた場合は質問5にジャンプしたりします。このアプローチは、検証が難しく、質問を並べ替えるときにロジックが壊れてしまうため、大きな制約があります。EMでは、質問が有効かどうかを決めるすべての条件を、ブール値の関係式を使用して指定します。質問が関連ありとなる場合は質問が表示され、それ以外の場合は「適用外」となり、データベースにはNULL値が格納されます。これは条件エディターで実行できるものと似ていますが、EMではより複雑で強力な条件を簡単に指定でき、さらにSGQA名ではなく変数名を使用できます。
アンケートによっては、"Gotoロジック"を使用して、質問1でCと答えた場合は質問5にジャンプしたりします。このアプローチは、検証が難しく、質問を並べ替えるときにロジックが壊れてしまうため、大きな制約があります。EMでは、質問が有効かどうかを決めるすべての条件を、ブール値の出現条件式を使用して指定します。質問が出現条件を満たす場合は質問が表示され、それ以外の場合は「適用外」となり、データベースにはNULL値が格納されます。これは条件エディターで実行できるものと似ていますが、EMではより複雑で強力な条件を簡単に指定でき、さらにSGQA名ではなく変数名を使用できます。


この画像では、アンケートの関連性ロジックを確認する例を示しており、ここでは、体格指数(BMI)を計算します。関連式は、変数名の直後の角カッコで示されています(緑色)。体重、体重の単位、身長、身長の単位の関連式はすべて1です。つまり、これらの項目は常に質問されます。しかし、BMIの関連式は、
この画像では、アンケートの関連性ロジックを確認する例を示しており、ここでは、体格指数(BMI)を計算します。関連式は、変数名の直後の角カッコで示されています(緑色)。体重、体重の単位、身長、身長の単位の関連式はすべて1です。つまり、これらの項目は常に質問されます。しかし、BMIの関連式は、
Line 28: Line 31:
関連は以下の場所て表示・編集ができます。
関連は以下の場所て表示・編集ができます。


<span id="Viewing_/_Editing_Question-Level_Relevance"></span>
===質問レベルの関連の閲覧/編集===
===質問レベルの関連の閲覧/編集===


Line 40: Line 44:
関連式を入力するときは中括弧を使用しないようにしてください。
関連式を入力するときは中括弧を使用しないようにしてください。


<span id="Viewing_/_Editing_Group-Level_Relevance"></span>
===グループレベルの関連の閲覧/編集===
===グループレベルの関連の閲覧/編集===


Line 52: Line 57:
[[File:tutorial5.jpg]]
[[File:tutorial5.jpg]]


Note that you do not use the curly braces when you enter a Relevance Equation.
関連式を入力するときは中括弧を使用しないようにしてください。


<span id="Tailoring/Piping"></span>
==カスタマイズ/パイプ==
==カスタマイズ/パイプ==


EM lets you easily do simple and complex conditional tailoring of your questions.  Sometimes you just need simple substitution, like saying, "You said you purchased <nowiki>[</nowiki>Product].  What did you like best about it?".  Sometimes you need conditional substitution like "<nowiki>[</nowiki>Mr./Mrs.] <nowiki>[</nowiki>LastName], would you be willing to complete our survey?".  In this case,  you want to use Mr. or Mrs. based upon the person's gender.  Other times you need even more complex substitution (such as based upon a mathematical computation).  EM supports each of these types of tailoring/piping.
EMを使用すると、単純な、または複雑な条件付きの質問を簡単に作成できます。例えば、"<nowiki>[</nowiki>製品]を購入したと回答しました。よかった点は何ですか?"のように、単純な「置き換え」が必要な場合があります。また、"<nowiki>[</nowiki>Mr./Mrs.] <nowiki>[</nowiki>LastName]、アンケートを完了してもよろしいですか?"のように、条件付きの置き換えが必要な場合もあります。この場合、回答者の性別に基づいてMr.かMrs.を使用します。また、例えば、数学的計算に基づいてさらに複雑な置き換えが必要になることもあります。EMは、このような場合のカスタマイズ/パイプをサポートしています。


<span id="Conditional_Equations"></span>
===条件式===
===条件式===


The Body Mass Index example shows the ability to compute a person's BMI, even while letting them enter their height and weight in metric or non-metric units.
体格指数の例では、身長と体重の入力単位がメートル法であってもメートル法でなくても、BMIが計算できることを示しています。


[[File:tailoring7.jpg]]
[[File:tailoring7.jpg]]


Here weight_kg is {if(weight_units == 'kg', weight, weight * .453592)}.  This if() function means that if the subject entered the weight using kilograms, use that value, otherwise multiply the entered value (which was in pounds) by .453592 to convert it to kilograms.  The height_m variable uses a similar approach to compute the person's height in meters, even if he entered his height in inches.
ここで、weight_kgは、{if(weight_units == 'kg', weight, weight * .453592)}となっています。このif()関数では、キログラムで体重が入力されていた場合は入力値をそのまま採用し、それ以外の場合は入力値(単位はポンド)に0.453592をかけてキログラムに変換します。同様に、変数height_mは、身長がインチ単位で入力されていてもメートル単位の身長を計算するようになっています。


BMI computes the weight formula as {weight_kg / (height_m * height_m)}.
BMIは、{weight_kg / (height_m * height_m)}という式で計算されます。


Lastly, the report conditionally tailors the message for the subject, telling him what he entered. ("You said you are 2 meters tall and weight 70 kg.")
最後に、回答者に対し、条件付きでカスタマイズして入力した内容を表示します。("身長2メートル、体重70キロと回答しました。"


Although not well shown in the above image, weight_status uses nested if() statements to categorize the person as underweight to severely obese.  You can see its equation in the Show Logic View
上の画像ではわかりにくくなっていますが、weight_statusは入れ子のif()ステートメントを使用し、その人物がやせているのか肥満なのかを分類します。その式をロジックビューで見ることができます。


[[File:tailoring8.jpg]]
[[File:tailoring8.jpg]]


From the edit window for this question, you can see two things:
この質問の編集ウィンドウから、次の2つのことがわかります。
#Tailoring must surround expressions with Curly Braces
#中括弧で表現を囲む必要があります
#Expressions can span multiple lines if, as in this case, you want to make it easier to read the nested conditional logic.
#式は、例えばこの例のように、ネストされた条件付きロジックを読みやすくするため、複数の行にまたがって記述することができます。


[[File:tailoring9.jpg]]
[[File:tailoring9.jpg]]


<span id="Tailored_Questions,_Answers,_and_Reports"></span>
===カスタマイズされた質問・解答・レポート===
===カスタマイズされた質問・解答・レポート===


<div class="simplebox">Note: Dynamic tailoring may not work if answer options are made available in select boxes on the same question page. This results from the fact that tailoring inserts a <nowiki><span></nowiki> tag which is not valid inside select options.</div>
<div class="simplebox">注意: 同じ質問ページの選択ボックスで回答オプションを利用できるようにすると、動的カスタマイズが機能しないことがあります。これは、選択オプション内で使えない<nowiki><span></nowiki>タグを挿入してしまうことに起因しています。</div>


This example shows the BMI report.
この例は、BMIレポートを示しています。


[[File:tailoring10.jpg]]
[[File:tailoring10.jpg]]


Here is the edit window for the same question.
同じ質問の編集ウィンドウです。


[[File:tailoring11.jpg]]
[[File:tailoring11.jpg]]


As you can see, anything in curly braces is treated as an expression, so is syntax-highlighted (color coded) in the prior image.  If you had any typos (such as misspelled or undefined variable names or functions), EM would show an error, such as this, showing that height_unit is an undefined variable name (it is actually height_units), and rnd() is an undefined function (the proper function name is round()).  In both cases, the errors are surrounded by a red box to make it easier to spot and fix them.
ご覧のように、中括弧で囲われた部分は式として扱われるので、前の画像では構文ハイライト(色分け)されています。タイプミスや定義されていない変数名や関数のような誤字があった場合、EMはこのようなエラーを表示します。例えば、height_unitは未定義の変数名(実際はheight_units)、rnd()は未定義関数(正しくはround())です。いずれの場合も、エラーを赤い枠で囲み、見つけて修正しやすくなっています。


[[File:tailoring12.jpg]]
[[File:tailoring12.jpg]]


You can also see that you can quickly create complex reports, such as a table of entered values or tailored advice.
また、入力された値の一覧やカスタマイズされたアドバイスなど、複雑なレポートをすばやく作成できます。


Please remember that all tailoring must surround expressions with Curly Braces, so that LimeSurvey knows which parts of the question are free text and which should be parsed through Expression Manager.
質問のどの部分がフリーテキストで、どの部分が式マネージャーで解析する必要があるかをLimeSurveyが判断するため、すべての式をCurly Bracesで囲む必要があります。


<span id="Validation"></span>
==検証==
==検証==


EM controls how most of the advanced question options work.  These control aspects like min/max numbers of answers; min/max individual values; min/max sum values; and checking that entered values match specified string patterns.  You continue to enter those advanced question options as usual.  However, now any value in one of those fields is considered an expression, so you can have min/max criteria with complex conditional relationships to other questions.
EMは、高度な質問オプションがどのように機能するかを制御します。回答の数、個々の入力値や合計の最小値/最大値を制限したり、入力された値が指定された文字列パターンと一致していることを確認したりします。いつものように高度な質問オプションの入力を行いますが、これらのフィールドの値はどれも式と見なされるため、他の質問と複雑な条件で組み合わせ、最小値/最大値基準を設定することができます。


In all of these cases, since the advanced question option is always considered an expression, you do not use curly braces when specifying it.
これらのすべてのケースでは、高度な質問オプションは常に式と見なされるため、中括弧を使用することはありません。


The [[Expression Manager Sample Surveys|Sample Surveys]] pages shows many working examples of using expressions for validations.
[[Expression Manager Sample Surveys|サンプルアンケート]]ページには、検証のために式を使用した実例がたくさんあります。


<span id="Introduction"></span>
=はじめに=
=はじめに=


LimeSurvey uses the new Expression Manager (EM) module which will let LimeSurvey support more complex branching, assessments, validation, and tailoring.  It will replace how LimeSurvey manages Replacements, Conditions, and Assessments on the back-end.  It will also speed up processing considerably since it eliminates most run-time database reads.  EM was developed by Dr. Thomas White (TMSWhite).
LimeSurveyでは、新しいExpression Manager(EM)モジュールを使用して、より複雑な分岐、評価、検証、およびカスタマイズがサポートされています。LimeSurveyがサーバー内で行う置換、条件、評価の管理方法を置き換えることができます。また、ランタイムデータベースの読み込みのほとんどが不要になるため、処理速度が大幅に向上します。EMはDr. Thomas White(TMSWhite)が開発しました。


This wiki page is the definitive reference for Expression Manager syntax and functionality.
このwikiページは、Expression Managerの構文と機能のリファレンスです。


==Key Definitions==
==主な定義==
#'''Expression''':  Anything surrounded by curly braces
#'''''':  中括弧で囲まれたもの
#*As long as there is no white space immediately after the opening brace or before the closing curly brace
#*開く中括弧の直後または閉じる中括弧の直前に空白がない
#*The contents of Expressions are evaluted by EM, so they can contain mathematical formulas, functions, and complex string and date processing.
#*式の内容はEMが評価するため、数式、関数、複雑な文字列と日付処理を含めることができます。
#'''Tailoring''': Sometimes called "piping", this is the process of conditionally modifying text
#'''カスタマイズ''': "パイピング"とも呼ばれますが、これは条件付きでテキストを変更するプロセスです。
#*You have access to all 'replacement fields', participant data, and response data.
#*すべての'置換フィールド'、参加者データ、回答データにアクセスできます。
#*You also have easier access to questions, answers, and their properties.
#*質問、回答、およびそのプロパティにも簡単にアクセスできます。
#'''Relevance''' Equation:  A new question attribute controlling question visiblity
#'''出現条件''':  質問を表示するかを制御する新しい質問属性
#*If there is a relevance equation, then the question is only shown if the relevance evaluates to true.
#*出現条件式がある場合、その出現条件が真と評価された場合にのみ質問が表示されます。
#*Internally, all array_filter and array_filter_exclude commands become sub-question-level relevance
#*内部では、すべてのarray_filterコマンドとarray_filter_excludeコマンドがサブ質問レベルの出現条件になります。
#'''Equation''' Question Type:  A new question type that saves calculations or reports to the database
#''''''質問タイプ:  データベースに計算やレポートを保存する新しい質問タイプ
#*It is like a Boilerplate question, but its contents are saved to the database even if you set "Always Hide this Question"
#*これはテキストを表示する質問のようなものですが、"この質問をいつも隠す"を設定しても、その内容はデータベースに保存されます。
#'''Question Code''':  This is the preferred variable name for EM
#'''質問コード''':  EMでの使用が推奨される変数名
#*This can be a descriptive name indicating the purpose of the question, making it easier to read complex logic
#*これは質問の目的を示すわかりやすい名前にすることができ、複雑なロジックを読みやすくなります。
#*Valid question codes should NOT start with a number, so when using the question code to number your questions, simply use "q1", or "q1a" or "g1q2".
#*質問コードは数字で始めることはできないので、質問番号を質問コードにするときは、単に"q1""q1a""g1q2"のようにしてください。
#*This is what currently becomes the variable name if you export data to SPSS or R, so if you do statistical analysis, you probably already made this unique.
#*現在のところ、データをSPSSまたはRにエクスポートすると、これが変数名になります。したがって、統計分析を行う場合は、ユニークにしなければなりません。


<span id="Do_I_have_to_use_EM?"></span>
==EMを使わなければならないのか?==
==EMを使わなければならないのか?==


The short answer is No (but also yes).
短い答えは「いいえ」ですが、「はい」でもあります。


EM is fully backwards-compatible with existing surveys.  So, if you are happy to use Conditions and Assessments in the style that LimeSurvey used in versions <= 1.91+, you can continue to do so.
EMは、既存のアンケートと完全に後方互換性があります。LimeSurveyバージョン1.91+以前で使用されていたスタイルの条件と評価は、引き続き使うことができます。


However, EM completely replaces how LimeSurvey internally deals with Conditions.  Although you can still use the Conditions Editor to create and manage conditions, LimeSurvey 1.92 will convert those to the equivalent Relevance Equations.  As part of the upgrade, LimeSurvey 1.92 will auto-convert all existing Conditions to Relevance Equations.
ただし、EMでは、LimeSurveyが内部的にどのように条件を処理するかについて完全に置き換えられています。条件エディタを使用して条件を作成したり管理したりすることはできますが、LimeSurvey 1.92ではそれらは同等の関連式に変換されます。アップグレードの一環として、LimeSurvey 1.92では既存のすべての条件が関連式に自動変換されます。


This should give you the best of both worlds - you can continue using LimeSurvey as you are used to, but will see the Relevance Equation equivalent so you can gradually migrate to Relevance Equations directly whenever you see fit.
これにより、新旧のいいとこ取りができます。これまで通りLimeSurveyを使い続けることもできますが、同等の関連式が表示されるので、関連式に徐々に移行することもできます。


<span id="Can_I_mix_use_of_Conditions_and_Relevance?"></span>
==条件と関連の両方を使えるか?==
==条件と関連の両方を使えるか?==


Yes. You can use the Conditions editor for some questions and the Relevance editor for others.  Conditions are auto-converted to Relevance when you save the question.
はい。質問によって条件エディターを使用することも、出現条件エディターを使用することもできます。質問を保存すると、条件は自動的に出現条件に変換されます。


Note, we assume that if you are using the Conditions editor, that you want those Conditions to over-write any manually entered Relevance equation.  So, if you have existing Conditions and want to manually edit the Relevance, please delete the Conditions for that question first.  Specifically, copy the generated relevance equation to a text editor, use the Conditions menu to delete all of the conditions for that question (which will also delete the relevance), then edit the question and paste the generated relevance equation from the text editor back into the relevance field for that question (and save the question).  If there is enough demand for deleting conditions without deleting the generated relevance equation, we could add a bulk conversion process.
条件エディターを使用している場合、手動で入力した関連式は上書きされます。したがって、すでに条件があって、関連を手動で編集したい場合は、まずその質問の条件を削除してください。具体的には、生成された関連式をテキストエディターにコピーし、条件メニューからその質問の条件をすべて削除し(関連も削除)、質問を編集し、テキストエディタからその質問の関連フィールドに貼り付け、質問を保存します。生成された関連式を削除せずに条件を削除したいというニーズが場合、一括変換プロセスの追加開発を検討します。


<span id="How_should_I_choose_between_Conditions_and_Relevance?"></span>
==条件と関連のどちらを選ぶべきか?==
==条件と関連のどちらを選ぶべきか?==


Here is a list of pros and cons of each style:
各々の長所と短所のリストを以下に示します。


{| class="wikitable"
{| class="wikitable"
!Style!!Pros!!Cons
!スタイル!!長所!!短所
|-
|-
|Conditions||1. Nice GUI for creating simple conditions <br/>2. GUI well documented and understood by support team||1. Only supports simple comparisons and does not AND/OR conditions well <br/>2. Cascading conditions work erratically <br/>3. Slow - database intensive, so can slow down long surveys <br/>4. Some reported problems with re-loading conditions <br/>5. GUI doesn't scale well when there are dozens, hundreds, or thousands of questions <br/>6. May be slow to convert paper-based surveys since must use SGQA names <br/>7. Often need a programmer to custom-code logic needed for complex branching
|条件||1. シンプルな条件を作成するための優れたGUI<br/>2. サポートチームにより文書化され理解しやすいGUI||1. 簡単な比較のみをサポートし、AND/OR条件はうまく機能しない<br/>2. カスケード条件が不安定<br/>3. データベースアクセスが遅く、アンケートに時間がかかる<br/>4. 条件のリロードで不具合がレポートされている<br/>5. GUIに拡張性がなく、何十、何百、または何千もの質問があるときにうまくいかない。<br/>6. SGQA名を使用しなければならないので、紙ベースのアンケートを変換するのが遅いかもしれない<br/>7. 複雑な分岐が必要な場合、カスタムコードロジックを書くプログラマーが必要なことがある
|-
|-
|Relevance||1. Supports very complex logic, including 80+ functions and math/string operators <br/>2. Perfect support for cascading logic <br/>3. Fast - no extra database calls, so supports 1000+ question surveys <br/>4. No problems with re-loading logic since does not require SGQA codes <br/>5. Syntax-highlighting scales to 1000+ question surveys <br/>6. Easy and fast to use for groups wanting to computerize existing paper-based suveys.  <br/>7. Easily supports semi-structured interviews and epidemiological surveys without needing a programmers||1. No GUI for simple conditions - use syntax-highlighting instead <br/>2. New, so support teams have not mastered EM yet.
|関連||1. 80以上の関数と数学/文字列演算子を含む非常に複雑なロジックのサポート<br/>2. カスケードロジックの完全サポート<br/>3. 高速 - 余計なデータベースアクセスがなく、1000以上の質問があるアンケートをサポート<br/>4. SGQAコードを必要としないため、リロードロジックで問題が生じない<br/>5. 構文ハイライト機能は1000以上の質問があるアンケートにも対応<br/>6. 既存の紙ベースのアンケートを電子化に簡単かつ迅速に対応<br/>7. プログラマーを必要とせずに半構造化インタビューや疫学調査を容易にサポート||1. 単純な条件のためのGUIがない(代わりに構文ハイライト機能を使用)<br/>2. まだ新しい機能で、サポートチームがまだEMをマスターしていない
|}
|}


The bottom is that if you are happy with how LimeSurvey 1.91+ works, there is no reason to change what you do.
LimeSurvey 1.91+の仕組みに満足していれば、変える理由はありません。


<span id="What_are_some_other_benefits_of_using_EM?"></span>
==EMのメリットは他にあるか?==
==EMのメリットは他にあるか?==


Here are some of the other reasons you might want to use EM.
EMを使うべき理由がいくつかあります。
#Calculations - you can create any calculation you can think of:
#計算 - 任意の計算式を作成することができます。
#*You have access to all common mathematical operators and functions
#*一般的な数学的演算子と関数のすべてを利用できます。
#*You have access to 70+ mathematical, date, and string processing functions
#*70以上の数学、日付、および文字列処理関数を利用できます。
#*It is fairly easy for developers to add new functions if users need them
#*必要な場合、新しい関数を簡単に追加できます。
#Storing Calculations to Database
#データベースへの計算の保存
#*You can now compute simple and complex calculations and/or scale scores AND have them stored in the database without needing JavaScript.
#*シンプル/複雑な式や評価点を計算し、JavaScriptを要せずにデータベースに保存できるようになりました。
#*You use the Equation question type to accomplish this.
#*式の質問タイプを使用してます。
#Assessments
#評価
#*You can now create assessments or scale scores from any question type, not just the subset that used to be supported
#*以前は一部のみサポートされていましたが、すべての質問タイプからの評価やスケールの作成が可能になりました。
#*You can use Tailoring to show running or total assessment scores anywhere needed - even on the same page
#*カスタマイズを使用すると、同じページであっても、必要な場所で、途中または合計の評価点数を表示できます。
#*You have more control over the reports generated based upon those assessment scores
#*評価点数に基づいて生成されたレポートをより細かくコントロールできます。
#*You can store assessment scores in the database without needing JavaScript
#*JavaScriptを使用せずに評価点数をデータベースに保存することができます。
#*You can hide assessment scores without needing JavaScript or CSS
#*評価点数は、JavaScriptやCSSを使わずに非表示にできます。
#Replacement Fields
#代替フィールド
#*Instead of using {INSERTANS:SGQA}, you can just use the Question Code - this makes it easier to read and validate.
#*{INSERTANS:SGQA}を使う代わりに、質問コードを使用すると、読みやすく、検証しやすくできます。
#*This also avoids the common need to edit questions to change the SGQA code to make everything work.
#*これにより、すべてを動作させるため質問を編集してSGQAコードを変更する必要もなくなります。
#Tailoring - you can conditionally display text based upon other values
#カスタマイズ - 他の値に基づいてテキストをカスタマイズして表示できます。#*適切な敬称を使用する(例: "Hello <nowiki>[</nowiki>Mr./Mrs.] Smith")。
#*Use the appropriate title for a subject, like (e.g. "Hello <nowiki>[</nowiki>Mr./Mrs.] Smith")
#*単数/複数に基づき文法的に正しい文章を出力する(例: "You have 1 child""You have 2 children"
#*Output gramatically correct sentences based when singular/plural matter:  (e.g. "You have 1 child" vs. "You have 2 children")
#*性や数に基づいて動詞や名詞を変化させる
#*Appropriately conjugate verbs and decline nouns based upon subject's gender and plurality.
#新しい変数の属性 - 次の項目にアクセスして調整できます。
#New Variable Attributes - you can access the following to do your tailoring:
#* (接尾辞なし) - qcode.codeの別名
#* (no suffix) -  an alias for qcode.code
#*.code - 質問が表示された場合は選択された回答コード(それ以外の場合は空白)、またはテキスト値(コード化されていない質問の場合)
#*.code - the selected response code for the question if it is relevant (otherwise blank), or the text value if it is not a coded question
#*.NAOK - .codeと同じですが、非表示となる場合であっても計算やリストに含めることができます。
#*.NAOK - same as .code, but can be part of calculations or lists even if irrelevant
#*.value - 質問が表示対象となる場合はその質問の評価値(それ以外の場合は空白)、またはテキスト値(コード化されていない質問の場合)
#*.value - the assessment value for the question if it is relevant (otherwise blank), or the text value if it is not a coded question
#*.valueNAOK - .valueと同じですが、非表示となる場合であっても計算やリストに含めることができます。
#*.valueNAOK - same as .value, but can be part of calculations or lists even if irrelevant
#*.shown - ユーザーに表示される回答(これは{INSERTANS:xxx}の機能です)
#*.shown - the answer as displayed to the user (this is what {INSERTANS:xxx}  does)
#*.qid - 質問ID
#*.qid - the question ID
#*.gid - グループID
#*.gid - the group ID
#*.sgqa - 質問のSGQA値
#*.sgqa - the SGQA value for the question
#*.jsName - (このページで定義されているかどうかに関係なく)質問に対する正しいjavascript変数名
#*.jsName - the correct javascript variable name for the question, regardless whether defined on this page or another
#*.qseq - 質問の順番(0から開始)
#*.qseq - the question sequence (starting from 0)
#*.gseq - グループの順番(0から開始)
#*.gseq - the group sequence (starting from 0)
#*.mandatory - 質問が必須かどうか(Y/N)
#*.mandatory - whether the question is mandatory (Y/N)
#*.question - 質問のテキスト
#*.question - the text of the question
#*.relevance - 質問の関連式
#*.relevance - the relevance equation for the question
#*.grelevance - グループの関連式
#*.grelevance - the relevance equation for the group
#*.relevanceStatus - 質問が表示条件を満たしているかどうか(1/0)
#*.relevanceStatus - whether or not the question is currently relevant (1 if true, 0 if false)
#*.type - 質問タイプ(1文字のコード)
#*.type - the question type (the one character code)
#ページ内の動的変更
#Dynamic On-Page Changes
#*すべての関連、計算、およびカスタマイズはページ内で動的に機能するため、値の変更によりページが即座に更新されます。
#*All Relevance, Calculation, and Tailoring works dynamically on a page - so changes in values instantly update the page
#*したがって、関連の評価結果に基づいて、質問が動的に表示/非表示になります。
#*So, you have questions dynamically appear/disappear based upon whether they are relevant
#*また、ページ内の回答に基づいて質問も動的に調整されるため、合計値、カスタマイズされた文、カスタマイズされたレポートをみることができます。
#*Questions are also dynamically tailored based upon responses on the page, so you can see running totals, tailored sentences and customized reports.
#新しいデータ入力画面
#New Data Entry Screen
#*現在のデータ入力システムを使用するだけでなく、単ページアンケートでも使用することもできます。
#*In addition to using the current data-entry system, you can just use Survey-All-In-One.
#*ページ内の関連とカスタマイズがサポートされており、データ入力担当者はタブキーで入力を進め、関連する回答を入力するだけで済みます。
#*This supports the on-page relevance and tailoring, so data entry clerks can quickly tab through and they will only have to enter the relevant responses
#*この特徴は、データ入力者がカスタマイズによる動的変化を確認する必要がある場合に重要です。
#*This can be critical if your data entry person needs to see the tailoring, which is also dynamic.
#ほとんどのカスタムJavaScriptの必要性を排除
#Eliminates the need for most custom JavaScript
#*EMは、複雑な計算、点数づけ、カスタマイズ、および条件付きロジックを容易にサポートします。
#*EM easily supports complicated computations, scoring, tailoring and conditional logic.
#*JavaScript(カスタムレイアウトや条件付きの質問サブ要素など)を必要とするものもありますが、JavaScriptによって、EM関数を使用してSGQAの代わりにQcodeで質問にアクセスし、上記の質問属性にアクセスすることができます。
#*Some things will still need JavaScript (like custom layouts and conditionally hiding question sub-elements), but your JavaScript can use the EM functions so that you can access questions by their Qcode instead of SGQA, and access any of the question properties listed above.


==EMでできるようになった新しい機能は他にないか?==
<span id="What_are_some_other_helpful_new_features_enabled_by_EM?"></span>
==式マネージャーのその他の新機能==


Regardless of whether you continue to use the Conditions Editor or manually compose Relevance Equations, you get these additional benefits:
条件エディターを引き続き使用するか、または関連式を手動で作成するかにかかわらず、次のような利点があります。
#You can create more complex validation criteria
#より複雑な検証基準を作成することができます。
#*All of the advanced question attribute (like max_answers, min_num_value_n, max_num_value) can use Expressions.  So, you min/max criteria can be easily adjusted based upon prior responses, even if they are on the same page.
#*すべての高度な質問属性(max_answers、min_num_value_n、max_num_valueなど)は式を使用できます。したがって、最小値・最大値の条件は、同じページの先行する質問の回答に基づいて簡単に調整できます。
#*EM also handles all regular-expression-based validation, so you can robustly combine preg and equation-based question attributes.
#*EMは正規表現ベースの検証をすべて処理するので、pregと式ベースの質問属性を強固に組み合わせることができます。
#Easy Re-ordering (or deleting) of Questions and Groups
#質問とグループの並べ替え(または削除)が容易にできます。
#*Prior to version 1.92, you could not re-order questions or groups if LimeSurvey thought that such-re-ordering could break conditions in which they were used.  Similarly, you could not delete questions if any other questions depended upon them.
#*バージョン1.92より前のバージョンでは、並べ替えによって条件が成立しなくなる可能性があると認識された場合、質問やグループの並べ替えはできませんでした。同様に、ある質問に依存する質問がある場合は、その質問を削除できませんでした。
#*With EM's syntax highlighting, it is easy to see and validate whether you try to use questions before they are declared.  So, we now let you re-order or delete questions and groups whenever you like.  EM will update all of the syntax highlighting to show you potential errors.
#*EMの構文強調表示により、これから宣言して使おうとしている質問を確認し、検証することが簡単にできです。したがって、いつでも質問やグループを並べ替えたり、削除したりすることができます。EMは潜在的なエラーを表示するためにすべての構文強調表示を更新します。
#*The re-order questions view has been enhanced to help with such review.  It now shows the question's relevance equation and tailoring, so you can immediately see whether any variables become pink (meaning they are used before being declared).
#*このようなレビューに役立つように、質問並べ替えの表示が強化されました。質問の関連式とカスタマイズが表示されるので、変数がピンク(宣言する前に使用されていることを意味します)になったかどうかをすぐに確認できます。
#The Question/Group Navigation Index is always available and accurate
#質問やグループのナビゲーション番号は常に利用可能で正確です。
#*Prior to version 1.92, these indexes were not available if there were complex conditions
#*バージョン1.92以前は、複雑な条件があった場合、ナビゲーション番号は利用できませんでした。
#*With EM, we can guarantee that they are accurate.
#*EMでは、正確であることを保証されています。
#*Subjects can even jump back, to a prior question, change the answer, then jump forward (or submit)
#*前の質問に戻り、答えを変えてから、後ろにジャンプする(または送信する)こともできます。
#**When jumping forwards, EM will re-validate all of the intervening questions/groups.
#**前進すると、EMは関係するすべての質問/グループを再検証します。
#**If any questions become irrelevant, they will be NULLed in the database so that your data is internally consistent
#**表示条件に該当しなくなる質問があれば、データは内部で一貫性を保つためデータベースにNULLが格納されます。
#**If any questions become relevant or newly fail mandatory or validation rules, EM will stop on that page and force the user to answer those questions before jumping to their final destination.
#**質問が表示条件に該当したり、新たに必須条件または検証ルールに適合しなくなった場合、EMはそのページで停止し、ユーザーが最終ページに飛ぶ前にそれらの質問に答えなければならないようにします。
#Auto-conversion of Conditions to Relevance
#条件から関連への自動変換
#*When you upgrade your database, all existing surveys that have conditions will have relevance equations generated for them
#*データベースをアップグレードすると、条件を持つ既存のすべてのアンケートに関連式が生成されます。
#*Whenever you import a survey, relevance equations will be created as needed
#*アンケートをインポートするたびに、関連式が必要に応じて作成されます。
#*Whenever you add, delete, or modify conditions, EM will generate the appropriate relevance equation.
#*条件を追加、削除、または変更すると、EMは適切な関連式を生成します。
#Convenient Syntax Highlighting
#便利な構文強調表示
#*When EM shows the relevance equation, it will show the Qcode, even if you entered an SGQA code, as we assume this will be easier to read.
#*SGQAコードを入力した場合であっても、EMが関連式を表示するときは、Qcodeが表示されます。読みやすくするためです。
#*All variables are color coded to show whether they were declared before or after the current question (or before or after the current group).  This lets you quickly detect and fix cases where you try to use variables for relevance (including array_filter), tailoring, or validation equations prior to declaring them.
#*すべての変数は、現在の質問の前後(または現在のグループの前後)に宣言されたかどうかを示すために色分けされています。これにより、変数を宣言する前に、関連(array_filterを含む)、カスタマイズ、検証式で使用する変数を使うケースをすばやく検出して修正できます。
#*In addition, if you hover your mouse over the color-coded variable, you will see the most important metadata about that question.   This includes the Group Sequence #, Question Sequence #, Qcode, Text of the question, and all available answer choices (if it is a question type with enumerated answer choices).
#*色付けされた変数の上にマウスを移動すると、その質問に関する追加情報が表示されます。これには、グループ番号、質問番号、Qcode、質問のテキスト、利用可能な回答の選択肢(該当する質問タイプの場合)が含まれます。
#**The list of answer choices uses this syntax:  'answers':{key:val, ... }.
#**回答の選択肢のリストは、次のような構文を使用します: 'answers':{key:val, ... }.
#**''key'' has the syntax ''''scale~code'''' where ''scale'' is the answer scale (e.g. for dual scale), and ''code'' is the answer code.
#**''key''''''scale~code''''という構文となります。''scale''は回答の尺度(二元スケールなど)、''code''は回答コードです。
#**''val'' has the syntax ''''value~shown'''' where ''value'' is the assessment value (if using assessments, otherwise ''code'')(e.g. Qcode.value), and ''shown'' is the display value as seen by the subject (e.g. Qcode.shown)
#**''val''''''value~shown''''という構文となります。''value''は評価値(評価を使う場合。その他の場合は''コード'')、''shown''は表示される値です(Qcode.shownなど)。
#**This means that many surveys can use calculations without needing assessment mode.  If you have enumerated answer options  that are unique, non-decimal, and non-negative, you can simply do calculations on the Qcode.code values.
#**つまり、多くの場合、アンケートで評価モードを使わずに計算を使用できます。ユニークで、10進数でなく、負の数でない回答オプションを列挙する場合は、Qcode.code値の計算を行うことができます。
#Easy review of entire survey logic and content
#アンケートロジックとコンテンツ全体の簡単なレビュー
#*There is a new Show Survey Logic feature that lets you see everything about the survey (or group or question) on a single page.
#*新しいアンケートロジック表示機能があり、アンケート(またはグループ、質問)に関するすべての情報を1ページに表示できます。
#*It shows the Group, Question, Sub-Question, and Answer-level details for the selected scope (survey vs. group vs. question)
#*選択したスコープ(アンケート、グループ、質問)のグループ、質問、サブ質問、回答レベルの詳細を表示します。
#*It also shows the relevance, sub-question-level relevance (for array_filter and array_filter_exclude), and generated validation equation (for preg and any validation rules like min/max sum/number of values), and all non-blank question attributes.
#*また、関連、サブ質問レベルの関連(array_filterとarray_filter_exclude)、生成された検証式(pregと合計の最小値・最大値、値の数などの検証ルール)、およびすべての空白以外の質問属性も表示されます。
#*Everything is syntax-highlighted so that you can see potential syntax errors (like unbalanced parentheses or use of variables before they were declared)
#*すべて構文強調表示されているため、潜在的な構文エラー(括弧の不一致、未宣言の変数使用など)を発見できます。
#*The syntax-highligting supports rapid navigation and editing of the survey.
#*構文強調表示により、アンケートのナビゲーションと編集が迅速にできるようになります。
#**If you click on a variable name, it opens a browser window (or tab) that shows you that question and lets you edit it.
#**変数名をクリックすると、その質問を示すブラウザウィンドウ(またはタブ)が開き、編集することができます。
#**If you click on a group name, it opens a browser window (or tab) showing the group-reorder view so that you can easily move questions around.
#**グループ名をクリックすると、グループの並べ替えビューを表示するブラウザウィンドウ(またはタブ)が開き、簡単に質問を移動できます。
#**All of the question attributes are also syntax highlighted.  This lets you set and see expressions within advanced question options (like basing the max/min number/sum of values on an expression)
#**すべての質問属性も構文強調表示されています。これにより、高度な質問オプション内で式を設定したり表示したりすることができます(式の最大値/最小値/合計など)
#*The EM author used similar view (a little cleaner) to let his collaborating Epidemiologists and Institutional Review Board validate and authorize surveys with thousands of questions in highly branched and tailored structured interviews
#*EMの製作者は、似たようなビューを使い、疫学者と治験審査委員会が高度に分岐する、何千もの質問があるアンケートを検証し、認可できるよう協力しました。


<span id="Getting_Started"></span>
=始めてみる=
=始めてみる=


The best way to get started with EM is to:
式マネージャーを始める最善の方法は以下のとおりです。
*Install the latest stable version from http://www.limesurvey.org/en/download
*http://www.limesurvey.org/en/downloadからLimeSurveyの最新の安定版をインストールしてください。
*Import and explore the [[Expression Manager Sample Surveys|sample surveys]].
*[[Expression Manager Sample Surveys|サンプルアンケート]]をインポートして確認します。
*Explore the [[Expression Manager HowTos|use cases and HowTos]] and [[Expression Manager Examples|step-by-step examples]].
*[[Expression Manager HowTos|使用例と使用法]][[Expression Manager Examples|ステップバイステップの例]]を読んでください。
*Explore the EM documentation (this page)
*EMに関するドキュメント(このページ)を読んでください。
*Examine the built-in EM test suite
*ビルトインのEMテスト環境を試してみてください。
**From any survey, under tools, select the EM option
**それぞれのアンケートのツールの下にあるEMオプションを選択します。
**Available Functions lists the 70+ functions and syntax
**使用可能な関数として、70以上の関数と構文を表示します。
**Unit Tests of Isolated Expressions
**分離された式の単体テスト
***shows examples of using all EM functions and operators, and the PHP and JavaScript results
***すべてのEM関数と演算子、PHPとJavaScriptの結果の使用例を表示します。
***note there are few functions that generate different results in the PHP and JavaScript versions, so this page lets you plan your EM logic accordingly.
***PHPとJavaScriptのバージョンで異なる結果を生成する関数はほとんどありません。このページの内容を踏まえ、EMロジックを適切に計画することができます。


=式マネージャーでは、どの機能が拡張/置換されたのか?(LimeSurvey 1.91)What Functionality does Expression Manager Extend/Replace? (LimeSurvey 1.91+から)=
<span id="What_Functionality_does_Expression_Manager_Extend/Replace?_(LimeSurvey_&lt;=_1.91+)"></span>
=式マネージャーでは、どの機能が拡張/置換されたのか?(LimeSurvey 1.91から)=


<span id="Conditions_=&gt;_Relevance"></span>
==条件 → 関連==
==条件 → 関連==


Conditions controlled which  questions are visible.  The general syntax was ''SGQA operator Value'', like ''111X2X3 == "Y"''.  Conditions could be ANDed or ORed together, but mixing ANDs and ORs was difficult.  The conditions themselves were stored in a separate table, and large portion of LimeSurvey's code was devoted to managing Conditions.  Because of extensive database access, processing large numbers of conditions could cause noticable performance problems.  Furthermore, once you had conditions assigned to questions or groups, you were often not allowed to re-order or delete them.
どの質問が表示されるかを制御する条件。一般的な構文は、''111X2X3 == "Y"'''のような''SGQA 演算子 値''でした。条件はANDまたはORを組み合わせることができますが、ANDとORを混在させることは困難でした。条件自体は独立したテーブルに保存され、LimeSurveyのコードの大部分は条件の管理に費やされていました。膨大なデータベースアクセスのため、多数の条件を処理すると、パフォーマンス上の深刻な問題が発生する可能性がありました。さらに、条件が質問やグループに一旦割り当てられると、それらを並べ替えたり削除したりすることはできませんでした。


<span id="Assessments_=&gt;_Equations_and_Micro-Tailoring"></span>
==評価 → 式と細かいカスタマイズ==
==評価 → 式と細かいカスタマイズ==


Assessments let users create scale scores from a collection of questions.  However, they could not dynamically change on the current page, and their values were not stored to the database.
評価機能により、一連の質問から評価値を算出することができます。ただし、表示中のページ内で動的に変更することはできず、またその値はデータベースに保存されませんでした。


<span id="Replacements_=&gt;_Micro-Tailoring"></span>
==置換 → 細かいカスタマイズ==
==置換 → 細かいカスタマイズ==


Users could tailor some messages and questions based  upon prior responses.  For example, a question might be, ''{TOKEN:FIRSTNAME}, you said {INSERTANS:111X3X4} was your favorite sport''.  However, it was not possible to do conditional tailoring (like say "Mr." or "Mrs." depending upon the person's gender), or conjugate verbs or decline nouns without fancy JavaScript.  Authors could implement surveys that seemed to tailor questions, but it required separate questions for each permutation, and complex conditions to decide which questions to display.
ユーザーは、先行する回答に基づいてメッセージや質問をカスタマイズできます。たとえば、''{TOKEN:FIRSTNAME}さん、あなたは{INSERTANS:111X3X4}が好きなスポーツだと回答しました''のような質問が可能です。しかし、条件付きのカスタマイズ(性別に応じて"Mr.""Mrs."をつけるなど)や、動詞や名詞を変化させたりすることはJavaScriptなしにはできませんでした。質問をカスタマイズするようなアンケートを実装することはできましたが、すべての組み合わせに対する個別の質問が必要であり、表示する質問を決定する複雑な条件が必要でした。


<span id="Validation"></span>
==検証==
==検証==


Question could be validated with Regular expressions, or minimum/maximum values, or let an SGQA response serve as the minimum or maximum value.  However, validations could not be based upon calculations of other variables without fancy JavaScript.
質問は、正規表現や最小値/最大値で検証するか、SGQAの回答を最小値または最大値として使用することができました。ただし、JavaScriptなしで他の変数の計算に基づいて検証することはできませんでした。


<span id="Equations"></span>
==式==
==式==


Equations were not supported without fancy JavaScript.
式はJavaScriptなしでは実現できませんでした。


<span id="Equation_Question_Type"></span>
==式の質問タイプ==
==式の質問タイプ==


Equations could not be saved to the database (e.g. the final score for an assessment) without fancy JavaScript.
JavaScriptを使用せずに式をデータベースに保存すること(評価の最終スコアなど)はできませんでした。


<span id="How_Will_Expression_Manager_Replace/Extend_That_Functionality?"></span>
=式マネージャーはどのように機能を拡張するのか?=
=式マネージャーはどのように機能を拡張するのか?=


The Expression Manager is a new core module within LimeSurvey that makes it much easier to support the type of complex functionality that used to require custom JavaScript.  It is also replacing the way LimeSurvey currently manages Conditions and Assessments.
式マネージャーは、カスタムJavaScriptを必要とする複雑な機能をより簡単に実現できるLimeSurveyの新しいコアモジュールです。LimeSurveyが条件と評価を管理する現場の方法に取って代わるものです。


<span id="New_Terminology_When_Referring_to_Expression_Manager_(EM)"></span>
==式マネージャー(EM)向けの新しい用語==
==式マネージャー(EM)向けの新しい用語==


EM "thinks" of its functionality in the following terms:
EMは次のように機能を定義しています。
*'''Relevance-based Branching''' - if a question is relevant, then ask it, otherwise don't (e.g. make it invisible, and mark it as NULL in the database).  There is a new Relevance field for all Question types, and also for each Group (so you can apply a set of conditions to an entire group without having to copy the same condition to each question, and/or combine group and question-level conditional logic).
*'''関連に基づく分岐''' - 質問が関連する場合は表示し、そうでない場合は非表示にします(データベースにNULLとしてマークします)。すべての質問タイプと各々のグループに対して新たな関連フィールドが追加されています(したがって、各質問に同じ条件をコピーしたりすることなくグループ全体に条件を設定でき、また、グループレベルと質問レベルの条件を組み合わせることができます)。
*'''Tailoring''' - Once you know which questions should be asked, tailoring (sometimes called ''piping'') specifies how the question should be asked. This lets you support not only simple subsitution (like {TOKEN:FIRSTNAME}), but also conjugation of verbs and declination of nouns based upon the gender or number of your subjects.  It also lets you change the message you deliver to a subject based upon whether they answered (or how they answered) other questions.
*'''カスタマイズ''' - どの質問を聞くべきかを決めたら、カスタマイズ(''パイピング''とも呼ばれる)によって、質問方法を指定します。これは簡単な置き換え(例:{TOKEN:FIRSTNAME})だけでなく、性別や人数によって動詞や名詞の変化も可能です。また、他の質問に回答したか(または回答内容)に基づいて、送信するメッセージを変更することもできます。
*'''Equations''' - EM adds a new question type called Equation which stores the result of an Expression.  These equations results are computed and written to the database, even if you hide them on the page.  Thus, they are useful for hidden scoring calculations, navigation based upon complex equations, assessments, and reports that should be generated and easily available within the database.
*'''''' - EMでは、式の結果を格納する新しい質問タイプ(式)が追加されました。式の結果は、たとえページ上で非表示であって、計算結果はデータベースに書き込まれます。これにより、裏で行われるスコア計算、複雑な式に基づくナビゲーション、評価、およびレポートの作成が可能になり、データベース上で簡単に利用することができます。


<span id="Relevance_and_Cascading_Relevance"></span>
===関連とカスケードされた関連===
===関連とカスケードされた関連===


Every question type now has a Relevance option which controls whether the question is displayed.  EM processes each of the Relevance Equations in the order they should appear in the survey.  If the expression is true (or missing - to support legacy surveys), the question will be displayed. If it is not relevant, then the question will be hidden, and the value will be NULLed in the database.  If there are no relevant questions in a group, the entire group will be skipped.
すべての質問タイプで、質問が表示されるかどうかを制御する関連オプションが追加されました。EMは、アンケートに登場する順に関連式を処理します。式が真(または式がない - 古い形式のアンケート向け)の場合、質問が表示されます。関連が偽の場合、質問は非表示になり、その値はデータベースでNULLになります。グループに関連する質問がない場合、グループ全体がスキップされます。


Moreover, if any of the variables within an expression is irrelevant, then the expression always evaluates to false.  This enables Cascading Relevance so that you do not have to write very long Relevance equations for each question.
さらに、式に含まれる変数のいずれかの関連が偽の場合、式は常に偽と評価されます。これにより関連の入れ子が可能になり、各々の質問に対して非常に長い関連式を書く必要がなくなります。


Say you have 5 questions Q1-Q5, and you only want to show Q2 if Q1 was answered, and Q3 if Q2 was answered, etc.  The relevance equations might be:
たとえば、5つの質問Q1〜Q5があり、Q1が答えられたらQ2、Q2に答えられたらQ3などを表示したいとします。関連式は次のようになります。


{| class="wikitable"
{| class="wikitable"
!Question Code!!Relevance!!Question
!質問コード!!関連!!質問
|-
|-
|Q1||1||What is your name?
|Q1||1||名前は何ですか。
|-
|-
|Q2||Q1||{Q1}, how old are you?
|Q2||Q1||{Q1}さん、何歳ですか。
|-
|-
|Q3||Q2||So, you are {Q2} years old.  Are you married?
|Q3||Q2||{Q2}歳なのですね。結婚していますか。
|-
|-
|Q4||Q3 == "Y"||{Q1}, how long have you been married?
|Q4||Q3 == "Y"||{Q1}さん、結婚して何年になりますか。
|-
|-
|Q5||Q4||How many children do you have, {Q1}?
|Q5||Q4||{Q1}さん、子供は何人いますか。
|}
|}


The relevance calculations also work in JavaScript - so you could put all the above questions on one page and it would still work as expected.  In fact, EM totally replaces how EM processes Survey vs. Group vs. Question-at-a-time survey formats.  They now all use the exactly same navigation engine so they work identically regardless of survey style.
関連性の計算はJavaScriptでも機能しますので、上記のすべての質問を1ページに置くことができ、期待どおりに動作します。実際、EMは、アンケート、グループ、一画面での一斉質問フォーマットの仕組みを完全に置き換えています。今では、まったく同じナビゲーションエンジンを使用しているので、アンケートスタイルに関係なく同じように動作します。


As long as you are on the same page, any data you entered will still be there, just hidden.  So, if you enter some information, then choose an option that makes them irrelevant, then make them relevant again, your answers will still be available.  However, as soon as you move to a different page, all irrelevant responses will be lost to integrity of the dataset.
同じページにいる限り、入力した回答データは隠れていますが保持されています。したがって、情報を入力たあと、出現条件を満たさなくなるようなオプションを選択し、再び出現条件を満たすような選択をすると、回答は引き続き利用可能になります。ただし、別のページに移動すると、データセットの整合性を保つため、出現条件を満たさないすべての回答は失われます。


===グループレベルの関連===
<span id="Group-Level_Relevance"></span>
===グループレベルの出現条件===


Expression Manager also supports group-level relevance.  This makes it easier to implement looping.   Say you want to collect information about up to 10 entities (such a products or people in a household), where you first determine how many entities need follow-up (such as by asking how many people live in a household, or having people check which products they like from a long list).  After knowning how many entities need follow-up, you can use Group-level relevance like {count >= 1}, {count >=2}, ... {count >= 10} for each of the 10 groups of follow-up questions.  Within each group, you can have question-level conditional logic (e.g. gender or age-specific follow-up questions for each subject).  The question and group-level relevance equations are ANDed together to determine which should be shown.
式マネージャーはグループレベルの出現条件もサポートしています。これにより、ループ(繰り返し)の実装が容易になります。最大10個の事柄(たとえば、製品や家庭内の人物など)に関する情報を収集するため、まずその数を質問するとします(例えば、家族の人数を聞いたり、リストの中からどの製品が好みなのかを選んでもらったりして)。後から繰り返し聞くべき回数が分かったら、10個用意したグループごとに{count>=1}{count>=2}... {count>=10}といった形で、グループレベルの出現条件を設定することができます。それぞれのグループ内では、質問レベルの条件付きロジック(例:回答者の性別や年齢別の質問)を作成することができます。質問とグループレベルの出現条件の式は、表示すべきかを決定するためにAND演算されます。


<span id="Tailoring_/_Piping"></span>
===カスタマイズ/パイプ===
===カスタマイズ/パイプ===


Anything within curly braces is now treated as an Expression (with one exception described below).  Expressions have acccess to all of the LimeReplacementFields, all of the variables (via several aliases), all typical equation operators (mathematical, logical, and comparison), and dozens of functions (that even work dynamically on the client-side).
中括弧内のものはすべて式として扱われるようになりました(後述する例外が1つあります)。式はすべてのLimeReplacementFields、すべての変数(いくつかのエイリアスを介して)、すべての一般的な演算子(数学、論理、比較)、数多くの関数(クライアント側でも動的に機能する)にアクセスします。


Using these equations, you can do things such as:
これらの式を使用すると、次のようなことができます。
#Conditionally show tailored messages to the respondants based upon prior responses
#先行する質問への回答に基づいて回答者に条件付きでメッセージを表示する
#Create Assessments and show Assessment results (or conditionally branch or show messages) based upon those results, all without using the Assessments module itself
#評価を作成し、その結果に基づいて評価結果を表示する(条件付きで分岐するまたはメッセージを表示する)(評価モジュール自体は使用しない)
#Conjugate verbs and decline nouns within questions, answers, and reports.
#質問、回答、およびレポート内の動詞、名詞を変化させる
#Show summaries of responses before the "Show your answers" page at the end of the survey
#アンケートの最後で、"回答を表示する"ページの前に回答の要約を表示する


<span id="Equations"></span>
===式===
===式===


There is a new question type called  Equation.  It is like a Boilerplate questions, except that it stores the value of what is displayed in the database.  So, if the Equation Question text contains an Assessment computation, that value would be stored in the database in a variable that can be displayed within public or private statistics.
式と呼ばれる新しい質問タイプがあります。これは、表示されている値をデータベースに格納することを除き、テキスト表示タイプの質問と似ています。したがって、式の質問テキストに評価計算が含まれている場合、パブリックまたはプライベート統計情報内に表示できる変数の値がデータベースに格納されます。


This solves a common request for storing Assessment scores within the database
これにより、データベース内に評価スコアを格納したいというニーズが解決します。


<span id="Syntax"></span>
==構文==
==構文==


Anything contained within curly braces is now considered an Expression (with one exception:  there must be no leading or trailing whitespace - this is needed to ensure the Expression Manager does not try to process embedded JavaScript).
中カッコ内に含まれるものはすべて式と見なされます(ただし、先頭または末尾に空白がないことが必要です。これは、式マネージャーが埋め込みJavaScriptを処理しないようにするためです)。


Note, it is OK for expressions to span multiple lines, as long as there is no whitespace after the opening  curly brace or before the closing curly brace.  This is especially helpful for nested if() statements like this:
開く括弧の後、閉じる括弧の前に空白がない限り、式は複数の行にまたがっても構いません。特に次のような入れ子のif()構文が見やすくなります。


<syntaxhighlight lang="java" enclose="div">{if(is_empty(PFTotals),
<syntaxhighlight lang="java">{if(is_empty(PFTotals),
 '',
 '',
 if(PFTotals >= -5 && PFTotals <= -4,
 if(PFTotals >= -5 && PFTotals <= -4,
Line 385: Line 414:
</syntaxhighlight>
</syntaxhighlight>


<div id="EMsyntax">Expression Manager supports the following syntax:</div>
<div id="EMsyntax">式マネージャーは次の構文をサポートしています。</div>
*All standard mathematical operators (e.g. +,-,*,/,!)
*すべての標準的な数学演算子 (例: +,-,*,/,!
*All standard comparison operators (e.g. <,<=,==,!=,>,>=, plus these equivalents:  lt,le,eq,ne,gt,ge)
*すべての標準的な比較演算子(例: <,<=,==,!=,>,>=, およびこれらと同等のもの: lt,le,eq,ne,gt,ge)
*Parentheses (so you can group sub-expressions)
*括弧(式のグルーピング)
*Conditional operators (e.g. &&,| | and these equivalents: and,or)
*条件演算子(例: &&,||, およびこれらと同等のもの: and,or)
*Single and double-quoted strings (which can each embed strings with the other quote type)
*シングルクォートやダブルクォートで囲まれた文字列(それぞれが他のクォートタイプの文字列を埋め込むことができます)
*Comma operator (so can have a list of expressions and just return the final result)
*コンマ演算子(式のリストを持つことができ、最終結果を返すことができます)
*Assignment operator (=)
*代入演算子(=
*Pre-defined variables (to refer to questions, question attributes, and responses) - e.g. all of the SGQA codes
*定義済みの変数(質問、質問属性、回答を参照するため) - 例: すべてのSGQAコード
*Pre-defined functions (there are already 70+, and it is easy to add more)
*定義済みの関数(既に70以上ありますが、簡単に追加できます)


<span id="Operators"></span>
=== 演算子 ===
=== 演算子 ===


EM syntax follows normal operator precedence:
EM構文は、通常の演算子の優先順位に従います。


{| class="wikitable"
{| class="wikitable"
!Level!!Operator(s)!!Description
!レベル!!演算子!!説明
|-
|-
|1||()||parentheses for grouping or calling functions
|1||()||グループ化または関数呼び出しのための括弧
|-
|-
|2||! - +||unary operators: not, negation, unary-plus
|2||! - +||単項演算子: 否定、正負
|-
|-
|3||* /||times, divide
|3||* /||乗算、除算
|-
|-
|4||+ -||plus, minus
|4||+ -||加算、減算
|-
|-
|5||< <= > >= lt le gt ge||relative comparisons
|5||< <= > >= lt le gt ge||比較演算子
|-
|-
|6||== != eq ne||equality comparisons
|6||== != eq ne||同等比較
|-
|-
|7||and||logical AND
|7||and||論理積 AND
|-
|-
|8||or||logical OR
|8||or||論理和 OR
|-
|-
|9||=||assignment operator
|9||=||代入演算子
|-
|-
|10||,||comma operator
|10||,||コンマ演算子
|}
|}


Note, for consistency between JavaScript and PHP, the plus operator (+) does addition if both operands are numeric, but does concatenation if both parts are non-numeric strings.  However, we recommend using the join() function for concatenation, as that makes your intent more clear, and avoids unexpected results if you were expecting strings but got numbers instead (or vice versa).
<span id="Warning_with_plus_operator_(+)"></span>
====プラス演算子に関する注意(+)====


JavaScriptとPHPの間の一貫性を保つために、プラス演算子(+)は両方のオペランドが数値の場合は加算を行いますが、両方の部分が数値以外の文字列の場合は連結します。しかし、意図をもっとはっきりさせるため、連結関数join()を使うことをお勧めします。
<span id="Warning_with_mismatch_between_number_and_string_and_alphabetic_comparison"></span>
====数と文字列の型の不一致、および文字列としての強制比較に関する注意====
値を不等号や等号で比較する場合は、値の型の不一致に注意してください。ユーザーが入力した値や選択した回答コードが明確に数値であれば、数値として使用されます。
いずれかの値が<code>"</code>で囲まれている場合: 強制的にテキストとして比較します。数値として比較したい場合は<code>"</code>で囲んではいけません。
たとえば、Q0.NAOKが値として9をもつ数値型質問である場合、<code>Q0.NAOK > "50"</code>はtrueです。
整数値を確実に比較するには、<code>[[Expression_Manager/ja#.E5.AE.9F.E8.A3.85.E6.B8.88.E3.81.BF.E9.96.A2.E6.95.B0|intval]](Q0.NAOK) > 50</code>を使用します。Q0.NAOKが数値でない(空または文字列)場合は、intval(Q0.NAOK) === 0となります。文字列値を比較する("A" < "B")場合は、直接[[Expression_Manager/ja#.E5.AE.9F.E8.A3.85.E6.B8.88.E3.81.BF.E9.96.A2.E6.95.B0|strcmp]]を使用します。<code>strcmp(Q0.NAOK,"B")</code>または<code>strcmp(Q0.NAOK,"A5")</code>
<span id="Caution_about_using_Assignment_Operator_(=)"></span>
===代入演算子(=)を使用する際の注意 ===
===代入演算子(=)を使用する際の注意 ===


Note, you should avoid using the assignment operators unless absolutely necessary, since they may cause unexpected side-effects.  For example, if you change the value of a previous response, the cascading relevance and validation logic between that question and the current question is not re-computed, so you could end up with internally inconsistent data (e.g. questions that stay answered but should have been NULLed, or questions that are skipped but should have been answered).  In general, if you want to assign a value to a variable, you should create an Equation question type, and use an expression to set its value.  However, there are some rare times that people really need this operator, so we made it available.
代入演算子は、予期せぬ副作用を引き起こす可能性があるため、絶対に必要でない限り、使用しないでください。たとえば、先行する回答の値を変更した場合、その質問と現在の質問との間のカスケードされた出現条件と検証ロジックは再計算されないため、内部的に一貫性のないデータになりえます(たとえば、NULLであるべきものに回答が残る、回答があるべきなのにスキップされる、など)。一般に、変数に値を割り当てる場合は、式の質問タイプを作成し、その値を設定するための式を使用する必要があります。しかし、本当に必要なことがまれにあるため、この演算子が用意されています。
 
この演算子について注意を促すため、構文式の中では赤いフォントで表示されています("=="と混同しないようにするため)。
 
===代入演算子を使う===
代入を使用する主な理由は次のとおりです。
*式を使った既定値を設定できない質問の既定値を設定する必要がある(ユーザーインターフェイスでは回答オプションの1つを選択できるが、式を入力することができないリスト、ラジオなど)。ただし、LimeSurveyは式がその質問に対する許容可能な回答を生成できるかどうかを検証できないため、注意して使用してください。
*後続の回答に基づいて先行する質問への回答を強制的に変更する必要がある
* など...


To help caution you about this operator, it is shown in red font within the syntax equations (so that you don't confuse it with "==")
この目的のために、式マネージャーシステムを使用することができます。


===Using Assignment Operator===
{{Alert|つまり、ページ内の値を更新するのではなく、ユーザーがページを移動したり保存したりしたときだけ演算が行われます。}}
The main reasons you may want to use assignment are:
*You need to set the default value for a question that does not accept defaults via equation (such as list radio, where the user interface lets you pick one of the answer options, but does not let you enter an equation).  However, be careful, as LimeSurvey will not be able to validate that your equation generates one of the allowable answers for that question.
*You need to forcibly change the response to a previous question based upon a later response
* etc...


You can use all expression manager system for this purpose. It's better to use an [[Question_type_-_Equation|Equation question]] type to this purpose.
{{Alert|[[Question_type_-_Equation/ja|式質問]]タイプをこの目的に使用しない場合、現在のページのロジックが完了した後にのみassigmentdが実行されます。常に[[Question_type_-_Equation/ja|式質問]]を使用することが推奨されます。}}


Some example:
:
* Set answer to a short text question in lowercase : <code>{QCODE=strtolower(QCODE.NAOK)}</code>
* 質問への回答を小文字にする: <code>{QCODE=strtolower(QCODE.NAOK)}</code>
* Set a default answer to an array question type at start of a survey : <code>{Q1_SQ1=(is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}</code>
* アンケート開始時に配列質問タイプに対する既定の回答を設定する: <code>{Q1_SQ1=((is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}</code>
* Set a default answer to an array texts question type at start of a survey : <code>{Q1_SQY1_SQX1 = (is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}</code>
* アンケート開始時に配列テキストの質問タイプに対する既定の回答を設定する: <code>{Q1_SQY1_SQX1 = ((is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}</code>
* Set an answer with condition : <code>{QCODE=if(YesNo="Y","A1","")}</code>
* 条件付きの回答を設定する: <code>{QCODE=if(YesNo="Y","A1","")}</code>


<span id="XSS_security"></span>
== XSS セキュリティ ==
== XSS セキュリティ ==


With XSS enable, some expression manager system can not be used :
XSSを有効にすると、式マネージャーシステムの一部が使用できなくなります。
* starting a HTML tag in expression but ending in another expression
* 式の中でHTMLタグを開き、別の式で閉じる
* use a complex expression in URL.
*URLに複雑な式を使用する


Example and workaround
例と解決策
* <code>{if( 1 ,"&lt;strong&gt;","")}information{if( 1 ,"&lt;/strong&gt;","")}</code> is broken with XSS security, here you can use <code>{if(1,"<strong&gt;information&lt;/strong&gt;","information")}</code>
* <code>{if( 1 ,"&lt;strong&gt;","")}information{if( 1 ,"&lt;/strong&gt;","")}</code>はXSSでは正常に動作しないため、次のようにします。<code>{if(1,"<strong&gt;information&lt;/strong&gt;","information")}</code>
* <code>&lt;a href="/script.php?value={if(QCODE == "Y","yes","no")}"&gt;next&lt;/a&gt;</code>, here you can use an equation question because using a complete question code is OK : <code>&lt;a href="/script.php?value={EQUATION.NAOK}"&gt;next&lt;/a&gt;</code>
* <code>&lt;a href="/script.php?value={if(QCODE == "Y","yes","no")}"&gt;next&lt;/a&gt;</code>は、ここでは式の質問を使います。なぜなら、完全な質問コードが使用できるからです。<code>&lt;a href="/script.php?value={EQUATION.NAOK}"&gt;next&lt;/a&gt;</code>


<span id="Access_to_Variables"></span>
==変数へのアクセス==
==変数へのアクセス==


Expression Manager provides read-only access to whichever variables we might need.  For backwards compatibility, it provides access to the following:
式マネージャーでは、必要な変数に読み取り専用でアクセスできます。下位互換性を保つため、次のものにアクセスすることができます。
*TOKEN:xxx - the value of a TOKEN (e.g. TOKEN:FIRSTNAME, TOKEN:ATTRIBUTE_5) (Only for NOT anonymous survey).
*TOKEN:xxx - トークンの属性値(例: TOKEN:FIRSTNAME、TOKEN:ATTRIBUTE_5)(匿名でないアンケート向け)
*[[Adding a question#Information_from_previous_answers|INSERTANS:SGQA]] - the display value of an answer (e.g. "Yes"). For Expression Manager it's the same that using {QCODE.shown}.
*[[Adding a question/ja#Information_from_previous_answers|INSERTANS:SGQA]] - 回答として表示する値(例: "はい")。式マネージャーでは、{QCODE.shown}と同じです。
*All [[The_template_editor#Keywords|{XXX} values used by templates]].
*[[The_template_editor/ja#Keywords|テンプレート内で使われるすべての{XXX}]]
*In question text, you can use {QID} replaced by the question id and {SGQ} replaced by the SGQA of the question
*質問テキストでは、{QID}を質問IDで置き換え、{SGQ}を質問のSGQAで置き換えることができます。


In addition, Expression Manager lets you refer to variables by the Question Code (the 'title' column in the questions table within the database).  This is also the variable label used when you export your data to SPSS, R, or SAS.  For example, if you have questions about name, age, and gender, you could call those variables ''name'', ''age'', and ''gender'' instead of ''12345X13X22'', ''12345X13X23'', and  ''12345X13X24''.  This makes equations easier for everyone to read and validate the logic, plus makes it possible to shuffle questions around without having to keep track of group or question numbers.
さらに、式マネージャーでは、質問コード(データベース内の質問テーブルの'タイトル'列)で変数を参照できます。これは、データをSPSS、R、またはSASにエクスポートするときに使用される変数ラベルでもあります。例えば、名前、年齢、性別について質問がある場合、12345X13X22、12345X13X23、12345X13X24といった形ではなく、''name''''age''''gender''といった形で変数を呼び出すことができます。これにより、式が読みやすく、ロジックが検証しやすくなり、また、グループや質問の番号を把握することなく質問をシャッフルすることが可能になります。


<div class='simplebox'>
<div class='simplebox'>
'''Important:''' It is only safe to refer to variables that occur in preceding pages or questions.
'''重要:''' 先行するページや質問で発生する変数を参照することもできます。</div>
</div>


Furthermore, Expression Manager lets you access many properties of the Question:
さらに、式マネージャーを使用すると、多くの質問プロパティにアクセスできます。




{| class="wikitable"
{| class="wikitable"
!Syntax!!Meaning!!Example!!Example Result
!構文!!意味!!!!例の結果
|-
|-
|Qcode||an alias for Qcode.code||{implode(',',name,gender)}||'Tom','M'
|Qcode||Qcode.codeの別名||{implode(',',name,gender)}||'Tom','M'
|-
|-
|Qcode.code||the selected response code for the question if it is relevant (otherwise blank), or the text value if it is not a coded question||{implode(',',name.code,gender.code)}||'Tom','M'
|Qcode.code||出現条件を満たす場合に質問に対して選択された回答コード(出現条件を満たさない場合は空白)、またはコード化された質問でない場合のテキスト値||{implode(',',name.code,gender.code)}||'Tom','M'
|-
|-
|Qcode.NAOK||same as Qcode - see discussion of NAOK||{gender.NAOK}||'M'
|Qcode.NAOK||Qcodeと同じ - NAOKの議論を参照||{gender.NAOK}||'M'
|-
|-
|Qcode.value||the assessment value for the question if it is relevant (otherwise blank), or the text value if it is not a coded question||{gender.value}||'1'
|Qcode.value||出現条件を満たす場合の質問の評価値(出現条件を満たさない場合は空白)、またはコード化された質問でない場合のテキスト値||{gender.value}||'1'
|-
|-
|Qcode.valueNAOK||same as Qcode.value - see discussion about NAOK||{gender.valueNAOK}||'1'
|Qcode.valueNAOK||Qcode.valueと同じ - NAOKについての議論を参照||{gender.valueNAOK}||'1'
|-
|-
|Qcode.shown||the dispay value for the question||{implode(',',name.shown,gender.shown)}||'Tom','Male'
|Qcode.shown||質問で表示される値||{implode(',',name.shown,gender.shown)}||'Tom','Male'
|-
|-
|Qcode.question||the text of the question||{gender.question}||'What is your gender?'
|Qcode.question||質問のテキスト||{gender.question}||'What is your gender?'
|-
|-
|Qcode.mandatory||whether the question is mandatory (Y/N)||{gender.mandatory}||'N'
|Qcode.mandatory||質問への回答が必須かどうか(Y/N)||{gender.mandatory}||'N'
|-
|-
|Qcode.qid||the internal question number (not the sequential number)||{gender.qid}||337
|Qcode.qid||内部の質問番号(連番ではない)||{gender.qid}||337
|-
|-
|Qcode.type||the question type||{gender.type}||'G'
|Qcode.type||質問タイプ||{gender.type}||'G'
|-
|-
|Qcode.jsName||the correct javascript name for the question, regardless whether declared on or off this page||{gender.jsName}||'java1827X3X337'
|Qcode.jsName||このページで宣言されているかどうかにかかわらず、質問の正しいjavascript名||{gender.jsName}||'java1827X3X337'
|-
|-
|Qcode.gid||the internal group number (not the sequential number)||{gender.gid}||3
|Qcode.gid||内部のグループ番号(連番ではない)||{gender.gid}||3
|-
|-
|Qcode.qseq||the sequential number of the question, starting from 0||{gender.qseq}||5
|Qcode.qseq||0から始まる質問の連番||{gender.qseq}||5
|-
|-
|Qcode.gseq||the sequential number of the group, starting from 0||{gender.gseq}||1
|Qcode.gseq||0から始まるグループの連番||{gender.gseq}||1
|-
|-
|Qcode.relevanceStatus||whether the question is currently relevant (0 or 1)||{gender.relevanceStatus}||1
|Qcode.relevanceStatus||その時点で質問が表示条件を満たすかどうか(0/1)||{gender.relevanceStatus}||1
|-
|-
|Qcode.relevance||the question-level relevance equation||{gender.relevance}||'!is_empty(name)'
|Qcode.relevance||質問レベルの出現条件の式||{gender.relevance}||'!is_empty(name)'
|-
|-
|Qcode.grelevance||the  group-level relevance equation||{gender.grelevance}||'num_children >= 5'
|Qcode.grelevance||グループレベルの出現条件の式||{gender.grelevance}||'num_children >= 5'
|-
|-
|Qcode.sgqa||the SGQA value for this question||{gender.sgqa}||'1827X3X337'
|Qcode.sgqa||質問に対応するSGQA値||{gender.sgqa}||'1827X3X337'
|}
|}


<span id="HTML_editor_issue"></span>
=== HTMLエディターの問題===
=== HTMLエディターの問題===


{{Alert|This issue is fixed after 2.05 build 140803}}  
{{Alert|この問題は2.05ビルド140803以降で修正されています。}}  


If you use HTML editor, some characters are replaced by HTML entities.
HTMLエディターを使用すると、一部の文字がHTML実体に置き換えられます。
* & by &amp;amp;
* & &amp;amp;
* < by &amp;lt;
* < &amp;lt;
* > by &amp;gt;
* > &amp;gt;


If you use HTML editor you need to use :
HTMLエディターを使用する場合は、次のものを使用する必要があります。
* and for &
* & に対しては and
* lt for <
* < に対してはlt
* le for <=
* <= に対してはle
* gt for >
* > に対してはgt
* ge for >=
* >= に対してはge


<span id="Qcode_Variable_Naming"></span>
==Qcode変数の命名==
==Qcode変数の命名==


Here are the details of how to construct a Qcode (and access some properties) by question type.  In general, Qcodes are constructed as:
Qcodeを構成する方法(およびいくつかのプロパティにアクセスする方法)の質問タイプ別の詳細は次のとおりです。一般に、Qcodeは次のように構成されます。


   QuestionCode . '_' . SubQuestionID . '_' . ScaleId
   QuestionCode . '_' . SubQuestionID . '_' . ScaleId


For '''comment''' and '''other''', question code are QuestionCode_comment and QuestionCode_other
'''コメント'''および'''その他'''の質問コードは、それぞれQuestionCode_commentとQuestionCode_otherです。


{| class="wikitable"
{| class="wikitable"
!Type!!Description!!Code!!SubQs!!Answer Options!!Scales!!Answer Code!!Answer Shown!!Relevance
!タイプ!!説明!!コード!!サブ質問!!回答の選択肢!!尺度!!回答コード!!回答の表示!!出現条件
|-
|-
|5||5 Point Choice Radio-Buttons||Q1|| ||1-5|| ||{Q1}||{Q1.shown}||{Q1==3}
|5||5点選択ラジオボタン||Q1|| ||1-5|| ||{Q1}||{Q1.shown}||{Q1==3}
|-
|-
|B||Array (10 Point Choice) Radio-Buttons||Q2||L1-L6||1-10|| ||{Q2_L2}||{Q2_L2.shown}||{Q2_L2==7}
|B||配列(10点選択)ラジオボタン||Q2||L1-L6||1-10|| ||{Q2_L2}||{Q2_L2.shown}||{Q2_L2==7}
|-
|-
|A||Array (5 Point Choice) Radio-Buttons||Q3||1-5||1-5|| ||{Q3_1}||{Q3_1.shown}||{Q3_1>=3}
|A||配列(5点選択)ラジオボタン||Q3||1-5||1-5|| ||{Q3_1}||{Q3_1.shown}||{Q3_1>=3}
|-
|-
|1||Array (Flexible Labels) Dual Scale||Q4||sq1-sq5||0:a1-a3||1:b1-b3||{Q4_sq1_0}||{Q4_sq1_1.shown}||{Q4_sq1_1=='b2'}
|1||配列(フレキシブルラベル)二元スケール||Q4||sq1-sq5||0:a1-a3||1:b1-b3||{Q4_sq1_0}||{Q4_sq1_1.shown}||{Q4_sq1_1=='b2'}
|-
|-
|H||Array (Flexible) - Column Format||Q5||1-5||s,m,t|| ||{Q5_1}||{Q5_1.shown}||{Q5_1=='s'}
|H||配列(フレキシブル) - 列形式||Q5||1-5||s,m,t|| ||{Q5_1}||{Q5_1.shown}||{Q5_1=='s'}
|-
|-
|F||Array (Flexible) - Row Format||Q6||F1-F5||1-5|| ||{Q6_F3}||{Q6_F3.shown}||{Q6_F3==4}
|F||配列(フレキシブル) - 行形式||Q6||F1-F5||1-5|| ||{Q6_F3}||{Q6_F3.shown}||{Q6_F3==4}
|-
|-
|E||Array (Increase/Same/Decrease) Radio-Buttons||Q7||1-7||I,S,D|| ||{Q7_4}||{Q7_4.shown}||{Q7_4=='D'}
|E||配列(増加/同じ/減少)ラジオボタン||Q7||1-7||I,S,D|| ||{Q7_4}||{Q7_4.shown}||{Q7_4=='D'}
|-
|-
|:||Array (Multi Flexi) 1 To 10||Q8||ls1,todo,ls2||min,max,avg|| ||{Q8_ls1_max}||{Q8_ls2_avg.shown}||{Q8_ls2_min==7}
|:||配列(複数フレキシブル)1から10||Q8||ls1,todo,ls2||min,max,avg|| ||{Q8_ls1_max}||{Q8_ls2_avg.shown}||{Q8_ls2_min==7}
|-
|-
|;||Array (Multi Flexi) Text||Q9||hp,st,sw||1st,2nd,3rd|| ||{Q9_hp_3rd}||{Q9_hp_3rd.shown}||{Q9_hp_3rd=='Peter'}
|;||配列(複数フレキシブル)テキスト||Q9||hp,st,sw||1st,2nd,3rd|| ||{Q9_hp_3rd}||{Q9_hp_3rd.shown}||{Q9_hp_3rd=='Peter'}
|-
|-
|C||Array (Yes/Uncertain/No) Radio-Buttons||Q10||1-5||Y,N,U|| ||{Q10_1}||{Q10_1.shown}||{Q10_3=='Y'}
|C||配列(はい/わからない/いいえ)ラジオボタン||Q10||1-5||Y,N,U|| ||{Q10_1}||{Q10_1.shown}||{Q10_3=='Y'}
|-
|-
|X||Boilerplate Question||Q11|| || || || ||{Q11.shown}||
|X||テキスト質問||Q11|| || || || ||{Q11.shown}||
|-
|-
|D||Date||Q12|| || || ||{Q12}||{Q12.shown}||
|D||日付||Q12|| || || ||{Q12}||{Q12.shown}||
|-
|-
|*||Equation||Q13|| || || ||{Q13}||{Q13.shown}||{Q13>5}
|*||||Q13|| || || ||{Q13}||{Q13.shown}||{Q13>5}
|-
|-
|~124~||File Upload (records number of files uploaded)||Q14|| || || ||{Q14}|| ||{Q14>0}
|~124~||ファイルアップロード(アップロードされたファイルの数)||Q14|| || || ||{Q14}|| ||{Q14>0}
|-
|-
|G||Gender Drop-Down List||Q15|| ||M,F|| ||{Q15}||{Q15.shown}||{Q15=='M'}
|G||性別ドロップダウンリスト||Q15|| ||M,F|| ||{Q15}||{Q15.shown}||{Q15=='M'}
|-
|-
|U||Huge Free Text||Q16|| || || ||{Q16}||{Q16.shown}||{strlen(Q16)>100}
|U||非常に長い自由文||Q16|| || || ||{Q16}||{Q16.shown}||{strlen(Q16)>100}
|-
|-
|I||Language Question||Q17|| || || ||{Q17}||{Q17.shown}||{Q17=='en'}
|I||言語質問||Q17|| || || ||{Q17}||{Q17.shown}||{Q17=='en'}
|-
|-
|!||List - Dropdown||Q18|| ||1-5|| ||{Q18}||{Q18.shown}||{Q18==3}
|!||リスト - ドロップダウン||Q18|| ||1-5|| ||{Q18}||{Q18.shown}||{Q18==3}
|-
|-
|L||List Drop-Down/Radio-Button List||Q19|| ||A-Z|| ||{Q19}||{Q19.shown}||{Q19=='X'}
|L||リスト ドロップダウン/ラジオボタン||Q19|| ||A-Z|| ||{Q19}||{Q19.shown}||{Q19=='X'}
|-
|-
|O||List With Comment Drop-Down/Radio-Button List + Textarea||Q20|| ||A-F|| ||{Q20},{Q20comment}||{Q20.shown}||{Q20=='B'}
|O||コメント付きリスト ドロップダウン/ラジオボタン+テキスト||Q20|| ||A-F|| ||{Q20},{Q20comment}||{Q20.shown}||{Q20=='B'}
|-
|-
|T||Long Free Text||Q21|| || || ||{Q21}||{Q21.shown}||{strstr(Q21,'hello')>0}
|T||長い自由文||Q21|| || || ||{Q21}||{Q21.shown}||{strstr(Q21,'hello')>0}
|-
|-
|M||Multiple Choice Checkbox||Q22||A-F, other|| || ||{Q22_E}, {Q22_other}||{Q22_E.shown}, {Q22_other.shown}||{Q22_E=='Y'}
|M||複数選択チェックボックス||Q22||A-F, other|| || ||{Q22_E}, {Q22_other}||{Q22_E.shown}, {Q22_other.shown}||{Q22_E=='Y'}
|-
|-
|P||Multiple Choice With Comments Checkbox + Text||Q23||A-F|| || ||{Q23_D}, {Q23_Dcomment}||{Q23_D.shown}||{!is_empty(Q23)}
|P||コメント付き複数選択 チェックボックス+テキスト||Q23||A-F|| || ||{Q23_D}, {Q23_Dcomment}||{Q23_D.shown}||{!is_empty(Q23)}
|-
|-
|K||Multiple Numerical Question||Q24||self,mom,dad|| || ||{Q24_self}||{Q24_self.shown}||{Q24_self>30}
|K||複数数値質問||Q24||self,mom,dad|| || ||{Q24_self}||{Q24_self.shown}||{Q24_self>30}
|-
|-
|Q||Multiple Short Text||Q25||A-F|| || ||{Q25_B}||{Q25_B.shown}||{substr(Q25_B,1,1)=='Q'}
|Q||複数テキスト||Q25||A-F|| || ||{Q25_B}||{Q25_B.shown}||{substr(Q25_B,1,1)=='Q'}
|-
|-
|N||Numerical Question Type||Q26|| || || ||{Q26}||{Q26.shown}||{Q26 > 30}
|N||数値質問タイプ||Q26|| || || ||{Q26}||{Q26.shown}||{Q26 > 30}
|-
|-
|R||Ranking Style||Q27||1-4|| || ||{Q27_1}||{Q27_1.shown}||{Q27_1==3}
|R||順位||Q27||1-4|| || ||{Q27_1}||{Q27_1.shown}||{Q27_1==3}
|-
|-
|S||Short Free Text||Q28|| || || ||{Q28}||{Q28.shown}||{Q28=='mine'}
|S||短い自由文||Q28|| || || ||{Q28}||{Q28.shown}||{Q28=='mine'}
|-
|-
|Y||Yes/No Radio-Buttons||Q29|| || || ||{Q29}||{Q29.shown}||{Q29=='Y'}
|Y||はい/いいえラジオボタン||Q29|| || || ||{Q29}||{Q29.shown}||{Q29=='Y'}
|}
|}


<span id="The_reserved_&#039;this&#039;,_&#039;self&#039;,_and_&#039;that&#039;_variables"></span>
==予約変数 this、self、that==
==予約変数 this、self、that==


Quite often, you want to evalute all parts of a question, such as counting how many sub-questions have been answered, or summing the scores.  Other times, you want to process just certain rows or columns of a question (such as getting the row or column sums and storing them in the database).  These reserved variables make that process relatively painless.
回答されたサブ質問の数を数えたり、スコアを合計するなど、質問の全体を評価したい場合がよくあります。また、質問の特定の行や列(行や列の合計を取得してデータベースに格納するなど)を処理したい場合もあります。以下の予約変数により、そのプロセスを簡単に実現できます。


The 'this' variable is used exclusively within the "Whole question validation equation" and "Sub-question validation equation" advanced question options.  It expands to the variable names of each of the cells within those questions.  So, if you want to make sure that each entry is greater than three, you would set the "Sub-question validation equation" to (this > 3).
'this'変数は、"完全な質問の検証式""サブ質問の検証式"の高度な質問オプション内で排他的に使用されます。該当の質問内の各セルの変数名に展開されます。したがって、各エントリが3より大きいかどうかを確認する場合は、"サブ質問の検証式"(this > 3)に設定します。


The 'self' and 'that' variable are more powerful, and serve as macros which are expanded prior to processing equations.  The syntax choices are:
'self''that'変数はより強力で、式を処理する前に展開されるマクロとして機能します。構文は次のとおりです。
*self
*self
*self.''suffix''
*self.''suffix''
Line 611: Line 663:
*self.''sub-selector''.''suffix''
*self.''sub-selector''.''suffix''


''suffix'' is any of the normal qcode suffixes (e.g. NAOK, value, shown)
''suffix''は、通常のqcode接尾辞のいずれかです(例: NAOK、value、shown)。


''sub-selector'' is one of:
''sub-selector''は次のいずれかです。
*comments - only subquestions that are comments (e.g. from multiple choice with comment and list with comment)
*comments - コメントのサブ質問(例えば、コメント付き複数選択、コメント付きリスト)
*nocomments - only subquestions that are not comments
*nocomments - コメントでないサブ質問
*sq_X - where X is a row or column identifier.  Only sub-questions matching pattern X are selected. Note that search is done on complete code identifier, then sq_X match and include subquestions nX, X, Xn (e.g. if you use sq_1, subquestions a1, 1a, 1, 11 or 001 was included). Put attention at dual scale question type where subquestions code are QCODE_SQCODE_1 and QCODE_SQCODE_1 and to ranking question type where subquestions code are QCODE_1,QCODE_2 ....
*sq_X - Xは、行または列の識別子。パターンXと一致するサブ質問のみが選択されます。検索は完全なコード識別子で行われ、sq_Xは、サブ質問nX、X、Xnとマッチし選択されることに注意してください(例えば、sq_1を使用する場合はサブ質問a1、1a、1、11または001が含まれます)。二元スケール質問タイプのサブ質問コードはQCODE_SQCODE_1、QCODE_SQCODE_1であり、順位付け質問タイプのサブ質問コードはQCODE_1、QCODE_2、....となります。


Examples:
:
*Has any part of a question been answered?  {count(self.NAOK)>0}
*質問に対して何らかの回答があったか?  {count(self.NAOK)>0}
*What is the assessment score for this question?  {sum(self.value)}
*この質問の評価点数は?  {sum(self.value)}


You can also use these to get row and column totals.  Say you have a array of numbers with rows A-E and columns 1-5.
行と列の合計を取得することもできます。列A-Eと行1-5の数字の配列があるとします。
*What is the grand total?  {sum(self.NAOK)}
*総合計は? {sum(self.NAOK)}
*What is the total of row B?  {sum(self.sq_B.NAOK)}
*列Bの合計は? {sum(self.sq_B.NAOK)}
*What is the total of column 3? {sum(self.sq_3.NAOK)}
*行3の合計は? {sum(self.sq_3.NAOK)}


The 'that' variable is like the 'self' variable, but lets you refer to other questions.  Its syntax is:
'that''self'に似ていますが、他の質問を参照することができます。構文は次のとおりです。
*that.''qname''
*that.''qname''
*that.''qname''.''suffix''
*that.''qname''.''suffix''
Line 633: Line 685:
*that.''qname''.''sub-selector''.''suffix''
*that.''qname''.''sub-selector''.''suffix''


''qname'' is the question name without any sub-question extensions.  So, say you create a question 'q1', that is its ''qname''
''qname''は、サブ質問拡張がない質問の名前です。質問 'q1'を作成したら、それが''qname''となります。


Examples:
:
*Has any part of question q1 been answered?  {count(that.q1.NAOK)>0}
*質問q1に対して何らかの回答があったか? {count(that.q1.NAOK)>0}
*What is the assessment score for q2?  {sum(that.q2.NAOK)}
*q2の評価点数は?  {sum(that.q2.NAOK)}
*What is the grand total of q3? {sum(that.q3.NAOK)}
*q3の総合計は? {sum(that.q3.NAOK)}
*What is the total of row C in q4?  {sum(that.q4.sq_C.NAOK)}
*q4の列Cの合計は?  {sum(that.q4.sq_C.NAOK)}
*What is the total of column 2 in q4? {sum(that.q4.sq_2.NAOK)}
*q4の行2の合計は? {sum(that.q4.sq_2.NAOK)}


The 'self' and 'that' variables can be used in any relevance,  validation, or tailoring.
'self''that'変数は、出現条件、検証、カスタマイズの式で使用できます。


The one caveat is that when you use the [[Show Logic File|Show Logic File]] feature, it will show you the expanded value of 'self' and 'that'.  This lets you see the actual equation that will be generated so that you (and Expression Manager) can validate that the variables exist.  This may seem confusing since you may see quite lenghty equations.  However, if you edit the question, you will see the original equation using 'self' and/or 'that'
注意すべき点は、[[Show Logic File/ja|ロジックファイルの表示]]機能を使用すると、'self''that'を展開した値が表示されることです。これにより、生成される実際の式が表示され、その結果、変数が存在することを検証できるようになります。かなり長い式になるかもしれないので、混乱しているように見えるかもしれません。しかし、質問を編集すると、'self''that'を使っている元の式が表示されます。


Also note that you should not use these variables if (a) you want to explicitly name each variable used in an equation, or (b) use variables that do not have sub-questions (e.g. single response questions).  In those cases, prefixing a variable with 'that' is overkill, and you run the risk of getting unexpected results.
また、(a)式に使用される各変数を明示的に命名する場合、または(b)サブ質問を持たない変数を使用する場合(例:単一回答の質問)、これらの変数を使用しないでください。そのような場合に、変数に'that'をつけてプレフィックスをつけると、予期しない結果が出る危険があります。


<span id="Usage_of_NAOK"></span>
==NAOKの利用==  
==NAOKの利用==  


NAOK --> "Not Applicable" (NA) is alright (OK)
NAOK --> "Not Applicable"(該当なし、NA)は問題ない(OK)


Using NAOK, means that all or some of the variables are irrelevant (e.g. "Not Applicable" (NA) is alright (OK)).
NAOKは、すべてまたは一部の変数が出現条件を満たさないということです。"Not Applicable"(該当なし、NA)は問題ない(OK)。


When you put some variable from question in any equation : if this question (or subquestion) is hidden by condition : this disable all equation.
式の中に、質問からの変数を導入するとき、この質問(またはサブ質問)が条件によって隠されている場合、式全体を無効にします。


For example : count(Q1_SQ1,Q1_SQ2,Q1_SQ3,Q1_SQ4) give always an empty string if one subquestion of Q1 is filtered.
: count(Q1_SQ1,Q1_SQ2,Q1_SQ3,Q1_SQ4) は、Q1のサブ質問の一つがフィルターされている場合、常に空文字となります。このような質問で、チェックされたサブ質問の数をカウントするには、count(Q1_SQ1.NAOK,Q1_SQ2.NAOK,Q1_SQ3.NAOK,Q1_SQ4.NAOK)とします。サブ質問が隠されている場合、式マネージャーは空文字を返します。
To count the number of checked subquestion in such question can be count(Q1_SQ1.NAOK,Q1_SQ2.NAOK,Q1_SQ3.NAOK,Q1_SQ4.NAOK). If the sub question is hidden :Expression manager return an empty string.


Without NAOK : if one question or one subquestion is hidden : Expression Manager return always an empty string, same to return false.
NAOKがない場合、1つの質問または1つのサブ質問が非表示になっている場合、式マネージャーは常に空の文字列を返します(falseを返すのと同じです)。


The .shown always use the NAOK system (empty string if hidden) but if you need the code of the answer : it's always a good idea to add .NAOK after the question code. Except if you need it and know what you do.
.shownは常にNAOKの仕組み(非表示の時は空文字)を使っていますが、回答のコードが必要な場合は、質問コードの後に.NAOKを付加するとよいでしょう。それが必要で、内容を理解している場合は別です。


Another example and information is provided at [[#Overriding_Cascading_Conditions|Overriding Cascading Conditions]]
その他の例と情報は、[[#Overriding_Cascading_Conditions|カスケードされた条件の上書き]]を参照してください。


<span id="Access_to_Functions"></span>
==関数へのアクセス==
==関数へのアクセス==


Expression Manager provides access to mathematical, string, and user-defined functions, as shown below.  It has PHP and JavaScript equivalents for these functions so that they work identically on server-side (PHP) and client-side (JavaScript).  It is easy to add new functions.
式マネージャーでは、以下に示すように、数学関数、文字列関数、およびユーザー定義関数が利用できます。これらの関数にはPHPとJavaScriptに同等のものがあるので、サーバ側(PHP)とクライアント側(JavaScript)で同じように動作します。新しい機能を追加するのは簡単です。


<span id="Implemented_Functions"></span>
===実装済み関数===
===実装済み関数===


The following functions are currently available:
現在、以下の関数が利用可能です。


{| class="wikitable"
{| class="wikitable"
!Function!!Meaning!!Syntax
!関数!!意味!!構文
|-
|-
|[http://www.php.net/manual/en/function.abs.php abs]||Absolute value||number abs(number)
|[http://www.php.net/manual/en/function.abs.php abs]||絶対値||number abs(数値)
|-
|-
|[http://www.php.net/manual/en/function.acos.php acos]||Arc cosine||number acos(number)
|[http://www.php.net/manual/en/function.acos.php acos]||アークコサイン||number acos(数値)
|-
|-
|[http://www.php.net/manual/en/function.addslashes.php addslashes]||Quote string with slashes||string addslashes(string)
|[http://www.php.net/manual/en/function.addslashes.php addslashes]||文字列をスラッシュで引用||string addslashes(文字列)
|-
|-
|[http://www.php.net/manual/en/function.asin.php asin]||Arc sine||number asin(number)
|[http://www.php.net/manual/en/function.asin.php asin]||アークサイン||number asin(数値)
|-
|-
|[http://www.php.net/manual/en/function.atan.php atan]||Arc tangent||number atan(number)
|[http://www.php.net/manual/en/function.atan.php atan]||アークタンジェント ||number atan(数値)
|-
|-
|[http://www.php.net/manual/en/function.atan2.php atan2]||Arc tangent of two variables||number atan2(number, number)
|[http://www.php.net/manual/en/function.atan2.php atan2]||2変数のアークタンジェント||number atan2(数値, 数値)
|-
|-
|[http://www.php.net/manual/en/function.ceil.php ceil]||Round fractions up||number ceil(number)
|[http://www.php.net/manual/en/function.ceil.php ceil]||切り上げ||number ceil(数値)
|-
|-
|[http://www.php.net/manual/en/function.checkdate.php checkdate]||Returns true(1) if it is a valid date in gregorian calendar||bool checkdate(month,day,year)
|[http://www.php.net/manual/en/function.checkdate.php checkdate]||グレゴリオ暦で有効な日付であれば真(1)を返す||bool checkdate(,,)
|-
|-
|convert_value||Convert a numerical value using a inputTable and outputTable of numerical values||number convert_value(fValue, iStrict, sTranslateFromList, sTranslateToList)
|convert_value||変換元リストにある数値を対応する変換先リストの数値に変換する||number convert_value(変換する数値, 一致フラグ, 変換元リスト, 変換先リスト)
|-
|-
|[http://www.php.net/manual/en/function.cos.php cos]||Cosine||number cos(number)
|[http://www.php.net/manual/en/function.cos.php cos]||コサイン||number cos(数値)
|-
|-
|count||count the number of answered (non-blank)questions in the list||number count(arg1, arg12, ..., argN)
|count||リスト内で回答された(空白でない)質問の数||number count(arg1, arg2, ..., argN)
|-
|-
|countif||Count the number of answered questions in the list equal the first argument||number countif(matches, arg1, arg2, ... argN)
|countif||回答された質問のうち、比較値と等しいリスト内の回答の数||number countif(比較値, arg1, arg2, ... argN)
|-
|-
|countifop||Count the number of answered questions in the list which pass the criteria (arg op value)||number countifop(op, value, arg1, arg2, ... argN)
|countifop||回答された質問のうち、条件を満たすリスト内の回答の数(回答 演算子 比較値)||number countifop(演算子, 比較値, arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.date.php date]||Format a local date/time||string date(format <nowiki>[</nowiki>, timestamp=time()])
|[http://www.php.net/manual/en/function.date.php date]||指定した、もしくは現在のローカルの日付/時刻を書式化する||string date(日付書式<nowiki>[</nowiki>, 指定時刻=time()])
|-
|-
|[http://www.php.net/manual/en/function.exp.php exp]||Calculates the exponent of e||number exp(number)
|[http://www.php.net/manual/en/function.exp.php exp]||eの累乗を計算する||number exp(数値)
|-
|-
|fixnum||Display numbers with comma as radix separator, if needed||string fixnum(number)
|fixnum||必要に応じてカンマで区切られた数字を表示する||string fixnum(数値)
|-
|-
|[http://www.php.net/manual/en/function.floor.php floor]||Round fractions down||number floor(number)
|[http://www.php.net/manual/en/function.floor.php floor]||切り捨て||number floor(数値)
|-
|-
|[http://www.php.net/manual/en/function.gmdate.php gmdate]||Format a GMT date/time||string gmdate(format <nowiki>[</nowiki>, timestamp=time()])
|[http://www.php.net/manual/en/function.gmdate.php gmdate]||指定した、もしくは現在のGMTの日付/時刻を書式化する||string gmdate(日付書式<nowiki>[</nowiki>, 指定時刻=time()])
|-
|-
|[http://www.php.net/manual/en/function.html-entity-decode.php html_entity_decode]||Convert all HTML entities to their applicable characters (always uses ENT_QUOTES and UTF-8)||string html_entity_decode(string)
|[http://www.php.net/manual/en/function.html-entity-decode.php html_entity_decode]||HTML エンティティを適切な文字に変換する (always uses ENT_QUOTES and UTF-8)||string html_entity_decode(文字列)
|-
|-
|[http://www.php.net/manual/en/function.htmlentities.php htmlentities]||Convert all applicable characters to HTML entities (always uses ENT_QUOTES and UTF-8)||string htmlentities(string)
|[http://www.php.net/manual/en/function.htmlentities.php htmlentities]||Convert all applicable characters to HTML entities(常にENT_QUOTESとUTF-8を使用)||string htmlentities(string)
|-
|-
|[http://www.php.net/manual/en/function.htmlspecialchars.php expr_mgr_htmlspecialchars]||Convert special characters to HTML entities (always uses ENT_QUOTES and UTF-8)||string htmlspecialchars(string)
|[http://www.php.net/manual/en/function.htmlspecialchars.php expr_mgr_htmlspecialchars]||特殊文字を HTML エンティティに変換す(常にENT_QUOTESとUTF-8を使用)||string htmlspecialchars(文字列)
|-
|-
|[http://www.php.net/manual/en/function.htmlspecialchars-decode.php expr_mgr_htmlspecialchars_decode]||Convert special HTML entities back to characters (always uses ENT_QUOTES and UTF-8)||string htmlspecialchars_decode(string)
|[http://www.php.net/manual/en/function.htmlspecialchars-decode.php expr_mgr_htmlspecialchars_decode]||特殊な HTML エンティティを文字に戻す(常にENT_QUOTESとUTF-8を使用)||string htmlspecialchars_decode(文字列)
|-
|-
|[http://www.php.net/manual/en/function.idate.php idate]||Format a local time/date as integer||string idate(string <nowiki>[</nowiki>, timestamp=time()])
|[http://www.php.net/manual/en/function.idate.php idate]||指定した、もしくは現在のローカルな時刻/日付を整数として整形する||string idate(文字列<nowiki>[</nowiki>, 指定時刻=time()])
|-
|-
|if||Excel-style if(test,result_if_true,result_if_false)||if(test,result_if_true,result_if_false)
|if||Excelスタイルのif(条件,trueの時の結果,falseの時の結果)||if(条件,trueの時の結果,falseの時の結果)
|-
|-
|[http://www.php.net/manual/en/function.implode.php implode]||Join array elements with a string||string implode(glue,arg1,arg2,...,argN)
|[http://www.php.net/manual/en/function.implode.php implode]||配列要素を文字列により連結するg||string implode(区切り文字,arg1,arg2,...,argN)
|-
|-
|[http://www.php.net/manual/en/function.intval.php intval]||Get the integer value of a variable||int intval(number <nowiki>[</nowiki>, base=10])
|[http://www.php.net/manual/en/function.intval.php intval]||変数の整数としての値を取得する||int intval(数値 <nowiki>[</nowiki>, 基数=10])
|-
|-
|[http://www.php.net/manual/en/function.empty.php is_empty]||Determine whether a variable is considered to be empty||bool is_empty(var)
|[http://www.php.net/manual/en/function.empty.php is_empty]||変数が空であるかどうかを検査する||bool is_empty(変数)
|-
|-
|[http://www.php.net/manual/en/function.is-float.php is_float]||Finds whether the type of a variable is float||bool is_float(var)
|[http://www.php.net/manual/en/function.is-float.php is_float]||変数の型が float かどうか調べる||bool is_float(変数)
|-
|-
|[http://www.php.net/manual/en/function.is-int.php is_int]||Find whether the type of a variable is integer||bool is_int(var)
|[http://www.php.net/manual/en/function.is-int.php is_int]||変数が整数型かどうかを検査する||bool is_int(変数)
|-
|-
|[http://www.php.net/manual/en/function.is-nan.php is_nan]||Finds whether a value is not a number||bool is_nan(var)
|[http://www.php.net/manual/en/function.is-nan.php is_nan]||値が数値でないかどうかを判定する||bool is_nan(変数)
|-
|-
|[http://www.php.net/manual/en/function.is-null.php is_null]||Finds whether a variable is NULL||bool is_null(var)
|[http://www.php.net/manual/en/function.is-null.php is_null]||変数が NULL かどうか調べる||bool is_null(変数)
|-
|-
|[http://www.php.net/manual/en/function.is-numeric.php is_numeric]||Finds whether a variable is a number or a numeric string||bool is_numeric(var)
|[http://www.php.net/manual/en/function.is-numeric.php is_numeric]||変数が数字または数値形式の文字列であるかを調べる||bool is_numeric(変数)
|-
|-
|[http://www.php.net/manual/en/function.is-string.php is_string]||Find whether the type of a variable is string||bool is_string(var)
|[http://www.php.net/manual/en/function.is-string.php is_string]||変数の型が文字列かどうかを調べる||bool is_string(変数)
|-
|-
|join{{NewIn|2.0|b=130129}}||Join elements as a new string||join(arg1, arg2, ... argN)
|join{{NewIn/ja|2.0|b=130129}}||要素を新しい文字列として結合する||join(arg1, arg2, ... argN)
|-
|-
|list||Return comma-separated list of non-blank values||string list(arg1, arg2, ... argN)
|list||空白でない値をコンマ区切りリストで返す||string list(arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.log.php log]|| The logarithm of number to base, if given, or the natural logarithm. ||number log(number,base=e)
|[http://www.php.net/manual/en/function.log.php log]||自然対数(底が指定されている場合は底に対する対数)||number log(数値,=e)
|-
|-
|[http://www.php.net/manual/en/function.ltrim.php ltrim]||Strip whitespace (or other characters) from the beginning of a string||string ltrim(string <nowiki>[</nowiki>, charlist])
|[http://www.php.net/manual/en/function.ltrim.php ltrim]||文字列の最初から空白 (もしくはその他の文字) を取り除く||string ltrim(文字列 <nowiki>[</nowiki>, 削除する文字のリスト])
|-
|-
|[http://www.php.net/manual/en/function.max.php max]||Find highest value||number max(arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.max.php max]||最大値を返す||number max(arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.min.php min]||Find lowest value||number min(arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.min.php min]||最小値を返す|number min(arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.mktime.php mktime]||Get UNIX timestamp for a date (each of the 6 arguments are optional)||number mktime([hour [, minute [, second [, month [, day [, year ]]]]]])
|[http://www.php.net/manual/en/function.mktime.php mktime]||日付を Unix のタイムスタンプとして取得する(引数は省略可)||number mktime([[, [, [, [, [, ]]]]]])
|-
|-
|modulo-function||The modulo function is '''not supported''' yet. You can use the floor() function instead||floor(x/y)==(x/y)
|モジュロ関数||モジュロ関数はまだ'''サポートされていません'''。代わりにfloor()関数を使用します。||floor(x/y)==(x/y)
|-
|-
|[http://www.php.net/manual/en/function.nl2br.php nl2br]||Inserts HTML line breaks before all newlines in a string||string nl2br(string)
|[http://www.php.net/manual/en/function.nl2br.php nl2br]||改行文字の前にHTMLの改行タグを挿入する||string nl2br(文字列)
|-
|-
|[http://www.php.net/manual/en/function.number-format.php number_format]||Format a number with grouped thousands||string number_format(number)
|[http://www.php.net/manual/en/function.number-format.php number_format]||数字を千位毎にグループ化してフォーマットする||string number_format(数値)
|-
|-
|pi||Get value of pi||number pi()
|pi||円周率||number pi()
|-
|-
|[http://www.php.net/manual/en/function.pow.php pow]||Exponential expression||number pow(base, exp)
|[http://www.php.net/manual/en/function.pow.php pow]||指数表現||number pow(基数, 指数)
|-
|-
|[http://www.php.net/manual/en/function.quoted-printable-decode.php quoted_printable_decode]||Convert a quoted-printable string to an 8 bit string||string quoted_printable_decode(string)
|[http://www.php.net/manual/en/function.quoted-printable-decode.php quoted_printable_decode]||quoted-printable 文字列を 8 ビット文字列に変換する||string quoted_printable_decode(文字列)
|-
|-
|[http://www.php.net/manual/en/function.quoted-printable-encode.php quoted_printable_encode]||Convert a 8 bit string to a quoted-printable string||string quoted_printable_encode(string)
|[http://www.php.net/manual/en/function.quoted-printable-encode.php quoted_printable_encode]||8 ビット文字列を quoted-printable 文字列に変換する||string quoted_printable_encode(文字列)
|-
|-
|[http://www.php.net/manual/en/function.quotemeta.php quotemeta]||Quote meta characters||string quotemeta(string)
|[http://www.php.net/manual/en/function.quotemeta.php quotemeta]||メタ文字をクォートする||string quotemeta(文字列)
|-
|-
|[http://www.php.net/manual/en/function.rand.php rand]||Generate a random integer, see [[Expression Manager Sample Surveys#Randomly Ask One Question Per Group|this example]]||int rand() OR int rand(min, max)
|[http://www.php.net/manual/en/function.rand.php rand]||乱数を生成する([[Expression Manager Sample Surveys#Randomly Ask One Question Per Group|]]||int rand() OR int rand(最小値, 最大値)
|-
|-
|regexMatch||compare a string to a [[Using regular expressions|regular expression]]||bool regexMatch(pattern,input)
|regexMatch||文字列を[[Using regular expressions/ja|正規表現]]で比較する||bool regexMatch(パターン,文字列)
|-
|-
|[http://www.php.net/manual/en/function.round.php round]||Rounds a number to an optional precision||number round(val <nowiki>[</nowiki>, precision])
|[http://www.php.net/manual/en/function.round.php round]||数値を任意の精度に丸める||number round(<nowiki>[</nowiki>, 丸める桁数])
|-
|-
|[http://www.php.net/manual/en/function.rtrim.php rtrim]||Strip whitespace (or other characters) from the end of a string||string rtrim(string <nowiki>[</nowiki>, charlist])
|[http://www.php.net/manual/en/function.rtrim.php rtrim]||文字列の最後から空白(またはその他の文字)を取り除く||string rtrim(文字列 <nowiki>[</nowiki>, 削除する文字のリスト])
|-
|-
|[http://www.php.net/manual/en/function.sin.php sin]||Sine||number sin(arg)
|[http://www.php.net/manual/en/function.sin.php sin]||サイン||number sin(数値)
|-
|-
|[http://www.php.net/manual/en/function.sprintf.php sprintf]||Return a formatted string||string sprintf(format, arg1, arg2, ... argN)
|[http://www.php.net/manual/en/function.sprintf.php sprintf]||フォーマットされた文字列を返す||string sprintf(フォーマット, arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.sqrt.php sqrt]||Square root||number sqrt(arg)
|[http://www.php.net/manual/en/function.sqrt.php sqrt]||平方根||number sqrt(数値)
|-
|-
|stddev||Calculate the Sample Standard Deviation for the list of numbers||number stddev(arg1, arg2, ... argN)
|stddev||数値のリストのサンプル標準偏差を計算する||number stddev(arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.str-pad.php str_pad]||Pad a string to a certain length with another string||string str_pad(input, pad_length <nowiki>[</nowiki>, pad_string])
|[http://www.php.net/manual/en/function.str-pad.php str_pad]||文字列を固定長になるまで他の文字列で埋める||string str_pad(入力文字列, 文字列の長さ <nowiki>[</nowiki>, 埋める文字列])
|-
|-
|[http://www.php.net/manual/en/function.str-repeat.php str_repeat]||Repeat a string||string str_repeat(input, multiplier)
|[http://www.php.net/manual/en/function.str-repeat.php str_repeat]||文字列を反復する||string str_repeat(入力文字列, 繰り返し回数)
|-
|-
|[http://www.php.net/manual/en/function.str-replace.php str_replace]||Replace all occurrences of the search string with the replacement string||string str_replace(search, replace, subject)
|[http://www.php.net/manual/en/function.str-replace.php str_replace]||検索文字列に一致したすべての文字列を置換する||string str_replace(検索文字列, 置き換える値, 対象の文字列)
|-
|-
|[http://www.php.net/manual/en/function.strcasecmp.php strcasecmp]||Binary safe case-insensitive string comparison||int strcasecmp(str1, str2)
|[http://www.php.net/manual/en/function.strcasecmp.php strcasecmp]||Binary safe case-insensitive string comparison||int strcasecmp(str1, str2)
|-
|-
|[http://www.php.net/manual/en/function.strcmp.php strcmp]||Binary safe string comparison||int strcmp(str1, str2)
|[http://www.php.net/manual/en/function.strcmp.php strcmp]||バイナリセーフな文字列比較を行う||int strcmp(文字列1, 文字列2)
|-
|-
|[http://www.php.net/manual/en/function.strip-tags.php strip_tags]||Strip HTML and PHP tags from a string||string strip_tags(str, allowable_tags)
|[http://www.php.net/manual/en/function.strip-tags.php strip_tags]||文字列から HTML および PHP タグを取り除く||string strip_tags(文字列, 取り除かないタグ)
|-
|-
|[http://www.php.net/manual/en/function.stripos.php stripos]||Find position of first occurrence of a case-insensitive unicode string (starting by 0, return false if not found)|||int stripos(haystack, needle <nowiki>[</nowiki>, offset=0])
|[http://www.php.net/manual/en/function.stripos.php stripos]||大文字小文字を区別せずに文字列が最初に現れる位置を探す(0から始まり、現れなければfalse)|||int stripos(対象文字列, 検索文字列 <nowiki>[</nowiki>, 検索開始位置=0])
|-
|-
|[http://www.php.net/manual/en/function.stripslashes.php stripslashes]||Un-quotes a quoted string||string stripslashes(string)
|[http://www.php.net/manual/en/function.stripslashes.php stripslashes]||クォートされた文字列のクォート部分を取り除く||string stripslashes(文字列)
|-
|-
|[http://www.php.net/manual/en/function.stristr.php stristr]||Case-insensitive strstr||string stristr(haystack, needle <nowiki>[</nowiki>, before_needle=false])
|[http://www.php.net/manual/en/function.stristr.php stristr]||大文字小文字を区別しないstrstr||string stristr(対象文字列, 検索文字列 <nowiki>[</nowiki>, before_needle=false])
|-
|-
|[http://www.php.net/manual/en/function.strlen.php strlen]||Get string length||int strlen(string)
|[http://www.php.net/manual/en/function.strlen.php strlen]||文字列の長さを得る||int strlen(文字列)
|-
|-
|[http://www.php.net/manual/en/function.strpos.php strpos]||Find position of first occurrence of an unicode string (starting by 0, return false if not found)||int strpos(haystack, needle <nowiki>[</nowiki> offset=0])
|[http://www.php.net/manual/en/function.strpos.php strpos]||文字列内の部分文字列が最初に現れる場所を見つける(0から始まり、現れなければfalse)||int strpos(対象文字列, 検索文字列 <nowiki>[</nowiki> 検索開始位置=0])
|-
|-
|[http://www.php.net/manual/en/function.strrev.php strrev]||Reverse a string||string strrev(string)
|[http://www.php.net/manual/en/function.strrev.php strrev]||文字列を逆順にする||string strrev(文字列)
|-
|-
|[http://www.php.net/manual/en/function.strstr.php strstr]||Find first occurrence of a string||string strstr(haystack, needle<nowiki>[</nowiki>, before_needle=false])
|[http://www.php.net/manual/en/function.strstr.php strstr]||文字列が最初に現れる位置を見つける||string strstr(対象文字列, 検索文字列<nowiki>[</nowiki>, before_needle=false])
|-
|-
|[http://www.php.net/manual/en/function.strtolower.php strtolower]||Make a string lowercase||string strtolower(string)
|[http://www.php.net/manual/en/function.strtolower.php strtolower]||文字列を小文字にする||string strtolower(文字列)
|-
|-
|[http://www.php.net/manual/en/function.strtotime.php strtotime]||Parse about any English textual datetime description into a Unix timestamp||int strtotime(string)
|[http://www.php.net/manual/en/function.strtotime.php strtotime]||英文形式の日付をUnixタイムスタンプに変換する||int strtotime(文字列)
|-
|-
|[http://www.php.net/manual/en/function.strtoupper.php strtoupper]||Make a string uppercase||string strtoupper(string)
|[http://www.php.net/manual/en/function.strtoupper.php strtoupper]||文字列を大文字にする||string strtoupper(文字列)
|-
|-
|[http://www.php.net/manual/en/function.substr.php substr]||Return part of an unicode string||string substr(string, start <nowiki>[</nowiki>, length])
|[http://www.php.net/manual/en/function.substr.php substr]||unicode文字列の一部分を返す||string substr(対象文字列, 開始位置 <nowiki>[</nowiki>, 長さ])
|-
|-
|sum||Calculate the sum of values in an array||number sum(arg1, arg2, ... argN)
|sum||配列中の値の合計||number sum(arg1, arg2, ... argN)
|-
|-
|sumifop||Sum the values of answered questions in the list which pass the criteria (arg op value)||number sumifop(op, value, arg1, arg2, ... argN)
|sumifop||回答された質問のうち、条件を満たすリスト内の回答の合計(回答 演算子 比較値)||number sumifop(演算子, , arg1, arg2, ... argN)
|-
|-
|[http://www.php.net/manual/en/function.tan.php tan]||Tangent||number tan(arg)
|[http://www.php.net/manual/en/function.tan.php tan]||タンジェント||number tan(数値)
|-
|-
|[http://www.php.net/manual/en/function.time.php time]||Return current UNIX timestamp||number time()
|[http://www.php.net/manual/en/function.time.php time]||現在の Unix タイムスタンプを返す||number time()
|-
|-
|[http://www.php.net/manual/en/function.trim.php trim]||Strip whitespace (or other characters) from the beginning and end of a string||string trim(string <nowiki>[</nowiki>, charlist])
|[http://www.php.net/manual/en/function.trim.php trim]||文字列の先頭および最後から空白(またはその他の文字)を取り除く||string trim(文字列 <nowiki>[</nowiki>, 削除する文字のリスト])
|-
|-
|[http://www.php.net/manual/en/function.ucwords.php ucwords]||Uppercase the first character of each word in a string||string ucwords(string)
|[http://www.php.net/manual/en/function.ucwords.php ucwords]||文字列の各単語の最初の文字を大文字にする||string ucwords(文字列)
|-
|-
|unique||Returns true if all non-empty responses are unique||boolean unique(arg1, ..., argN)
|unique||空白以外の回答のすべてが一意である場合にtrueを返す||boolean unique(arg1, ..., argN)
|}
|}


<span id="Functions_that_are_Planned_or_Being_Considered"></span>
===計画中・検討中の関数===
===計画中・検討中の関数===


Other functions that are planned (or being considered) but which are not implemented yet include the following.  Some of these are for backwards compatability with another survey tool.
計画中(または検討中)でまだ実装されていない関数は、以下の通りです。このうちいくつかは別のアンケートツールとの下位互換性のためのものです。


{| class="wikitable"
{| class="wikitable"
!Syntax!!Meaning!!Comments
!構文!!意味!!コメント
|-
|-
|e()||returns the value of e||
|e()||eの値を返す||
|-
|-
|formatDate(X,PAT)||return the string value of date X formatted according to Java data format pattern PAT||
|formatDate(X,PAT)||Javaデータ形式パターンPATに従ってフォーマットされた日付Xの文字列値を返す||
|-
|-
|formatNumber(X,PAT)||return the string value of number X formatted according to Java number format pattern PAT||
|formatNumber(X,PAT)||Java数値書式パターンPATに従ってフォーマットされた数値Xの文字列を返す||
|-
|-
|getAnsOption(X)||returns the text corresponding to the selected option for answer X||this is the same as X.shown
|getAnsOption(X)||[[ExpressionAnswerOptions/ja|コアプラグインExpressionAnswerOptions ]]||
|-
|-
|getAnsOption(X,Y)||returns the text corresponding to the option at index Y of node X||
|getAnsOption(X,Y)||[[ExpressionAnswerOptions/ja|コアプラグインExpressionAnswerOptions ]]||
|-
|-
|getRelevance(X)||returns the relevance equation for question X||
|getRelevance(X)||質問Xの出現条件の式を返す||
|-
|-
|getStartTime()||returns the date corresponding to the system time when the interview was started||
|getStartTime()||アンケートが開始されたシステム時刻の日付を返す||
|-
|-
|getType(X)||returns the string name of the datatype - e.g. *NA* if isNA()||
|getType(X)||データタイプの名前を返す(例: isNA()なら*NA*||
|-
|-
|gotoFirst()||jumps to the first relevant set of questions - this violates the normal flow of the system||
|gotoFirst()||出現条件を満たす最初の質問にジャンプする(これはシステムの通常の流れに反する)||
|-
|-
|gotoNext()||jumps to the next set of relevant questions - this violates the normal flow of the system||
|gotoNext()||出現条件を満たす次の質問にジャンプする(これはシステムの通常の流れに反する)||
|-
|-
|gotoPrevious()||jumps to the previous set of relevant questions - this violates the normal flow of the system||
|gotoPrevious()||出現条件を満たすひとつ前の質問にジャンプする(これはシステムの通常の流れに反する)||
|-
|-
|isAsked(X)||returns true if the answer is neither *NA*, *INVALID*, nor *UNASKED*||
|isAsked(X)||回答が*NA**INVALID**UNASKED*のいずれでもなければtrueを返す||
|-
|-
|isInvalid(X)||returns true if the answer is of type *INVALID*||
|isInvalid(X)||回答が*INVALID*の場合trueを返す||
|-
|-
|isNA(X)||returns true if the answer is of type *NA*||
|isNA(X)||回答が*NA*の場合trueを返す||
|-
|-
|isNotUnderstood(X)||returns true if the answer if of type *HUH*||
|isNotUnderstood(X)||回答が*HUH*の場合trueを返す||
|-
|-
|isRefused(X)||returns true if the answer is of type *REFUSED*||
|isRefused(X)||回答が*REFUSED*の場合trueを返す||
|-
|-
|isSpecial(X)||returns true if the answer is of type *UNASKED*, *NA*, *REFUSED*, *INVALID*, *UNKNOWN*, or *HUH*||
|isSpecial(X)||回答が*UNASKED**NA**REFUSED**INVALID**UNKNOWN**HUH*のいずれかの場合trueを返す||
|-
|-
|isUnknown(X)||returns true if the answer is of type *UNKNOWN*||
|isUnknown(X)||回答が*UNKNOWN*の場合trueを返す||
|-
|-
|jumpTo(X)||jump to the group containing the named question -- this violates the normal flow of the system||
|jumpTo(X)||指定した名前の質問を含むグループにジャンプする(これはシステムの通常の流れに反する)||
|-
|-
|jumpToFirstUnasked()||jump to the first unasked question <strike> thus bypassing previous answered questions </strike> this violates the normal flow of the system||
|jumpToFirstUnasked()||<strike>回答済みの質問を飛び越えて</strike>最初の未回答の質問にジャンプする (これはシステムの通常の流れに反する)||
|-
|-
|lastIndexOf(X,Y)||returns the last index (base 0) of string Y in string X. Returns -1 if Y is not contained within X||
|lastIndexOf(X,Y)||文字列Xに文字列Yが最後に現れる位置(0始まり)を返す(XにYが含まれない場合は-1を返す)||
|-
|-
|list(X,...)||a string containing a comma separated list of the positive values with "and" separating the last two||
|list(X,...)||正の値のリスト(値はコンマで区切り、最後の2つの間は"and"で区切る)||
|-
|-
|mean(X,...)||returns the mean of a list of values||
|mean(X,...)||リストの値の平均を返す||
|-
|-
|numAnsOptions(X)||returns the number of answer options that question X has||
|numAnsOptions(X)||質問Xの回答オプションの数を返す||
|-
|-
|orlist(X,...)||a string containing a comma separated list of the positive values, with "or" separting the last two||
|orlist(X,...)||正の値のリスト(値はコンマで区切り、最後の2つの間は"or"で区切る)||
|-
|-
|parseDate(X,PAT)||returns the date value of string X parsed with Java date format pattern PAT||
|parseDate(X,PAT)||文字列XをJavaの日付書式パターンPATで解析した日付値を返す||
|-
|-
|parseNumber(X,PAT)||returns the numerical value of string X parsed with Java number format pattern PAT||
|parseNumber(X,PAT)||文字列XをJavaの数値書式パターンPATで解析した数値を返す||
|-
|-
|showAllResponsesExcept( questionList,attributeList,attributeTitleList)||questionList = pipe-delimited list of question identifiers; attributeList = pipe-delimited list of attributes (like question#, title, text, type - so you can decide what to show); attributeTitleList = pipe-delimited list of table headers, so can internationalize the report.||
|showAllResponsesExcept( questionList,attributeList,attributeTitleList)||questionListはパイプで区切られた質問IDのリスト、attributeListはパイプで区切られた属性のリスト(question#、title、text、typeなど、表示したいもの)、attributeTitleListはパイプで区切られたテーブルヘッダーで、レポートを国際化する||
|-
|-
|showTheseResponses( questionList,attributeList,attributeTitleList)||questionList = pipe-delimited list of question identifiers; attributeList = pipe-delimited list of attributes (like question#, title, text, type - so you can decide what to show); attributeTitleList = pipe-delimited list of table headers, so can internationalize the report.||  
|showTheseResponses( questionList,attributeList,attributeTitleList)||questionListはパイプで区切られた質問IDのリスト、attributeListはパイプで区切られた属性のリスト(question#、title、text、typeなど、表示したいもの)、attributeTitleListはパイプで区切られたテーブルヘッダーで、レポートを国際化する||  
|}
|}


<span id="Expression_Manager_Knows_Which_Variables_are_Local"></span>
==式マネージャーとローカル変数==
==式マネージャーとローカル変数==


In order to properly build the JavaScript for page, Expression Manager needs to know which variables are set on the page, and what their JavaScript ID is (e.g. for document.getElementById(x)).  It also must know which variables are set on other pages (so that it can ensure that the needed <input type='hidden' value='x'> fields are present and populated).
ページのJavaScriptを適切に構築するため、式マネージャーはページに設定されている変数とJavaScript IDが何であるかを知る必要があります(例: document.getElementById(x))。また、他のページにどの変数が設定されているかも知る必要があります(これにより、必要な<input type='hidden' value='x'>フィールドが存在しているか確認できます)。


<span id="Cascading_Conditions"></span>
==カスケードされた条件==
==カスケードされた条件==


If any of the variables are irrelevant, the whole equation will be irrelevant (false).  For example, in the following table, N/A means that one of the variables was not relevant
いずれかの変数がfalseである場合、式全体はfalseになります。たとえば、次の表では、N/Aは変数の1つがtrueでないことを意味します。


{| class="wikitable"
{| class="wikitable"
!Operator!!Example!!a!!b!!Result
!演算子!!説明!!a!!b!!結果
|-
|-
|<nowiki>+ (unary)</nowiki>||<nowiki>+a</nowiki>||N/A|| ||false
|<nowiki>+(単項)</nowiki>||<nowiki>+a</nowiki>||N/A|| ||false
|-
|-
|- (unary)||-a||N/A|| ||false
|-(単項)||-a||N/A|| ||false
|-
|-
|!||!a||N/A|| ||false
|!||!a||N/A|| ||false
|-
|-
|== (or eq)||a == b||N/A||5||false
|== (またはeq)||a == b||N/A||5||false
|-
|-
|== (or eq)||a == b||N/A||0||false
|== (またはeq)||a == b||N/A||0||false
|-
|-
|== (or eq)||a == b||N/A||N/A||false
|== (またはeq)||a == b||N/A||N/A||false
|-
|-
|!= (or ne)||a != b||N/A||5|| false
|!= (またはne)||a != b||N/A||5|| false
|-
|-
|!= (or ne)||a != b||N/A||N/A|| false
|!= (またはne)||a != b||N/A||N/A|| false
|-
|-
|!= (or ne)||a != b||N/A||0||false
|!= (またはne)||a != b||N/A||0||false
|-
|-
|> (or gt)||a > b||N/A||5|| false
|> (またはgt)||a > b||N/A||5|| false
|-
|-
|>= (or ge)||a >= b||N/A||5||false
|>= (またはge)||a >= b||N/A||5||false
|-
|-
|< (or lt)||a < b||N/A||5||false
|< (またはlt)||a < b||N/A||5||false
|-
|-
|<= (or le)||a <= b||N/A||5||false
|<= (またはle)||a <= b||N/A||5||false
|-
|-
|and||a and b||N/A||5||false
|and||a and b||N/A||5||false
Line 962: Line 1,019:
|(exp) op (exp)||(b + b) > (a && b)||N/A||5||false
|(exp) op (exp)||(b + b) > (a && b)||N/A||5||false
|-
|-
|function||sum(a,b,b)||N/A||5||false
|関数||sum(a,b,b)||N/A||5||false
|-
|-
|function||max(a,b)||N/A||5||false
|関数||max(a,b)||N/A||5||false
|-
|-
|function||min(a,b)||N/A||5||false
|関数||min(a,b)||N/A||5||false
|-
|-
|function||implode(', ',a,b,a,b)||N/A||5||false
|関数||implode(', ',a,b,a,b)||N/A||5||false
|-
|-
|function||if(a,a,b)||N/A||5||false
|関数||if(a,a,b)||N/A||5||false
|-
|-
|function||is_empty(a)||N/A|| ||false
|関数||is_empty(a)||N/A|| ||false
|-
|-
|function||is_empty(a)||0 (or blank)|| ||true
|関数||is_empty(a)||0 (or blank)|| ||true
|-
|-
|function||!is_empty(a)||N/A|| ||false
|関数||!is_empty(a)||N/A|| ||false
|}
|}


<span id="Overriding_Cascading_Conditions"></span>
===カスケードされた条件の上書き===
===カスケードされた条件の上書き===


Say you want to show a running total of all relevant answers.  You might try to use the equation {sum(q1,q2,q3,...,qN)}.  However, this gets translated internally to LEMif(LEManyNA('q1','q2','q3',...,'qN'),'',sum(LEMval('q1'),LEMval('q2'),LEMval('q3'),...,LEMval('qN'))).  So, if any of the values q1-qN are irrelevant, the equation will always return false.  In this case, the sum() will show 0 until all questions are answered.
出現条件を満たした回答の合計を表示したいとします。式 {sum(q1,q2,q3,...,qN)}を使おうとするでしょう。しかし、これは内部的にLEMif(LEManyNA('q1','q2','q3',...,'qN'),'',sum(LEMval('q1'),LEMval('q2'),LEMval('q3'),...,LEMval('qN')))に変換されます。これにより、値q1〜qNのいずれかが出現条件を満たさない場合、式は常にfalseを返します。この場合、sum()はすべての質問が出現して回答されない限り0となります。


To get around this, each variable can have a ".NAOK" suffix (meaning that Not Applicable is OK) added to it.  In such cases, the following behavior occurs.  Say you have a variable q1.NAOK
この問題を回避するために、各変数には".NAOK"という接尾辞(「Not Applicable」はOK)を追加することができます。このような場合、次のような現象が発生します。変数q1.NAOKがあるとします。
#q1 is not added to the LEManyNA() clause
#q1はLEManyNA()節には追加されません
#LEMval('q1') will  continue to check whether the response is relevant, and will return <nowiki>''</nowiki> if it is not (so individual irrelevant responses will be ignored, but they will not void the entire expression).
#LEMval('q1')は回答が出現条件を満たしているかを確認し、そうでない場合は<nowiki>''</nowiki>を返します(出現条件を満たさない回答は無視されますが、式全体を無効にしません)。


So, the solution to the running total problem is to use the equation sum(q1.NAOK,q2.NAOK,q3.NAOK,...,qN.NAOK).
したがって、合計を求める方法は、次の式となります。sum(q1.NAOK,q2.NAOK,q3.NAOK,...,qN.NAOK)


The use of the .NAOK suffix also lets authors design surveys that have several possible paths but then converge on common paths later.  For example, say subjects answer a survey in a way that is outside the normal range of responses.  The author could alert the subjects that they may not get valid results, and ask them whether they really want to  continue with the survey.  If they say Yes, then the rest of the questions will be shown.  The condition for the "rest of the questions" would check whether the initial responses were answered within the normal range OR whether the subject said Yes to the question that is only relevant if they answered outside the normal range.
.NAOK接尾辞を使用することで、いくつかの経路を経た後、共通の経路に収束するアンケートを設計することができます。例えば、回答者が正常な範囲外となるような回答をしたとします。アンケート作成者は、有効な結果を得られない可能性があることを回答者に警告し、アンケートを継続するかどうかを尋ねることができます。彼らが「はい」と答えた場合、残りの質問が表示されます。"残りの質問"の条件は、最初に正常な範囲内で回答があったかどうか、または正常な範囲外で回答した場合にのみ出現する質問に「はい」と回答したかどうかをチェックします。


<span id="How_does_Expression_Manager_Support_Conditional_Micro-Tailoring?"></span>
==式マネージャーはどのように条件付きカスタマイズを実現するか?==
==式マネージャーはどのように条件付きカスタマイズを実現するか?==


Here is an example of micro-tailoring (where Question Type=='expr' means an Equation):
ここでは、カスタマイズ(質問タイプ'expr'は式を意味します)の例を示します。


{| class="wikitable"
{| class="wikitable"
!Question Code!!Relevance!!Question Type!!Question
!質問コード!!出現条件!!質問タイプ!!質問
|-
|-
|name||1||text||What is your name?
|name||1||text||お名前は?
|-
|-
|age||1||text||How old are you?
|age||1||text||年齢は?
|-
|-
|badage||!is_empty(age)||expr||{(age<16) or (age>80)}
|badage||!is_empty(age)||expr||{(age<16) or (age>80)}
|-
|-
|agestop||badage||message||Sorry, {name}, you are too {if( (age<16),'young',if( (age>80),'old','middle-aged') ) } for this test.
|agestop||badage||message||{name}さん、失礼ですが、アンケート回答者として{if( (age<16),'若すぎます',if( (age>80),'高齢すぎます','中くらいの年齢です') ) }
|-
|-
|kids||!badage||yesno||Do you have children?
|kids||!badage||yesno||お子様はいますか?
|-
|-
|parents||1||expr||{!badage && kids=='Y'}
|parents||1||expr||{!badage && kids=='Y'}
|-
|-
|numKids||parents||text||How many children do you have?
|numKids||parents||text||何人のお子様がいますか?
|-
|-
|kid1||parents && numKids >= 1||text||How old is your first child?
|kid1||parents && numKids >= 1||text||第一子の年齢は?
|-
|-
|kid2||parents && numKids >= 2||text||How old is your second child?
|kid2||parents && numKids >= 2||text||第二子の年齢は?
|-
|-
|kid3||parents && numKids >= 3||text||How old is your third child?
|kid3||parents && numKids >= 3||text||第三子の年齢は?
|-
|-
|kid4||parents && numKids >= 4||text||How old is your fourth child?
|kid4||parents && numKids >= 4||text||第四子の年齢は?
|-
|-
|kid5||parents && numKids >= 5||text||How old is your fifth child?
|kid5||parents && numKids >= 5||text||第五子の年齢は?
|-
|-
|sumage||1||expr||{sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK,kid5.NAOK)}
|sumage||1||expr||{sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK,kid5.NAOK)}
|-
|-
|report||parents||yesno||{name}, you said you are {age} and that you have {numKids}.  The sum of ages of your first {min(numKids,5)} kids is {sumage}
|report||parents||yesno||{name}さん、あなたの年齢は{age}歳、{numKids}名のお子様がいると回答しました。{min(numKids,5)}番目のお子様までの年齢の合計は、{sumage}です。
|}
|}


All of these questions can be on a single page (e.g. in the same group), and only the relevant questions will display.  Moreover, as you enter the ages of children, the sum() expression in the last question will dynamically update on the page.
これらの質問はすべて1つのページ(たとえば同じグループ)に入れることができ、出現条件に合致する質問のみが表示されます。さらに、子供の年齢を入力すると、最後の質問のsum()式がページ上で動的に更新されます。


Expression Manager provides this functionality by surrounding each expression with a named <nowiki><span></nowiki> element.  Every time a value changes, it recomputes the expression that should appear in that <nowiki><span></nowiki> element and regenerates the display.  You can have dozens, or even hundreds, of such tailored expressions on the same page, and the page will re-display all of them in a single screen refresh.
式マネージャーは、各式を名前付き<nowiki><span></nowiki>要素で囲むことでこの機能を提供します。値が変更されるたびに、その<nowiki><span></nowiki>要素に表示される式を再計算し、再表示します。そのようなカスタマイズされた式が同じページに数十、または数百もあっても、ページは一度の画面更新ですべて再表示されます。


<span id="Mapping_of_LimeSurvey_1.91+_to_Expression_Manager_Functionality"></span>
==LimeSurvey 1.91と式マネージャー機能の対照表==
==LimeSurvey 1.91と式マネージャー機能の対照表==


{| class="wikitable"
{| class="wikitable"
!Old Feature!!New Feature!!Comments
!旧機能!!新機能!!コメント
|-
|-
|Conditions||Relevance||You can use very complex conditional equations, and access a broader range of variables
|条件||出現条件||非常に複雑な条件式を使用して、より広い範囲の変数にアクセスできます。
|-
|-
|Assessments||Equation||Any assessment scores can be re-structured into an Equation. This both ensures that the score is written to the database, and also lets you see dynamic changes to the score value on the current page
|評価||||どの評価スコアも式に再構成することができます。これにより、スコアがデータベースに書き込まれるとともに、現在のページでスコア値が動的に変化しても表示できます。
|-
|-
|Replacements||Expression Manager||The core engine takes the input string and treats everything within curly braces as an Expression - so it handles all historical replacements types.  To avoid messing up embedded JavaScript, Expression Manager only processes content between curly braces as long as (a)  there is no leading or trailing whitespace within the curly braces - e.g. {expr} is an expression, but { expr}, {expr }, and { expr } are not expressions.  Furthermore, Expression Manager does not process content within its own strings (e.g. {list('hi','there {braces}')} generates "hi there {braces}").  It also ignores escaped curly braces (e.g. \{this is not an expression\})
|置換||式マネージャー||コアエンジンは入力文字列を取得すると、中括弧内のすべてを式として扱います。したがって、すべての置換タイプを処理します。埋め込まれたJavaScriptの混乱を避けるために、式マネージャーでは、中括弧内に先頭または末尾の空白がない限り、中括弧間のコンテンツしか処理しません。たとえば{expr}は式ですが、{ expr}{expr }{ expr }は式ではありません。さらに、式マネージャーは文字列内のコンテンツを処理しません(たとえば、{list('hi','there {braces}')}"hi there {braces}"となります)。また、エスケープされた中括弧も無視されます(例えば、\{this is not an expression\})。
|-
|-
|Validation||Expression Manager||The plan is to take the current min/max Question Attributes and have Expression Manager process them.  That way the min/max values can be expressions themselves
|検証||式マネージャー||現在の最小/最大の質問属性を使って、式マネージャーからそれらを処理する計画です。これにより、最小値/最大値は式そのものになります。
|}
|}


<span id="Syntax_Highlighting"></span>
=構文ハイライト=
=構文ハイライト=


To help with entering and validating expressions, EM provides syntax highlighting with the following features:
式の入力と検証を支援するために、EMでは以下のような構文強調表示機能を提供しています。


<span id="Types_and_Meanings_of_Syntax_Highlighting"></span>
==構文ハイライトの種類と意味==
==構文ハイライトの種類と意味==


{| class="wikitable"
{| class="wikitable"
!Color!!Sample!!Meaning!!Tooltip!!Comments
!!!サンプル!!意味!!ツールチップ!!コメント
|-
|-
|tan background||style='background-color: #eee8aa'|Sample||the whole equation||none||Anything within curly braces that is recognized as an equation (e.g. there is no leading or trailing whitepace) will be color-coded with a tan background to help distinguish it from surrounding text
|黄褐色の背景||style='background-color: #eee8aa'|サンプル||式全体||なし||式として認識される中括弧内のもの(先頭または末尾の空白がない)は、周囲のテキストと区別するのに役立つ黄褐色の背景で色分けされます。
|-
|-
|bold red text||style='color:#ff0000; background-color:#eee8aa'|'''Sample'''||An error||Some explanation on error||Can be an unknow variable or an error in function, .... Survey can be totally broken, this don't show to public user.
|太字赤色のテキスト||style='color:#ff0000; background-color:#eee8aa'|'''サンプル'''||エラー||エラーに関する説明||未知の変数または関数のエラーの可能性があります。アンケートは完全に壊れている可能性がありますが、これは一般ユーザーには表示されません。
|-
|-
|blue text||style='color:#0000ff; background-color:#eee8aa'|Sample||function name||meaning and allowable syntax||function names, or things that should be functions since they are followed by an opening parenthesis, are presented in bold blue text.  Tooltips show the meaning and allowable syntax for the function.
|青色のテキスト||style='color:#0000ff; background-color:#eee8aa'|サンプル||関数名||関数の意味と構文||関数名、または開く括弧が続くので関数と思われるものは、太字の青いテキストで表示されます。ツールチップには、その機能の意味と許容される構文が表示されます。
|-
|-
|grey text||style='color:#808080; background-color:#eee8aa'|Sample||string||none||single and double-quoted strings are shown in grey text
|灰色のテキスト||style='color:#808080; background-color:#eee8aa'|サンプル||文字列||なし||シングルもしくはダブルクォートで囲まれた文字列が灰色のテキストとして表示されます。
|-
|-
|cyan text||style='color:#4169e1; background-color:#eee8aa'|Sample||variable set on the same page,||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on the same page to the current question is shown in cyan text, showning it can be updated in javascript.  The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set).  If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|水色のテキスト||style='color:#4169e1; background-color:#eee8aa'|サンプル||同じページにセットされた変数||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; ; それぞれの値のコードが示された回答リスト||現在の質問と同じページに設定されている変数は水色のテキストで表示され、javascriptで更新されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
|-
|-
|green text||style='color:#008000; background-color:#eee8aa'|Sample||variable set on a prior page||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on a prior page is shown in bold green text.  The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set).  If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|緑色のテキスト||style='color:#008000; background-color:#eee8aa'|サンプル||先行するページでセットされた変数||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; ; それぞれの値のコードが示された回答リスト||先行するページに設定されている変数は太字の緑色のテキストで表示されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
|-
|-
|bold pink text||style='color:#9370db; background-color:#eee8aa'|Sample||variable set on a later page <sup>in general : empty at survey start, but can be filled with index or move previous</sup>||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on a prior page is shown in bold pink text.  The tooltip shows its name (if you used INSERTANS:xxx) or SGQA code (if you used the new naming system), the actual question, and its current value (or blank if not set).  If the question type expects responses from an enumerated value set, the mapping of the codes to display values is show.
|太字桃色のテキスト||style='color:#9370db; background-color:#eee8aa'|サンプル||後続のページでセットされた変数<sup>一般的には、アンケート開始時は空で、インデックスや前への移動を使用した時に値が入ります。</sup>||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; ; それぞれの値のコードが示された回答リスト||後続のページに設定されている変数は太字の桃色のテキストで表示されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
|-
|-
|bold tan text||style='color:#a0522d; background-color:#eee8aa'|Sample||a lime replacement value||the value||Lime Replacement Strings (like {TOKEN:xxx}, {PRIVACY_MESSAGE}) are shown in bold tan text.  
|太字の黄褐色のテキスト||style='color:#a0522d; background-color:#eee8aa'|サンプル||LimeSurveyの置換値||||LimeSurveyの置換文字列({TOKEN:xxx}{PRIVACY_MESSAGE}など)は太字の黄褐色のテキストとして表示されます。  
|-
|-
|red text||style='color:#ff4500; background-color:#eee8aa'|Sample||assignment operator (=) ||warning message||If you use one of the assignment operator (=) that operator will be displayed in red text.  This is meant to help prevent accidental re-assignment of values when you really meant to check whether a == b instead of  setting the value of a = b.
|赤色のテキスト||style='color:#ff4500; background-color:#eee8aa'|サンプル||代入演算子(=||注意喚起メッセージ||代入演算子(=)を使用すると、演算子は赤色のテキストで表示されます。これは、aとbは等しいことを確認しようとしているとき、誤ってbの値をaに代入することを防ぐのに役立ちます。
|-
|-
|normal black text||style='color:black; background-color:#eee8aa'|Sample||punctuation||none||All other punctuation within the expression is shown as normal black text.
|通常の黒色のテキスト||style='color:black; background-color:#eee8aa'|サンプル||句読点||なし||式の内の他の句読点はすべて、通常の黒文字で表示されます。
|-
|-
|red-boxed text||a bold red line surrounds the error||syntax error||description of the error||Any detected syntax errors are shown by surrounding the error with a red box.  The tooltip shows the error.  Examples include unmatched parentheses, use of undefined functions, passing the wrong number of arguments to functions, poorly structured expressions (e.g. missing operators between variables), trying to assign a new value to a read-only variable, trying to assign values to non-variables, or using unsupported syntax.  Note that the syntax error dectection system may only report one error in an expression even if there are multiple errors; however, if any errors are detected, at least one error will be shown.
|赤枠で囲まれたテキスト||赤い太線で囲まれたエラー||構文エラー||エラーの説明||検出された構文エラーは、エラーを赤い枠線で囲んで表示されます。ツールチップにエラーが表示されます。例としては、括弧の不一致、未定義関数の使用、関数に渡す引数の数の誤り、構造化が不十分な式(変数間の演算子の欠落など)、読み取り専用変数に値を代入しようとする、変数でないものに値を代入しようとする、サポートされていない構文を使用するなどです。構文エラー検出システムは、複数のエラーがあっても式内の1つのエラーだけを報告することがあります。ただし、エラーが検出された場合は、少なくとも1つのエラーが表示されます。
|}
|}


<span id="Additional_Reading"></span>
=参考記事=
=参考記事=


<span id="Expression_Manager_sample_surveys"></span>
==[[Expression Manager Sample Surveys/ja|式マネージャーのサンプル]]==
==[[Expression Manager Sample Surveys/ja|式マネージャーのサンプル]]==


<span id="Use_Cases_and_HowTos"></span>
==[[Expression Manager HowTos/ja|ユースケースとHowTo]]==
==[[Expression Manager HowTos/ja|ユースケースとHowTo]]==


<span id="Step-by-Step_examples"></span>
==[[Expression Manager Examples/ja|ステップバイステップの例]]==
==[[Expression Manager Examples/ja|ステップバイステップの例]]==


<span id="Expression_Manager_statistic_functions"></span>
==[[StatFunctions/ja|式マネージャーの統計関数]]==
<span id="Reference_for_Developers"></span>
==[[Expression Manager for developers/ja|開発者向け参考情報]]==
==[[Expression Manager for developers/ja|開発者向け参考情報]]==


<span id="RoadMap/Status/ToDo_List"></span>
==[[Expression Manager Roadmap/ja|ロードマップ/状況/ToDoリスト]]==
==[[Expression Manager Roadmap/ja|ロードマップ/状況/ToDoリスト]]==

Latest revision as of 00:05, 8 April 2024

注意 : この機能は LimeSurvey 1.92 以降で利用できます。

クイックスタート

概要

アンケートをカスタマイズするには、通常、次のことを指定する方法が必要です :

  1. ナビゲーション・分岐 - アンケート参加者の回答によって質問の順番を変更できるようにします。
  2. テーラーリング・パイピング - 質問の表現方法(先行する回答の参照、調査の課題による参加者数や性別に合わせた語句の変化など)、(評価スコアやカスタマイズしたアドバイスなど)カスタマイズしたレポートを生成する方法
  3. 検証 - 最小値と最大値、または入力パターンの一致など、回答が特定の基準を満たしていることを確認します。

式マネージャー(EM)では、各機能のロジックを指定する直感的な方法が提供されています。関数を呼び出しているものであっても、標準的な数式として書くことができるものは、ほとんどが有効な式になります。EMは現在、70の関数が利用でき、より多くの機能をサポートするよう、簡単に拡張することができます。また、(SGQA名ではなく)人間が読める変数名を使用して変数にアクセスすることもできます。

以下のセクションで、式マネージャーを使う主な場面を紹介します。

関連(ナビゲーション制御/分岐)

アンケートによっては、"Gotoロジック"を使用して、質問1でCと答えた場合は質問5にジャンプしたりします。このアプローチは、検証が難しく、質問を並べ替えるときにロジックが壊れてしまうため、大きな制約があります。EMでは、質問が有効かどうかを決めるすべての条件を、ブール値の出現条件式を使用して指定します。質問が出現条件を満たす場合は質問が表示され、それ以外の場合は「適用外」となり、データベースにはNULL値が格納されます。これは条件エディターで実行できるものと似ていますが、EMではより複雑で強力な条件を簡単に指定でき、さらにSGQA名ではなく変数名を使用できます。

この画像では、アンケートの関連性ロジックを確認する例を示しており、ここでは、体格指数(BMI)を計算します。関連式は、変数名の直後の角カッコで示されています(緑色)。体重、体重の単位、身長、身長の単位の関連式はすべて1です。つまり、これらの項目は常に質問されます。しかし、BMIの関連式は、 {!is_empty(height) and !is_empty(weight)}となっており、BMIは、身長と体重の両方を入力しないと計算しないようになっています(ゼロで割るリスクも避けています)。また、「Report」の質問は、主たる4つの質問(身長、身長の単位、体重、体重の単位)すべてに回答した場合にのみ表示されます。

関連は以下の場所て表示・編集ができます。

質問レベルの関連の閲覧/編集

この式は、体格指数(BMI)を計算します。最初に身長と体重を入力した場合のみ対象となります。

こちらがBMI質問の編集画面です。

関連式を入力するときは中括弧を使用しないようにしてください。

グループレベルの関連の閲覧/編集

これは、国勢調査の調査例です。最初のページで、回答者に同居人数を尋ね、結果が"cohabs"変数に格納されています。このページは、複数の同居人がいる場合(つまり、このページは同居している2番目の人物に関するもの)で、回答者と「人物1」の関係(p1_rel)を指定した場合にのみ表示されます。

ご覧のように、グループには質問レベルの関連基準もあり、こうした質問は、先行する質問に回答したときにのみ表示されます(例:{!is_empty(p1_sex)})。EMは、グループと質問レベルの関連を結合します。グループ内の質問は、グループ全体が関連する場合にのみ尋ねられます。次に、関連するグループ内の質問のサブセットのみが尋ねられます。

その質問のグループレベルの関連を編集する画面は次のとおりです。

関連式を入力するときは中括弧を使用しないようにしてください。

カスタマイズ/パイプ

EMを使用すると、単純な、または複雑な条件付きの質問を簡単に作成できます。例えば、"[製品]を購入したと回答しました。よかった点は何ですか?"のように、単純な「置き換え」が必要な場合があります。また、"[Mr./Mrs.] [LastName]、アンケートを完了してもよろしいですか?"のように、条件付きの置き換えが必要な場合もあります。この場合、回答者の性別に基づいてMr.かMrs.を使用します。また、例えば、数学的計算に基づいてさらに複雑な置き換えが必要になることもあります。EMは、このような場合のカスタマイズ/パイプをサポートしています。

条件式

体格指数の例では、身長と体重の入力単位がメートル法であってもメートル法でなくても、BMIが計算できることを示しています。

ここで、weight_kgは、{if(weight_units == 'kg', weight, weight * .453592)}となっています。このif()関数では、キログラムで体重が入力されていた場合は入力値をそのまま採用し、それ以外の場合は入力値(単位はポンド)に0.453592をかけてキログラムに変換します。同様に、変数height_mは、身長がインチ単位で入力されていてもメートル単位の身長を計算するようになっています。

BMIは、{weight_kg / (height_m * height_m)}という式で計算されます。

最後に、回答者に対し、条件付きでカスタマイズして入力した内容を表示します。("身長2メートル、体重70キロと回答しました。")

上の画像ではわかりにくくなっていますが、weight_statusは入れ子のif()ステートメントを使用し、その人物がやせているのか肥満なのかを分類します。その式をロジックビューで見ることができます。

この質問の編集ウィンドウから、次の2つのことがわかります。

  1. 中括弧で表現を囲む必要があります
  2. 式は、例えばこの例のように、ネストされた条件付きロジックを読みやすくするため、複数の行にまたがって記述することができます。

カスタマイズされた質問・解答・レポート

注意: 同じ質問ページの選択ボックスで回答オプションを利用できるようにすると、動的カスタマイズが機能しないことがあります。これは、選択オプション内で使えない<span>タグを挿入してしまうことに起因しています。

この例は、BMIレポートを示しています。

同じ質問の編集ウィンドウです。

ご覧のように、中括弧で囲われた部分は式として扱われるので、前の画像では構文ハイライト(色分け)されています。タイプミスや定義されていない変数名や関数のような誤字があった場合、EMはこのようなエラーを表示します。例えば、height_unitは未定義の変数名(実際はheight_units)、rnd()は未定義関数(正しくはround())です。いずれの場合も、エラーを赤い枠で囲み、見つけて修正しやすくなっています。

また、入力された値の一覧やカスタマイズされたアドバイスなど、複雑なレポートをすばやく作成できます。

質問のどの部分がフリーテキストで、どの部分が式マネージャーで解析する必要があるかをLimeSurveyが判断するため、すべての式をCurly Bracesで囲む必要があります。

検証

EMは、高度な質問オプションがどのように機能するかを制御します。回答の数、個々の入力値や合計の最小値/最大値を制限したり、入力された値が指定された文字列パターンと一致していることを確認したりします。いつものように高度な質問オプションの入力を行いますが、これらのフィールドの値はどれも式と見なされるため、他の質問と複雑な条件で組み合わせ、最小値/最大値基準を設定することができます。

これらのすべてのケースでは、高度な質問オプションは常に式と見なされるため、中括弧を使用することはありません。

サンプルアンケートページには、検証のために式を使用した実例がたくさんあります。

はじめに

LimeSurveyでは、新しいExpression Manager(EM)モジュールを使用して、より複雑な分岐、評価、検証、およびカスタマイズがサポートされています。LimeSurveyがサーバー内で行う置換、条件、評価の管理方法を置き換えることができます。また、ランタイムデータベースの読み込みのほとんどが不要になるため、処理速度が大幅に向上します。EMはDr. Thomas White(TMSWhite)が開発しました。

このwikiページは、Expression Managerの構文と機能のリファレンスです。

主な定義

  1. :  中括弧で囲まれたもの
    • 開く中括弧の直後または閉じる中括弧の直前に空白がない
    • 式の内容はEMが評価するため、数式、関数、複雑な文字列と日付処理を含めることができます。
  2. カスタマイズ: "パイピング"とも呼ばれますが、これは条件付きでテキストを変更するプロセスです。
    • すべての'置換フィールド'、参加者データ、回答データにアクセスできます。
    • 質問、回答、およびそのプロパティにも簡単にアクセスできます。
  3. 出現条件式:  質問を表示するかを制御する新しい質問属性
    • 出現条件式がある場合、その出現条件が真と評価された場合にのみ質問が表示されます。
    • 内部では、すべてのarray_filterコマンドとarray_filter_excludeコマンドがサブ質問レベルの出現条件になります。
  4. 質問タイプ:  データベースに計算やレポートを保存する新しい質問タイプ
    • これはテキストを表示する質問のようなものですが、"この質問をいつも隠す"を設定しても、その内容はデータベースに保存されます。
  5. 質問コード:  EMでの使用が推奨される変数名
    • これは質問の目的を示すわかりやすい名前にすることができ、複雑なロジックを読みやすくなります。
    • 質問コードは数字で始めることはできないので、質問番号を質問コードにするときは、単に"q1"、"q1a"、"g1q2"のようにしてください。
    • 現在のところ、データをSPSSまたはRにエクスポートすると、これが変数名になります。したがって、統計分析を行う場合は、ユニークにしなければなりません。

EMを使わなければならないのか?

短い答えは「いいえ」ですが、「はい」でもあります。

EMは、既存のアンケートと完全に後方互換性があります。LimeSurveyバージョン1.91+以前で使用されていたスタイルの条件と評価は、引き続き使うことができます。

ただし、EMでは、LimeSurveyが内部的にどのように条件を処理するかについて完全に置き換えられています。条件エディタを使用して条件を作成したり管理したりすることはできますが、LimeSurvey 1.92ではそれらは同等の関連式に変換されます。アップグレードの一環として、LimeSurvey 1.92では既存のすべての条件が関連式に自動変換されます。

これにより、新旧のいいとこ取りができます。これまで通りLimeSurveyを使い続けることもできますが、同等の関連式が表示されるので、関連式に徐々に移行することもできます。

条件と関連の両方を使えるか?

はい。質問によって条件エディターを使用することも、出現条件エディターを使用することもできます。質問を保存すると、条件は自動的に出現条件に変換されます。

条件エディターを使用している場合、手動で入力した関連式は上書きされます。したがって、すでに条件があって、関連を手動で編集したい場合は、まずその質問の条件を削除してください。具体的には、生成された関連式をテキストエディターにコピーし、条件メニューからその質問の条件をすべて削除し(関連も削除)、質問を編集し、テキストエディタからその質問の関連フィールドに貼り付け、質問を保存します。生成された関連式を削除せずに条件を削除したいというニーズが場合、一括変換プロセスの追加開発を検討します。

条件と関連のどちらを選ぶべきか?

各々の長所と短所のリストを以下に示します。

スタイル 長所 短所
条件 1. シンプルな条件を作成するための優れたGUI
2. サポートチームにより文書化され理解しやすいGUI
1. 簡単な比較のみをサポートし、AND/OR条件はうまく機能しない
2. カスケード条件が不安定
3. データベースアクセスが遅く、アンケートに時間がかかる
4. 条件のリロードで不具合がレポートされている
5. GUIに拡張性がなく、何十、何百、または何千もの質問があるときにうまくいかない。
6. SGQA名を使用しなければならないので、紙ベースのアンケートを変換するのが遅いかもしれない
7. 複雑な分岐が必要な場合、カスタムコードロジックを書くプログラマーが必要なことがある
関連 1. 80以上の関数と数学/文字列演算子を含む非常に複雑なロジックのサポート
2. カスケードロジックの完全サポート
3. 高速 - 余計なデータベースアクセスがなく、1000以上の質問があるアンケートをサポート
4. SGQAコードを必要としないため、リロードロジックで問題が生じない
5. 構文ハイライト機能は1000以上の質問があるアンケートにも対応
6. 既存の紙ベースのアンケートを電子化に簡単かつ迅速に対応
7. プログラマーを必要とせずに半構造化インタビューや疫学調査を容易にサポート
1. 単純な条件のためのGUIがない(代わりに構文ハイライト機能を使用)
2. まだ新しい機能で、サポートチームがまだEMをマスターしていない

LimeSurvey 1.91+の仕組みに満足していれば、変える理由はありません。

EMのメリットは他にあるか?

EMを使うべき理由がいくつかあります。

  1. 計算 - 任意の計算式を作成することができます。
    • 一般的な数学的演算子と関数のすべてを利用できます。
    • 70以上の数学、日付、および文字列処理関数を利用できます。
    • 必要な場合、新しい関数を簡単に追加できます。
  2. データベースへの計算の保存
    • シンプル/複雑な式や評価点を計算し、JavaScriptを要せずにデータベースに保存できるようになりました。
    • 式の質問タイプを使用してます。
  3. 評価
    • 以前は一部のみサポートされていましたが、すべての質問タイプからの評価やスケールの作成が可能になりました。
    • カスタマイズを使用すると、同じページであっても、必要な場所で、途中または合計の評価点数を表示できます。
    • 評価点数に基づいて生成されたレポートをより細かくコントロールできます。
    • JavaScriptを使用せずに評価点数をデータベースに保存することができます。
    • 評価点数は、JavaScriptやCSSを使わずに非表示にできます。
  4. 代替フィールド
    • {INSERTANS:SGQA}を使う代わりに、質問コードを使用すると、読みやすく、検証しやすくできます。
    • これにより、すべてを動作させるため質問を編集してSGQAコードを変更する必要もなくなります。
  5. カスタマイズ - 他の値に基づいてテキストをカスタマイズして表示できます。#*適切な敬称を使用する(例: "Hello [Mr./Mrs.] Smith")。
    • 単数/複数に基づき文法的に正しい文章を出力する(例: "You have 1 child"と"You have 2 children")
    • 性や数に基づいて動詞や名詞を変化させる
  6. 新しい変数の属性 - 次の項目にアクセスして調整できます。
    • (接尾辞なし) - qcode.codeの別名
    • .code - 質問が表示された場合は選択された回答コード(それ以外の場合は空白)、またはテキスト値(コード化されていない質問の場合)
    • .NAOK - .codeと同じですが、非表示となる場合であっても計算やリストに含めることができます。
    • .value - 質問が表示対象となる場合はその質問の評価値(それ以外の場合は空白)、またはテキスト値(コード化されていない質問の場合)
    • .valueNAOK - .valueと同じですが、非表示となる場合であっても計算やリストに含めることができます。
    • .shown - ユーザーに表示される回答(これは{INSERTANS:xxx}の機能です)
    • .qid - 質問ID
    • .gid - グループID
    • .sgqa - 質問のSGQA値
    • .jsName - (このページで定義されているかどうかに関係なく)質問に対する正しいjavascript変数名
    • .qseq - 質問の順番(0から開始)
    • .gseq - グループの順番(0から開始)
    • .mandatory - 質問が必須かどうか(Y/N)
    • .question - 質問のテキスト
    • .relevance - 質問の関連式
    • .grelevance - グループの関連式
    • .relevanceStatus - 質問が表示条件を満たしているかどうか(1/0)
    • .type - 質問タイプ(1文字のコード)
  7. ページ内の動的変更
    • すべての関連、計算、およびカスタマイズはページ内で動的に機能するため、値の変更によりページが即座に更新されます。
    • したがって、関連の評価結果に基づいて、質問が動的に表示/非表示になります。
    • また、ページ内の回答に基づいて質問も動的に調整されるため、合計値、カスタマイズされた文、カスタマイズされたレポートをみることができます。
  8. 新しいデータ入力画面
    • 現在のデータ入力システムを使用するだけでなく、単ページアンケートでも使用することもできます。
    • ページ内の関連とカスタマイズがサポートされており、データ入力担当者はタブキーで入力を進め、関連する回答を入力するだけで済みます。
    • この特徴は、データ入力者がカスタマイズによる動的変化を確認する必要がある場合に重要です。
  9. ほとんどのカスタムJavaScriptの必要性を排除
    • EMは、複雑な計算、点数づけ、カスタマイズ、および条件付きロジックを容易にサポートします。
    • JavaScript(カスタムレイアウトや条件付きの質問サブ要素など)を必要とするものもありますが、JavaScriptによって、EM関数を使用してSGQAの代わりにQcodeで質問にアクセスし、上記の質問属性にアクセスすることができます。

式マネージャーのその他の新機能

条件エディターを引き続き使用するか、または関連式を手動で作成するかにかかわらず、次のような利点があります。

  1. より複雑な検証基準を作成することができます。
    • すべての高度な質問属性(max_answers、min_num_value_n、max_num_valueなど)は式を使用できます。したがって、最小値・最大値の条件は、同じページの先行する質問の回答に基づいて簡単に調整できます。
    • EMは正規表現ベースの検証をすべて処理するので、pregと式ベースの質問属性を強固に組み合わせることができます。
  2. 質問とグループの並べ替え(または削除)が容易にできます。
    • バージョン1.92より前のバージョンでは、並べ替えによって条件が成立しなくなる可能性があると認識された場合、質問やグループの並べ替えはできませんでした。同様に、ある質問に依存する質問がある場合は、その質問を削除できませんでした。
    • EMの構文強調表示により、これから宣言して使おうとしている質問を確認し、検証することが簡単にできです。したがって、いつでも質問やグループを並べ替えたり、削除したりすることができます。EMは潜在的なエラーを表示するためにすべての構文強調表示を更新します。
    • このようなレビューに役立つように、質問並べ替えの表示が強化されました。質問の関連式とカスタマイズが表示されるので、変数がピンク(宣言する前に使用されていることを意味します)になったかどうかをすぐに確認できます。
  3. 質問やグループのナビゲーション番号は常に利用可能で正確です。
    • バージョン1.92以前は、複雑な条件があった場合、ナビゲーション番号は利用できませんでした。
    • EMでは、正確であることを保証されています。
    • 前の質問に戻り、答えを変えてから、後ろにジャンプする(または送信する)こともできます。
      • 前進すると、EMは関係するすべての質問/グループを再検証します。
      • 表示条件に該当しなくなる質問があれば、データは内部で一貫性を保つためデータベースにNULLが格納されます。
      • 質問が表示条件に該当したり、新たに必須条件または検証ルールに適合しなくなった場合、EMはそのページで停止し、ユーザーが最終ページに飛ぶ前にそれらの質問に答えなければならないようにします。
  4. 条件から関連への自動変換
    • データベースをアップグレードすると、条件を持つ既存のすべてのアンケートに関連式が生成されます。
    • アンケートをインポートするたびに、関連式が必要に応じて作成されます。
    • 条件を追加、削除、または変更すると、EMは適切な関連式を生成します。
  5. 便利な構文強調表示
    • SGQAコードを入力した場合であっても、EMが関連式を表示するときは、Qcodeが表示されます。読みやすくするためです。
    • すべての変数は、現在の質問の前後(または現在のグループの前後)に宣言されたかどうかを示すために色分けされています。これにより、変数を宣言する前に、関連(array_filterを含む)、カスタマイズ、検証式で使用する変数を使うケースをすばやく検出して修正できます。
    • 色付けされた変数の上にマウスを移動すると、その質問に関する追加情報が表示されます。これには、グループ番号、質問番号、Qcode、質問のテキスト、利用可能な回答の選択肢(該当する質問タイプの場合)が含まれます。
      • 回答の選択肢のリストは、次のような構文を使用します: 'answers':{key:val, ... }.
      • keyは'scale~code'という構文となります。scaleは回答の尺度(二元スケールなど)、codeは回答コードです。
      • valは'value~shown'という構文となります。valueは評価値(評価を使う場合。その他の場合はコード)、shownは表示される値です(Qcode.shownなど)。
      • つまり、多くの場合、アンケートで評価モードを使わずに計算を使用できます。ユニークで、10進数でなく、負の数でない回答オプションを列挙する場合は、Qcode.code値の計算を行うことができます。
  6. アンケートロジックとコンテンツ全体の簡単なレビュー
    • 新しいアンケートロジック表示機能があり、アンケート(またはグループ、質問)に関するすべての情報を1ページに表示できます。
    • 選択したスコープ(アンケート、グループ、質問)のグループ、質問、サブ質問、回答レベルの詳細を表示します。
    • また、関連、サブ質問レベルの関連(array_filterとarray_filter_exclude)、生成された検証式(pregと合計の最小値・最大値、値の数などの検証ルール)、およびすべての空白以外の質問属性も表示されます。
    • すべて構文強調表示されているため、潜在的な構文エラー(括弧の不一致、未宣言の変数使用など)を発見できます。
    • 構文強調表示により、アンケートのナビゲーションと編集が迅速にできるようになります。
      • 変数名をクリックすると、その質問を示すブラウザウィンドウ(またはタブ)が開き、編集することができます。
      • グループ名をクリックすると、グループの並べ替えビューを表示するブラウザウィンドウ(またはタブ)が開き、簡単に質問を移動できます。
      • すべての質問属性も構文強調表示されています。これにより、高度な質問オプション内で式を設定したり表示したりすることができます(式の最大値/最小値/合計など)
    • EMの製作者は、似たようなビューを使い、疫学者と治験審査委員会が高度に分岐する、何千もの質問があるアンケートを検証し、認可できるよう協力しました。

始めてみる

式マネージャーを始める最善の方法は以下のとおりです。

式マネージャーでは、どの機能が拡張/置換されたのか?(LimeSurvey 1.91から)

条件 → 関連

どの質問が表示されるかを制御する条件。一般的な構文は、111X2X3 == "Y"'のようなSGQA 演算子 値でした。条件はANDまたはORを組み合わせることができますが、ANDとORを混在させることは困難でした。条件自体は独立したテーブルに保存され、LimeSurveyのコードの大部分は条件の管理に費やされていました。膨大なデータベースアクセスのため、多数の条件を処理すると、パフォーマンス上の深刻な問題が発生する可能性がありました。さらに、条件が質問やグループに一旦割り当てられると、それらを並べ替えたり削除したりすることはできませんでした。

評価 → 式と細かいカスタマイズ

評価機能により、一連の質問から評価値を算出することができます。ただし、表示中のページ内で動的に変更することはできず、またその値はデータベースに保存されませんでした。

置換 → 細かいカスタマイズ

ユーザーは、先行する回答に基づいてメッセージや質問をカスタマイズできます。たとえば、{TOKEN:FIRSTNAME}さん、あなたは{INSERTANS:111X3X4}が好きなスポーツだと回答しましたのような質問が可能です。しかし、条件付きのカスタマイズ(性別に応じて"Mr."や"Mrs."をつけるなど)や、動詞や名詞を変化させたりすることはJavaScriptなしにはできませんでした。質問をカスタマイズするようなアンケートを実装することはできましたが、すべての組み合わせに対する個別の質問が必要であり、表示する質問を決定する複雑な条件が必要でした。

検証

質問は、正規表現や最小値/最大値で検証するか、SGQAの回答を最小値または最大値として使用することができました。ただし、JavaScriptなしで他の変数の計算に基づいて検証することはできませんでした。

式はJavaScriptなしでは実現できませんでした。

式の質問タイプ

JavaScriptを使用せずに式をデータベースに保存すること(評価の最終スコアなど)はできませんでした。

式マネージャーはどのように機能を拡張するのか?

式マネージャーは、カスタムJavaScriptを必要とする複雑な機能をより簡単に実現できるLimeSurveyの新しいコアモジュールです。LimeSurveyが条件と評価を管理する現場の方法に取って代わるものです。

式マネージャー(EM)向けの新しい用語

EMは次のように機能を定義しています。

  • 関連に基づく分岐 - 質問が関連する場合は表示し、そうでない場合は非表示にします(データベースにNULLとしてマークします)。すべての質問タイプと各々のグループに対して新たな関連フィールドが追加されています(したがって、各質問に同じ条件をコピーしたりすることなくグループ全体に条件を設定でき、また、グループレベルと質問レベルの条件を組み合わせることができます)。
  • カスタマイズ - どの質問を聞くべきかを決めたら、カスタマイズ(パイピングとも呼ばれる)によって、質問方法を指定します。これは簡単な置き換え(例:{TOKEN:FIRSTNAME})だけでなく、性別や人数によって動詞や名詞の変化も可能です。また、他の質問に回答したか(または回答内容)に基づいて、送信するメッセージを変更することもできます。
  • - EMでは、式の結果を格納する新しい質問タイプ(式)が追加されました。式の結果は、たとえページ上で非表示であって、計算結果はデータベースに書き込まれます。これにより、裏で行われるスコア計算、複雑な式に基づくナビゲーション、評価、およびレポートの作成が可能になり、データベース上で簡単に利用することができます。

関連とカスケードされた関連

すべての質問タイプで、質問が表示されるかどうかを制御する関連オプションが追加されました。EMは、アンケートに登場する順に関連式を処理します。式が真(または式がない - 古い形式のアンケート向け)の場合、質問が表示されます。関連が偽の場合、質問は非表示になり、その値はデータベースでNULLになります。グループに関連する質問がない場合、グループ全体がスキップされます。

さらに、式に含まれる変数のいずれかの関連が偽の場合、式は常に偽と評価されます。これにより関連の入れ子が可能になり、各々の質問に対して非常に長い関連式を書く必要がなくなります。

たとえば、5つの質問Q1〜Q5があり、Q1が答えられたらQ2、Q2に答えられたらQ3などを表示したいとします。関連式は次のようになります。

質問コード 関連 質問
Q1 1 名前は何ですか。
Q2 Q1 {Q1}さん、何歳ですか。
Q3 Q2 {Q2}歳なのですね。結婚していますか。
Q4 Q3 == "Y" {Q1}さん、結婚して何年になりますか。
Q5 Q4 {Q1}さん、子供は何人いますか。

関連性の計算はJavaScriptでも機能しますので、上記のすべての質問を1ページに置くことができ、期待どおりに動作します。実際、EMは、アンケート、グループ、一画面での一斉質問フォーマットの仕組みを完全に置き換えています。今では、まったく同じナビゲーションエンジンを使用しているので、アンケートスタイルに関係なく同じように動作します。

同じページにいる限り、入力した回答データは隠れていますが保持されています。したがって、情報を入力たあと、出現条件を満たさなくなるようなオプションを選択し、再び出現条件を満たすような選択をすると、回答は引き続き利用可能になります。ただし、別のページに移動すると、データセットの整合性を保つため、出現条件を満たさないすべての回答は失われます。

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

式マネージャーはグループレベルの出現条件もサポートしています。これにより、ループ(繰り返し)の実装が容易になります。最大10個の事柄(たとえば、製品や家庭内の人物など)に関する情報を収集するため、まずその数を質問するとします(例えば、家族の人数を聞いたり、リストの中からどの製品が好みなのかを選んでもらったりして)。後から繰り返し聞くべき回数が分かったら、10個用意したグループごとに{count>=1}、{count>=2}、... {count>=10}といった形で、グループレベルの出現条件を設定することができます。それぞれのグループ内では、質問レベルの条件付きロジック(例:回答者の性別や年齢別の質問)を作成することができます。質問とグループレベルの出現条件の式は、表示すべきかを決定するためにAND演算されます。

カスタマイズ/パイプ

中括弧内のものはすべて式として扱われるようになりました(後述する例外が1つあります)。式はすべてのLimeReplacementFields、すべての変数(いくつかのエイリアスを介して)、すべての一般的な演算子(数学、論理、比較)、数多くの関数(クライアント側でも動的に機能する)にアクセスします。

これらの式を使用すると、次のようなことができます。

  1. 先行する質問への回答に基づいて回答者に条件付きでメッセージを表示する
  2. 評価を作成し、その結果に基づいて評価結果を表示する(条件付きで分岐するまたはメッセージを表示する)(評価モジュール自体は使用しない)
  3. 質問、回答、およびレポート内の動詞、名詞を変化させる
  4. アンケートの最後で、"回答を表示する"ページの前に回答の要約を表示する

式と呼ばれる新しい質問タイプがあります。これは、表示されている値をデータベースに格納することを除き、テキスト表示タイプの質問と似ています。したがって、式の質問テキストに評価計算が含まれている場合、パブリックまたはプライベート統計情報内に表示できる変数の値がデータベースに格納されます。

これにより、データベース内に評価スコアを格納したいというニーズが解決します。

構文

中カッコ内に含まれるものはすべて式と見なされます(ただし、先頭または末尾に空白がないことが必要です。これは、式マネージャーが埋め込みJavaScriptを処理しないようにするためです)。

開く括弧の後、閉じる括弧の前に空白がない限り、式は複数の行にまたがっても構いません。特に次のような入れ子のif()構文が見やすくなります。

{if(is_empty(PFTotals),
 '',
 if(PFTotals >= -5 && PFTotals <= -4,
   'Very Soft',
   if(PFTotals >= -3 && PFTotals <= -2,
     'Soft',
     if(PFTotals == -1,
       'Somewhat Soft',
       if(PFTotals == 0,
         'Moderate',
         if(PFTotals == 1,
           'Somewhat Hard',
           if(PFTotals >= 2 && PFTotals <= 3,
             'Hard',
             if(PFTotals >= 4 && PFTotals <= 5,
               'Very Hard',
               ''
             )
           )
         )
       )
     )
   )
 )
)}
式マネージャーは次の構文をサポートしています。
  • すべての標準的な数学演算子 (例: +,-,*,/,!)
  • すべての標準的な比較演算子(例: <,<=,==,!=,>,>=, およびこれらと同等のもの: lt,le,eq,ne,gt,ge)
  • 括弧(式のグルーピング)
  • 条件演算子(例: &&,||, およびこれらと同等のもの: and,or)
  • シングルクォートやダブルクォートで囲まれた文字列(それぞれが他のクォートタイプの文字列を埋め込むことができます)
  • コンマ演算子(式のリストを持つことができ、最終結果を返すことができます)
  • 代入演算子(=)
  • 定義済みの変数(質問、質問属性、回答を参照するため) - 例: すべてのSGQAコード
  • 定義済みの関数(既に70以上ありますが、簡単に追加できます)

演算子

EM構文は、通常の演算子の優先順位に従います。

レベル 演算子 説明
1 () グループ化または関数呼び出しのための括弧
2 ! - + 単項演算子: 否定、正負
3 * / 乗算、除算
4 + - 加算、減算
5 < <= > >= lt le gt ge 比較演算子
6 == != eq ne 同等比較
7 and 論理積 AND
8 or 論理和 OR
9 = 代入演算子
10 , コンマ演算子

プラス演算子に関する注意(+)

JavaScriptとPHPの間の一貫性を保つために、プラス演算子(+)は両方のオペランドが数値の場合は加算を行いますが、両方の部分が数値以外の文字列の場合は連結します。しかし、意図をもっとはっきりさせるため、連結関数join()を使うことをお勧めします。

数と文字列の型の不一致、および文字列としての強制比較に関する注意

値を不等号や等号で比較する場合は、値の型の不一致に注意してください。ユーザーが入力した値や選択した回答コードが明確に数値であれば、数値として使用されます。 いずれかの値が"で囲まれている場合: 強制的にテキストとして比較します。数値として比較したい場合は"で囲んではいけません。

たとえば、Q0.NAOKが値として9をもつ数値型質問である場合、Q0.NAOK > "50"はtrueです。

整数値を確実に比較するには、intval(Q0.NAOK) > 50を使用します。Q0.NAOKが数値でない(空または文字列)場合は、intval(Q0.NAOK) === 0となります。文字列値を比較する("A" < "B")場合は、直接strcmpを使用します。strcmp(Q0.NAOK,"B")またはstrcmp(Q0.NAOK,"A5")

代入演算子(=)を使用する際の注意

代入演算子は、予期せぬ副作用を引き起こす可能性があるため、絶対に必要でない限り、使用しないでください。たとえば、先行する回答の値を変更した場合、その質問と現在の質問との間のカスケードされた出現条件と検証ロジックは再計算されないため、内部的に一貫性のないデータになりえます(たとえば、NULLであるべきものに回答が残る、回答があるべきなのにスキップされる、など)。一般に、変数に値を割り当てる場合は、式の質問タイプを作成し、その値を設定するための式を使用する必要があります。しかし、本当に必要なことがまれにあるため、この演算子が用意されています。

この演算子について注意を促すため、構文式の中では赤いフォントで表示されています("=="と混同しないようにするため)。

代入演算子を使う

代入を使用する主な理由は次のとおりです。

  • 式を使った既定値を設定できない質問の既定値を設定する必要がある(ユーザーインターフェイスでは回答オプションの1つを選択できるが、式を入力することができないリスト、ラジオなど)。ただし、LimeSurveyは式がその質問に対する許容可能な回答を生成できるかどうかを検証できないため、注意して使用してください。
  • 後続の回答に基づいて先行する質問への回答を強制的に変更する必要がある
  • など...

この目的のために、式マネージャーシステムを使用することができます。

  つまり、ページ内の値を更新するのではなく、ユーザーがページを移動したり保存したりしたときだけ演算が行われます。


  式質問タイプをこの目的に使用しない場合、現在のページのロジックが完了した後にのみassigmentdが実行されます。常に式質問を使用することが推奨されます。


例:

  • 質問への回答を小文字にする: {QCODE=strtolower(QCODE.NAOK)}
  • アンケート開始時に配列質問タイプに対する既定の回答を設定する: {Q1_SQ1=((is_empty(Q1_SQ1.NAOK),"A99",Q1_SQ1.NAOK)}
  • アンケート開始時に配列テキストの質問タイプに対する既定の回答を設定する: {Q1_SQY1_SQX1 = ((is_empty(Q1_SQY1_SQX1.NAOK),"Inserted answer", Q1_SQY1_SQX1.NAOK)}
  • 条件付きの回答を設定する: {QCODE=if(YesNo="Y","A1","")}

XSS セキュリティ

XSSを有効にすると、式マネージャーシステムの一部が使用できなくなります。

  • 式の中でHTMLタグを開き、別の式で閉じる
  • URLに複雑な式を使用する

例と解決策

  • {if( 1 ,"<strong>","")}information{if( 1 ,"</strong>","")}はXSSでは正常に動作しないため、次のようにします。{if(1,"<strong>information</strong>","information")}
  • <a href="/script.php?value={if(QCODE == "Y","yes","no")}">next</a>は、ここでは式の質問を使います。なぜなら、完全な質問コードが使用できるからです。<a href="/script.php?value={EQUATION.NAOK}">next</a>

変数へのアクセス

式マネージャーでは、必要な変数に読み取り専用でアクセスできます。下位互換性を保つため、次のものにアクセスすることができます。

  • TOKEN:xxx - トークンの属性値(例: TOKEN:FIRSTNAME、TOKEN:ATTRIBUTE_5)(匿名でないアンケート向け)
  • INSERTANS:SGQA - 回答として表示する値(例: "はい")。式マネージャーでは、{QCODE.shown}と同じです。
  • テンプレート内で使われるすべての{XXX}
  • 質問テキストでは、{QID}を質問IDで置き換え、{SGQ}を質問のSGQAで置き換えることができます。

さらに、式マネージャーでは、質問コード(データベース内の質問テーブルの'タイトル'列)で変数を参照できます。これは、データをSPSS、R、またはSASにエクスポートするときに使用される変数ラベルでもあります。例えば、名前、年齢、性別について質問がある場合、12345X13X22、12345X13X23、12345X13X24といった形ではなく、nameagegenderといった形で変数を呼び出すことができます。これにより、式が読みやすく、ロジックが検証しやすくなり、また、グループや質問の番号を把握することなく質問をシャッフルすることが可能になります。

重要: 先行するページや質問で発生する変数を参照することもできます。

さらに、式マネージャーを使用すると、多くの質問プロパティにアクセスできます。


構文 意味 例の結果
Qcode Qcode.codeの別名 {implode(',',name,gender)} 'Tom','M'
Qcode.code 出現条件を満たす場合に質問に対して選択された回答コード(出現条件を満たさない場合は空白)、またはコード化された質問でない場合のテキスト値 {implode(',',name.code,gender.code)} 'Tom','M'
Qcode.NAOK Qcodeと同じ - NAOKの議論を参照 {gender.NAOK} 'M'
Qcode.value 出現条件を満たす場合の質問の評価値(出現条件を満たさない場合は空白)、またはコード化された質問でない場合のテキスト値 {gender.value} '1'
Qcode.valueNAOK Qcode.valueと同じ - NAOKについての議論を参照 {gender.valueNAOK} '1'
Qcode.shown 質問で表示される値 {implode(',',name.shown,gender.shown)} 'Tom','Male'
Qcode.question 質問のテキスト {gender.question} 'What is your gender?'
Qcode.mandatory 質問への回答が必須かどうか(Y/N) {gender.mandatory} 'N'
Qcode.qid 内部の質問番号(連番ではない) {gender.qid} 337
Qcode.type 質問タイプ {gender.type} 'G'
Qcode.jsName このページで宣言されているかどうかにかかわらず、質問の正しいjavascript名 {gender.jsName} 'java1827X3X337'
Qcode.gid 内部のグループ番号(連番ではない) {gender.gid} 3
Qcode.qseq 0から始まる質問の連番 {gender.qseq} 5
Qcode.gseq 0から始まるグループの連番 {gender.gseq} 1
Qcode.relevanceStatus その時点で質問が表示条件を満たすかどうか(0/1) {gender.relevanceStatus} 1
Qcode.relevance 質問レベルの出現条件の式 {gender.relevance} '!is_empty(name)'
Qcode.grelevance グループレベルの出現条件の式 {gender.grelevance} 'num_children >= 5'
Qcode.sgqa 質問に対応するSGQA値 {gender.sgqa} '1827X3X337'

HTMLエディターの問題

  この問題は2.05ビルド140803以降で修正されています。


HTMLエディターを使用すると、一部の文字がHTML実体に置き換えられます。

  • & → &amp;
  • < → &lt;
  • > → &gt;

HTMLエディターを使用する場合は、次のものを使用する必要があります。

  • & に対しては and
  • < に対してはlt
  • <= に対してはle
  • > に対してはgt
  • >= に対してはge

Qcode変数の命名

Qcodeを構成する方法(およびいくつかのプロパティにアクセスする方法)の質問タイプ別の詳細は次のとおりです。一般に、Qcodeは次のように構成されます。

 QuestionCode . '_' . SubQuestionID . '_' . ScaleId

コメントおよびその他の質問コードは、それぞれQuestionCode_commentとQuestionCode_otherです。

タイプ 説明 コード サブ質問 回答の選択肢 尺度 回答コード 回答の表示 出現条件
5 5点選択ラジオボタン Q1 1-5 {Q1} {Q1.shown} {Q1==3}
B 配列(10点選択)ラジオボタン Q2 L1-L6 1-10 {Q2_L2} {Q2_L2.shown} {Q2_L2==7}
A 配列(5点選択)ラジオボタン Q3 1-5 1-5 {Q3_1} {Q3_1.shown} {Q3_1>=3}
1 配列(フレキシブルラベル)二元スケール Q4 sq1-sq5 0:a1-a3 1:b1-b3 {Q4_sq1_0} {Q4_sq1_1.shown} {Q4_sq1_1=='b2'}
H 配列(フレキシブル) - 列形式 Q5 1-5 s,m,t {Q5_1} {Q5_1.shown} {Q5_1=='s'}
F 配列(フレキシブル) - 行形式 Q6 F1-F5 1-5 {Q6_F3} {Q6_F3.shown} {Q6_F3==4}
E 配列(増加/同じ/減少)ラジオボタン Q7 1-7 I,S,D {Q7_4} {Q7_4.shown} {Q7_4=='D'}
: 配列(複数フレキシブル)1から10 Q8 ls1,todo,ls2 min,max,avg {Q8_ls1_max} {Q8_ls2_avg.shown} {Q8_ls2_min==7}
; 配列(複数フレキシブル)テキスト Q9 hp,st,sw 1st,2nd,3rd {Q9_hp_3rd} {Q9_hp_3rd.shown} {Q9_hp_3rd=='Peter'}
C 配列(はい/わからない/いいえ)ラジオボタン Q10 1-5 Y,N,U {Q10_1} {Q10_1.shown} {Q10_3=='Y'}
X テキスト質問 Q11 {Q11.shown}
D 日付 Q12 {Q12} {Q12.shown}
* Q13 {Q13} {Q13.shown} {Q13>5}
~124~ ファイルアップロード(アップロードされたファイルの数) Q14 {Q14} {Q14>0}
G 性別ドロップダウンリスト Q15 M,F {Q15} {Q15.shown} {Q15=='M'}
U 非常に長い自由文 Q16 {Q16} {Q16.shown} {strlen(Q16)>100}
I 言語質問 Q17 {Q17} {Q17.shown} {Q17=='en'}
! リスト - ドロップダウン Q18 1-5 {Q18} {Q18.shown} {Q18==3}
L リスト ドロップダウン/ラジオボタン Q19 A-Z {Q19} {Q19.shown} {Q19=='X'}
O コメント付きリスト ドロップダウン/ラジオボタン+テキスト Q20 A-F {Q20},{Q20comment} {Q20.shown} {Q20=='B'}
T 長い自由文 Q21 {Q21} {Q21.shown} {strstr(Q21,'hello')>0}
M 複数選択チェックボックス Q22 A-F, other {Q22_E}, {Q22_other} {Q22_E.shown}, {Q22_other.shown} {Q22_E=='Y'}
P コメント付き複数選択 チェックボックス+テキスト Q23 A-F {Q23_D}, {Q23_Dcomment} {Q23_D.shown} {!is_empty(Q23)}
K 複数数値質問 Q24 self,mom,dad {Q24_self} {Q24_self.shown} {Q24_self>30}
Q 複数テキスト Q25 A-F {Q25_B} {Q25_B.shown} {substr(Q25_B,1,1)=='Q'}
N 数値質問タイプ Q26 {Q26} {Q26.shown} {Q26 > 30}
R 順位 Q27 1-4 {Q27_1} {Q27_1.shown} {Q27_1==3}
S 短い自由文 Q28 {Q28} {Q28.shown} {Q28=='mine'}
Y はい/いいえラジオボタン Q29 {Q29} {Q29.shown} {Q29=='Y'}

予約変数 this、self、that

回答されたサブ質問の数を数えたり、スコアを合計するなど、質問の全体を評価したい場合がよくあります。また、質問の特定の行や列(行や列の合計を取得してデータベースに格納するなど)を処理したい場合もあります。以下の予約変数により、そのプロセスを簡単に実現できます。

'this'変数は、"完全な質問の検証式"と"サブ質問の検証式"の高度な質問オプション内で排他的に使用されます。該当の質問内の各セルの変数名に展開されます。したがって、各エントリが3より大きいかどうかを確認する場合は、"サブ質問の検証式"を(this > 3)に設定します。

'self'と 'that'変数はより強力で、式を処理する前に展開されるマクロとして機能します。構文は次のとおりです。

  • self
  • self.suffix
  • self.sub-selector
  • self.sub-selector.suffix

suffixは、通常のqcode接尾辞のいずれかです(例: NAOK、value、shown)。

sub-selectorは次のいずれかです。

  • comments - コメントのサブ質問(例えば、コメント付き複数選択、コメント付きリスト)
  • nocomments - コメントでないサブ質問
  • sq_X - Xは、行または列の識別子。パターンXと一致するサブ質問のみが選択されます。検索は完全なコード識別子で行われ、sq_Xは、サブ質問nX、X、Xnとマッチし選択されることに注意してください(例えば、sq_1を使用する場合はサブ質問a1、1a、1、11または001が含まれます)。二元スケール質問タイプのサブ質問コードはQCODE_SQCODE_1、QCODE_SQCODE_1であり、順位付け質問タイプのサブ質問コードはQCODE_1、QCODE_2、....となります。

例:

  • 質問に対して何らかの回答があったか?  {count(self.NAOK)>0}
  • この質問の評価点数は?  {sum(self.value)}

行と列の合計を取得することもできます。列A-Eと行1-5の数字の配列があるとします。

  • 総合計は? {sum(self.NAOK)}
  • 列Bの合計は? {sum(self.sq_B.NAOK)}
  • 行3の合計は? {sum(self.sq_3.NAOK)}

'that'は'self'に似ていますが、他の質問を参照することができます。構文は次のとおりです。

  • that.qname
  • that.qname.suffix
  • that.qname.sub-selector
  • that.qname.sub-selector.suffix

qnameは、サブ質問拡張がない質問の名前です。質問 'q1'を作成したら、それがqnameとなります。

例:

  • 質問q1に対して何らかの回答があったか? {count(that.q1.NAOK)>0}
  • q2の評価点数は?  {sum(that.q2.NAOK)}
  • q3の総合計は? {sum(that.q3.NAOK)}
  • q4の列Cの合計は?  {sum(that.q4.sq_C.NAOK)}
  • q4の行2の合計は? {sum(that.q4.sq_2.NAOK)}

'self'と'that'変数は、出現条件、検証、カスタマイズの式で使用できます。

注意すべき点は、ロジックファイルの表示機能を使用すると、'self'と'that'を展開した値が表示されることです。これにより、生成される実際の式が表示され、その結果、変数が存在することを検証できるようになります。かなり長い式になるかもしれないので、混乱しているように見えるかもしれません。しかし、質問を編集すると、'self'や'that'を使っている元の式が表示されます。

また、(a)式に使用される各変数を明示的に命名する場合、または(b)サブ質問を持たない変数を使用する場合(例:単一回答の質問)、これらの変数を使用しないでください。そのような場合に、変数に'that'をつけてプレフィックスをつけると、予期しない結果が出る危険があります。

NAOKの利用

NAOK --> "Not Applicable"(該当なし、NA)は問題ない(OK)

NAOKは、すべてまたは一部の変数が出現条件を満たさないということです。"Not Applicable"(該当なし、NA)は問題ない(OK)。

式の中に、質問からの変数を導入するとき、この質問(またはサブ質問)が条件によって隠されている場合、式全体を無効にします。

例: count(Q1_SQ1,Q1_SQ2,Q1_SQ3,Q1_SQ4) は、Q1のサブ質問の一つがフィルターされている場合、常に空文字となります。このような質問で、チェックされたサブ質問の数をカウントするには、count(Q1_SQ1.NAOK,Q1_SQ2.NAOK,Q1_SQ3.NAOK,Q1_SQ4.NAOK)とします。サブ質問が隠されている場合、式マネージャーは空文字を返します。

NAOKがない場合、1つの質問または1つのサブ質問が非表示になっている場合、式マネージャーは常に空の文字列を返します(falseを返すのと同じです)。

.shownは常にNAOKの仕組み(非表示の時は空文字)を使っていますが、回答のコードが必要な場合は、質問コードの後に.NAOKを付加するとよいでしょう。それが必要で、内容を理解している場合は別です。

その他の例と情報は、カスケードされた条件の上書きを参照してください。

関数へのアクセス

式マネージャーでは、以下に示すように、数学関数、文字列関数、およびユーザー定義関数が利用できます。これらの関数にはPHPとJavaScriptに同等のものがあるので、サーバ側(PHP)とクライアント側(JavaScript)で同じように動作します。新しい機能を追加するのは簡単です。

実装済み関数

現在、以下の関数が利用可能です。

関数 意味 構文
abs 絶対値 number abs(数値)
acos アークコサイン number acos(数値)
addslashes 文字列をスラッシュで引用 string addslashes(文字列)
asin アークサイン number asin(数値)
atan アークタンジェント number atan(数値)
atan2 2変数のアークタンジェント number atan2(数値, 数値)
ceil 切り上げ number ceil(数値)
checkdate グレゴリオ暦で有効な日付であれば真(1)を返す bool checkdate(月,日,年)
convert_value 変換元リストにある数値を対応する変換先リストの数値に変換する number convert_value(変換する数値, 一致フラグ, 変換元リスト, 変換先リスト)
cos コサイン number cos(数値)
count リスト内で回答された(空白でない)質問の数 number count(arg1, arg2, ..., argN)
countif 回答された質問のうち、比較値と等しいリスト内の回答の数 number countif(比較値, arg1, arg2, ... argN)
countifop 回答された質問のうち、条件を満たすリスト内の回答の数(回答 演算子 比較値) number countifop(演算子, 比較値, arg1, arg2, ... argN)
date 指定した、もしくは現在のローカルの日付/時刻を書式化する string date(日付書式[, 指定時刻=time()])
exp eの累乗を計算する number exp(数値)
fixnum 必要に応じてカンマで区切られた数字を表示する string fixnum(数値)
floor 切り捨て number floor(数値)
gmdate 指定した、もしくは現在のGMTの日付/時刻を書式化する string gmdate(日付書式[, 指定時刻=time()])
html_entity_decode HTML エンティティを適切な文字に変換する (always uses ENT_QUOTES and UTF-8) string html_entity_decode(文字列)
htmlentities Convert all applicable characters to HTML entities(常にENT_QUOTESとUTF-8を使用) string htmlentities(string)
expr_mgr_htmlspecialchars 特殊文字を HTML エンティティに変換す(常にENT_QUOTESとUTF-8を使用) string htmlspecialchars(文字列)
expr_mgr_htmlspecialchars_decode 特殊な HTML エンティティを文字に戻す(常にENT_QUOTESとUTF-8を使用) string htmlspecialchars_decode(文字列)
idate 指定した、もしくは現在のローカルな時刻/日付を整数として整形する string idate(文字列[, 指定時刻=time()])
if Excelスタイルのif(条件,trueの時の結果,falseの時の結果) if(条件,trueの時の結果,falseの時の結果)
implode 配列要素を文字列により連結するg string implode(区切り文字,arg1,arg2,...,argN)
intval 変数の整数としての値を取得する int intval(数値 [, 基数=10])
is_empty 変数が空であるかどうかを検査する bool is_empty(変数)
is_float 変数の型が float かどうか調べる bool is_float(変数)
is_int 変数が整数型かどうかを検査する bool is_int(変数)
is_nan 値が数値でないかどうかを判定する bool is_nan(変数)
is_null 変数が NULL かどうか調べる bool is_null(変数)
is_numeric 変数が数字または数値形式の文字列であるかを調べる bool is_numeric(変数)
is_string 変数の型が文字列かどうかを調べる bool is_string(変数)
join (2.0 build 130129から追加) 要素を新しい文字列として結合する join(arg1, arg2, ... argN)
list 空白でない値をコンマ区切りリストで返す string list(arg1, arg2, ... argN)
log 自然対数(底が指定されている場合は底に対する対数) number log(数値,底=e)
ltrim 文字列の最初から空白 (もしくはその他の文字) を取り除く string ltrim(文字列 [, 削除する文字のリスト])
max 最大値を返す number max(arg1, arg2, ... argN)
min number min(arg1, arg2, ... argN)
mktime 日付を Unix のタイムスタンプとして取得する(引数は省略可) number mktime([時 [, 分 [, 秒 [, 月 [, 日 [, 年 ]]]]]])
モジュロ関数 モジュロ関数はまだサポートされていません。代わりにfloor()関数を使用します。 floor(x/y)==(x/y)
nl2br 改行文字の前にHTMLの改行タグを挿入する string nl2br(文字列)
number_format 数字を千位毎にグループ化してフォーマットする string number_format(数値)
pi 円周率 number pi()
pow 指数表現 number pow(基数, 指数)
quoted_printable_decode quoted-printable 文字列を 8 ビット文字列に変換する string quoted_printable_decode(文字列)
quoted_printable_encode 8 ビット文字列を quoted-printable 文字列に変換する string quoted_printable_encode(文字列)
quotemeta メタ文字をクォートする string quotemeta(文字列)
rand 乱数を生成する( int rand() OR int rand(最小値, 最大値)
regexMatch 文字列を正規表現で比較する bool regexMatch(パターン,文字列)
round 数値を任意の精度に丸める number round(値 [, 丸める桁数])
rtrim 文字列の最後から空白(またはその他の文字)を取り除く string rtrim(文字列 [, 削除する文字のリスト])
sin サイン number sin(数値)
sprintf フォーマットされた文字列を返す string sprintf(フォーマット, arg1, arg2, ... argN)
sqrt 平方根 number sqrt(数値)
stddev 数値のリストのサンプル標準偏差を計算する number stddev(arg1, arg2, ... argN)
str_pad 文字列を固定長になるまで他の文字列で埋める string str_pad(入力文字列, 文字列の長さ [, 埋める文字列])
str_repeat 文字列を反復する string str_repeat(入力文字列, 繰り返し回数)
str_replace 検索文字列に一致したすべての文字列を置換する string str_replace(検索文字列, 置き換える値, 対象の文字列)
strcasecmp Binary safe case-insensitive string comparison int strcasecmp(str1, str2)
strcmp バイナリセーフな文字列比較を行う int strcmp(文字列1, 文字列2)
strip_tags 文字列から HTML および PHP タグを取り除く string strip_tags(文字列, 取り除かないタグ)
stripos 大文字小文字を区別せずに文字列が最初に現れる位置を探す(0から始まり、現れなければfalse) int stripos(対象文字列, 検索文字列 [, 検索開始位置=0])
stripslashes クォートされた文字列のクォート部分を取り除く string stripslashes(文字列)
stristr 大文字小文字を区別しないstrstr string stristr(対象文字列, 検索文字列 [, before_needle=false])
strlen 文字列の長さを得る int strlen(文字列)
strpos 文字列内の部分文字列が最初に現れる場所を見つける(0から始まり、現れなければfalse) int strpos(対象文字列, 検索文字列 [ 検索開始位置=0])
strrev 文字列を逆順にする string strrev(文字列)
strstr 文字列が最初に現れる位置を見つける string strstr(対象文字列, 検索文字列[, before_needle=false])
strtolower 文字列を小文字にする string strtolower(文字列)
strtotime 英文形式の日付をUnixタイムスタンプに変換する int strtotime(文字列)
strtoupper 文字列を大文字にする string strtoupper(文字列)
substr unicode文字列の一部分を返す string substr(対象文字列, 開始位置 [, 長さ])
sum 配列中の値の合計 number sum(arg1, arg2, ... argN)
sumifop 回答された質問のうち、条件を満たすリスト内の回答の合計(回答 演算子 比較値) number sumifop(演算子, 値, arg1, arg2, ... argN)
tan タンジェント number tan(数値)
time 現在の Unix タイムスタンプを返す number time()
trim 文字列の先頭および最後から空白(またはその他の文字)を取り除く string trim(文字列 [, 削除する文字のリスト])
ucwords 文字列の各単語の最初の文字を大文字にする string ucwords(文字列)
unique 空白以外の回答のすべてが一意である場合にtrueを返す boolean unique(arg1, ..., argN)

計画中・検討中の関数

計画中(または検討中)でまだ実装されていない関数は、以下の通りです。このうちいくつかは別のアンケートツールとの下位互換性のためのものです。

構文 意味 コメント
e() eの値を返す
formatDate(X,PAT) Javaデータ形式パターンPATに従ってフォーマットされた日付Xの文字列値を返す
formatNumber(X,PAT) Java数値書式パターンPATに従ってフォーマットされた数値Xの文字列を返す
getAnsOption(X) コアプラグインExpressionAnswerOptions
getAnsOption(X,Y) コアプラグインExpressionAnswerOptions
getRelevance(X) 質問Xの出現条件の式を返す
getStartTime() アンケートが開始されたシステム時刻の日付を返す
getType(X) データタイプの名前を返す(例: isNA()なら*NA*)
gotoFirst() 出現条件を満たす最初の質問にジャンプする(これはシステムの通常の流れに反する)
gotoNext() 出現条件を満たす次の質問にジャンプする(これはシステムの通常の流れに反する)
gotoPrevious() 出現条件を満たすひとつ前の質問にジャンプする(これはシステムの通常の流れに反する)
isAsked(X) 回答が*NA*、*INVALID*、*UNASKED*のいずれでもなければtrueを返す
isInvalid(X) 回答が*INVALID*の場合trueを返す
isNA(X) 回答が*NA*の場合trueを返す
isNotUnderstood(X) 回答が*HUH*の場合trueを返す
isRefused(X) 回答が*REFUSED*の場合trueを返す
isSpecial(X) 回答が*UNASKED*、*NA*、*REFUSED*、*INVALID*、*UNKNOWN*、*HUH*のいずれかの場合trueを返す
isUnknown(X) 回答が*UNKNOWN*の場合trueを返す
jumpTo(X) 指定した名前の質問を含むグループにジャンプする(これはシステムの通常の流れに反する)
jumpToFirstUnasked() 回答済みの質問を飛び越えて最初の未回答の質問にジャンプする (これはシステムの通常の流れに反する)
lastIndexOf(X,Y) 文字列Xに文字列Yが最後に現れる位置(0始まり)を返す(XにYが含まれない場合は-1を返す)
list(X,...) 正の値のリスト(値はコンマで区切り、最後の2つの間は"and"で区切る)
mean(X,...) リストの値の平均を返す
numAnsOptions(X) 質問Xの回答オプションの数を返す
orlist(X,...) 正の値のリスト(値はコンマで区切り、最後の2つの間は"or"で区切る)
parseDate(X,PAT) 文字列XをJavaの日付書式パターンPATで解析した日付値を返す
parseNumber(X,PAT) 文字列XをJavaの数値書式パターンPATで解析した数値を返す
showAllResponsesExcept( questionList,attributeList,attributeTitleList) questionListはパイプで区切られた質問IDのリスト、attributeListはパイプで区切られた属性のリスト(question#、title、text、typeなど、表示したいもの)、attributeTitleListはパイプで区切られたテーブルヘッダーで、レポートを国際化する
showTheseResponses( questionList,attributeList,attributeTitleList) questionListはパイプで区切られた質問IDのリスト、attributeListはパイプで区切られた属性のリスト(question#、title、text、typeなど、表示したいもの)、attributeTitleListはパイプで区切られたテーブルヘッダーで、レポートを国際化する

式マネージャーとローカル変数

ページのJavaScriptを適切に構築するため、式マネージャーはページに設定されている変数とJavaScript IDが何であるかを知る必要があります(例: document.getElementById(x))。また、他のページにどの変数が設定されているかも知る必要があります(これにより、必要な<input type='hidden' value='x'>フィールドが存在しているか確認できます)。

カスケードされた条件

いずれかの変数がfalseである場合、式全体はfalseになります。たとえば、次の表では、N/Aは変数の1つがtrueでないことを意味します。

演算子 説明 a b 結果
+(単項) +a N/A false
! !a N/A false
== (またはeq) a == b N/A 5 false
== (またはeq) a == b N/A 0 false
== (またはeq) a == b N/A N/A false
!= (またはne) a != b N/A 5 false
!= (またはne) a != b N/A N/A false
!= (またはne) a != b N/A 0 false
> (またはgt) a > b N/A 5 false
>= (またはge) a >= b N/A 5 false
< (またはlt) a < b N/A 5 false
<= (またはle) a <= b N/A 5 false
and a and b N/A 5 false
and a and b N/A N/A false
or a or b N/A N/A false
or a or b N/A 5 false
+ a + b N/A 5 false
* a * b N/A 5 false
/ a / b 5 N/A false
() (a) N/A false
(exp) (a && b) N/A 5 false
(exp) op (exp) (b + b) > (a && b) N/A 5 false
関数 sum(a,b,b) N/A 5 false
関数 max(a,b) N/A 5 false
関数 min(a,b) N/A 5 false
関数 implode(', ',a,b,a,b) N/A 5 false
関数 if(a,a,b) N/A 5 false
関数 is_empty(a) N/A false
関数 is_empty(a) 0 (or blank) true
関数 !is_empty(a) N/A false

カスケードされた条件の上書き

出現条件を満たした回答の合計を表示したいとします。式 {sum(q1,q2,q3,...,qN)}を使おうとするでしょう。しかし、これは内部的にLEMif(LEManyNA('q1','q2','q3',...,'qN'),,sum(LEMval('q1'),LEMval('q2'),LEMval('q3'),...,LEMval('qN')))に変換されます。これにより、値q1〜qNのいずれかが出現条件を満たさない場合、式は常にfalseを返します。この場合、sum()はすべての質問が出現して回答されない限り0となります。

この問題を回避するために、各変数には".NAOK"という接尾辞(「Not Applicable」はOK)を追加することができます。このような場合、次のような現象が発生します。変数q1.NAOKがあるとします。

  1. q1はLEManyNA()節には追加されません
  2. LEMval('q1')は回答が出現条件を満たしているかを確認し、そうでない場合は''を返します(出現条件を満たさない回答は無視されますが、式全体を無効にしません)。

したがって、合計を求める方法は、次の式となります。sum(q1.NAOK,q2.NAOK,q3.NAOK,...,qN.NAOK)

.NAOK接尾辞を使用することで、いくつかの経路を経た後、共通の経路に収束するアンケートを設計することができます。例えば、回答者が正常な範囲外となるような回答をしたとします。アンケート作成者は、有効な結果を得られない可能性があることを回答者に警告し、アンケートを継続するかどうかを尋ねることができます。彼らが「はい」と答えた場合、残りの質問が表示されます。"残りの質問"の条件は、最初に正常な範囲内で回答があったかどうか、または正常な範囲外で回答した場合にのみ出現する質問に「はい」と回答したかどうかをチェックします。

式マネージャーはどのように条件付きカスタマイズを実現するか?

ここでは、カスタマイズ(質問タイプ'expr'は式を意味します)の例を示します。

質問コード 出現条件 質問タイプ 質問
name 1 text お名前は?
age 1 text 年齢は?
badage !is_empty(age) expr {(age<16) or (age>80)}
agestop badage message {name}さん、失礼ですが、アンケート回答者として{if( (age<16),'若すぎます',if( (age>80),'高齢すぎます','中くらいの年齢です') ) }。
kids !badage yesno お子様はいますか?
parents 1 expr {!badage && kids=='Y'}
numKids parents text 何人のお子様がいますか?
kid1 parents && numKids >= 1 text 第一子の年齢は?
kid2 parents && numKids >= 2 text 第二子の年齢は?
kid3 parents && numKids >= 3 text 第三子の年齢は?
kid4 parents && numKids >= 4 text 第四子の年齢は?
kid5 parents && numKids >= 5 text 第五子の年齢は?
sumage 1 expr {sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK,kid5.NAOK)}
report parents yesno {name}さん、あなたの年齢は{age}歳、{numKids}名のお子様がいると回答しました。{min(numKids,5)}番目のお子様までの年齢の合計は、{sumage}です。

これらの質問はすべて1つのページ(たとえば同じグループ)に入れることができ、出現条件に合致する質問のみが表示されます。さらに、子供の年齢を入力すると、最後の質問のsum()式がページ上で動的に更新されます。

式マネージャーは、各式を名前付き<span>要素で囲むことでこの機能を提供します。値が変更されるたびに、その<span>要素に表示される式を再計算し、再表示します。そのようなカスタマイズされた式が同じページに数十、または数百もあっても、ページは一度の画面更新ですべて再表示されます。

LimeSurvey 1.91と式マネージャー機能の対照表

旧機能 新機能 コメント
条件 出現条件 非常に複雑な条件式を使用して、より広い範囲の変数にアクセスできます。
評価 どの評価スコアも式に再構成することができます。これにより、スコアがデータベースに書き込まれるとともに、現在のページでスコア値が動的に変化しても表示できます。
置換 式マネージャー コアエンジンは入力文字列を取得すると、中括弧内のすべてを式として扱います。したがって、すべての置換タイプを処理します。埋め込まれたJavaScriptの混乱を避けるために、式マネージャーでは、中括弧内に先頭または末尾の空白がない限り、中括弧間のコンテンツしか処理しません。たとえば{expr}は式ですが、{ expr}、{expr }、{ expr }は式ではありません。さらに、式マネージャーは文字列内のコンテンツを処理しません(たとえば、{list('hi','there {braces}')}は"hi there {braces}"となります)。また、エスケープされた中括弧も無視されます(例えば、\{this is not an expression\})。
検証 式マネージャー 現在の最小/最大の質問属性を使って、式マネージャーからそれらを処理する計画です。これにより、最小値/最大値は式そのものになります。

構文ハイライト

式の入力と検証を支援するために、EMでは以下のような構文強調表示機能を提供しています。

構文ハイライトの種類と意味

サンプル 意味 ツールチップ コメント
黄褐色の背景 サンプル 式全体 なし 式として認識される中括弧内のもの(先頭または末尾の空白がない)は、周囲のテキストと区別するのに役立つ黄褐色の背景で色分けされます。
太字赤色のテキスト サンプル エラー エラーに関する説明 未知の変数または関数のエラーの可能性があります。アンケートは完全に壊れている可能性がありますが、これは一般ユーザーには表示されません。
青色のテキスト サンプル 関数名 関数の意味と構文 関数名、または開く括弧が続くので関数と思われるものは、太字の青いテキストで表示されます。ツールチップには、その機能の意味と許容される構文が表示されます。
灰色のテキスト サンプル 文字列 なし シングルもしくはダブルクォートで囲まれた文字列が灰色のテキストとして表示されます。
水色のテキスト サンプル 同じページにセットされた変数 [名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト 現在の質問と同じページに設定されている変数は水色のテキストで表示され、javascriptで更新されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
緑色のテキスト サンプル 先行するページでセットされた変数 [名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト 先行するページに設定されている変数は太字の緑色のテキストで表示されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
太字桃色のテキスト サンプル 後続のページでセットされた変数一般的には、アンケート開始時は空で、インデックスや前への移動を使用した時に値が入ります。 [名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト 後続のページに設定されている変数は太字の桃色のテキストで表示されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
太字の黄褐色のテキスト サンプル LimeSurveyの置換値 LimeSurveyの置換文字列({TOKEN:xxx}、{PRIVACY_MESSAGE}など)は太字の黄褐色のテキストとして表示されます。
赤色のテキスト サンプル 代入演算子(=) 注意喚起メッセージ 代入演算子(=)を使用すると、演算子は赤色のテキストで表示されます。これは、aとbは等しいことを確認しようとしているとき、誤ってbの値をaに代入することを防ぐのに役立ちます。
通常の黒色のテキスト サンプル 句読点 なし 式の内の他の句読点はすべて、通常の黒文字で表示されます。
赤枠で囲まれたテキスト 赤い太線で囲まれたエラー 構文エラー エラーの説明 検出された構文エラーは、エラーを赤い枠線で囲んで表示されます。ツールチップにエラーが表示されます。例としては、括弧の不一致、未定義関数の使用、関数に渡す引数の数の誤り、構造化が不十分な式(変数間の演算子の欠落など)、読み取り専用変数に値を代入しようとする、変数でないものに値を代入しようとする、サポートされていない構文を使用するなどです。構文エラー検出システムは、複数のエラーがあっても式内の1つのエラーだけを報告することがあります。ただし、エラーが検出された場合は、少なくとも1つのエラーが表示されます。

参考記事

式マネージャーのサンプル

ユースケースとHowTo

ステップバイステップの例

式マネージャーの統計関数

開発者向け参考情報

ロードマップ/状況/ToDoリスト