Actions

ExpressionScript How-tos/ja: Difference between revisions

From LimeSurvey Manual

(Created page with "'Mr.'か'Mrs.'を使い分けるにはif()関数を使用します。")
No edit summary
 
(163 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<languages />
__TOC__
__TOC__




=はじめに=
=これまでの説明の概略=


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


LimeSurveyのマニュアルを理解しているならば、[[ExpressionScript - Presentation/ja#.E4.B8.BB.E3.81.AA.E5.AE.9A.E7.BE.A9|LimeSurvey特有の用語]]を理解していることになります。続いて、アンケートを強化する方法として、式と変数について説明しました。さらに、[[ExpressionScript - Presentation/ja#.E6.A7.8B.E6.96.87.E3.83.8F.E3.82.A4.E3.83.A9.E3.82.A4.E3.83.88|構文の強調表示]]の種類と意味を取り扱い、構文エラーを修正する方法を学びました。


==主な定義==
これらの基本的な概念が理解できたら、LimeSurvey内で式がどのように機能するか、例を使って見ていきましょう。




#'''式''': 中括弧で囲まれたもの
==構文強調表示==
#*開く中括弧の直後または閉じる中括弧の直前に空白がない
#*式の内容はEMが評価するため、数式、関数、複雑な文字列と日付処理を含めることができます。
#'''テーラリング''': "パイピング"とも呼ばれますが、これは条件付きでテキストを変更するプロセスです。
#*すべての'置換フィールド'、参加者データ、回答データにアクセスできます。
#*質問、回答、およびそのプロパティにも簡単にアクセスできます。
#'''出現条件'''式: 質問を表示するかを制御する新しい質問属性
#*出現条件式がある場合、その出現条件が真と評価された場合にのみ質問が表示されます。
#*内部では、すべての[[QS:Array_filter/ja|array_filter]]コマンドと[[QS:Array_filter_exclude/ja|array_filter_exclude]]コマンドがサブ質問レベルの出現条件になります。
#'''SGQA''':  LimeSurvey 1.91以前の変数の命名方法です。
#*アンケート(Survey)-グループ(Group)-質問(Question)-回答(Answer)の略です。
#*SGQA変数名は123X5X382X971のようなもので、サブ質問の接尾辞がつくことがあります。
#*これらの変数名は、基礎となるS/Q/G/Aデータベースコードに固有のものであるため、しばしば変更する必要があります。
#'''式'''質問タイプ: データベースに計算やレポートを保存する[[Question type - Equation/ja|新しい質問タイプ]]
#*これはテキストを表示する質問のようなものですが、"この質問をいつも隠す"の設定をしても、その内容はデータベースに保存されます。
#'''質問コード''': EMで使用することが望まれる変数
#*これは質問の目的を示すわかりやすい名前で、複雑なロジックを読みやすくします。
#*有効な質問コードとして数字で始まるものは使用できないので、質問コードを使用して質問の番号を付けるときは、単に「q1」または「q1a」または「g1q2」を使用してください。
#*これはSPSSまたはRにデータをエクスポートすると変数名になります。したがって、統計分析を行う場合は、固有の質問コードのみを作成する必要があります。




=構文ハイライト=
次のスクリーンショットは実際の表示例ですが、ツールチップの値は表示されません。ツールチップは、太字の色の上にマウスを置くたびに表示される便利なボックスです。


この構文強調表示によって、複雑なものであっても簡単に正しい式を作成することができます。LimeSurveyチームは、式ビルダーGUIの開発を計画していますが、すでに提供されている構文強調表示を使用すれば、タイプミスをすばやく特定し修正することができます。また、ツールチップを使って、式が正しいかを検証することもできます(目的の変数を選択したかを確認するなど)。


式の入力と検証を支援するために、EMでは以下のような構文強調表示機能を提供しています。
それぞれの例には、3つの列があります。
#Source - LimeSurveyの質問フィールドに入力する生のテキストです
#Pretty Print - 入力したものと同等ですが、構文が強調表示されています
#*この強調表示では、式は黄褐色の背景で表示されますが、中括弧で囲まれていません。
#*EMは再帰的な置換をサポートしているため、強調表示に中括弧を表示すると構文エラーが発生します
#Result - EMがソースを処理して生成した結果です
#*適切に置換できるものすべて
#*エラーのある式はインラインで表示され、構文が強調表示されます。 エラーは赤い線のボックスで囲まれます。




==構文ハイライトの種類と意味==
===適切な構文===




{|
適切な構文の例を以下に示します。
|色||サンプル||意味||ツールチップ||コメント
#: 現在のページでセットされているかに応じて既知の変数が色付きで表示されます。旧式のINSERTANS:xxxxは独自の色分けスタイルになります。
|-
#質問の属性: ドット表記により質問の属性にアクセスできます。
|黄褐色の背景||<span style='background:#eee8aa'>サンプル</span>||式全体||なし||式として認識される中括弧内のもの(先頭または末尾の空白がない)は、周囲のテキストと区別するのに役立つ黄褐色の背景で色分けされます。
#数学: 基本的な計算だけでなく、複雑な計算もサポートします。
|-
#テキスト処理: テキスト処理関数の例
|太字青色のテキスト||'''<span style='color:blue;background:#eee8aa'>サンプル</span>'''||関数名||関数の意味と構文||関数名、または開く括弧が続くので関数と思われるものは、太字の青いテキストで表示されます。ツールチップには、その機能の意味と許容される構文が表示されます。
#日付: 日付関連の関数の例
|-
#条件: if()の使い方。入れ子にすることも可能。
|灰色のテキスト||<span style='color:grey'>'サンプル'</span>||文字列||なし||シングルもしくはダブルクォートで囲まれた文字列が灰色のテキストとして表示されます。
#文言調整: 先行する質問の値に応じてレポートをカスタマイズできます。
|-
#文字列中のES処理: 文字列の一部を置換できます。この例では画像の名前を変えることができます。
|太字栗色のテキスト||'''<span style='color:maroon;background:#eee8aa'>サンプル</span>'''||同じページの後続の質問にセットされた変数||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト||同じページの後続の質問にセットされた変数は太字栗色のテキストで表示されます。この色付き表示は、質問の順序にかかわるエラーの可能性を作成者に警告するものですが、動的レポートを作成するページなど、こうした変数の使い方を必要とする場合があるので許容されています。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
#ESは次のような中括弧を処理しません: 中括弧がエスケープされている場合、式と中括弧の間に空白がある場合、ESは式を無視します。
|-
|太字水色のテキスト||'''<span style='color:#4C88BE;background:#eee8aa'>サンプル</span>'''||同じページの先行する質問にセットされた変数||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト||同じページの先行する質問にセットされた変数は太字水色のテキストで表示されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
|-
|太字緑色のテキスト||'''<span style='color:green;background:#eee8aa'>サンプル</span>'''||先行するページでセットされた変数||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト||先行するページでセットされた変数は太字緑色のテキストで表示されます。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
|-
|太字桃色のテキスト||'''<span style='color:#FF00FF;background:#eee8aa'>サンプル</span>'''||後続のページでセットされた変数||<nowiki>[</nowiki>名前またはSGQAコード]: 質問; 値; それぞれの値のコードが示された回答リスト||後続のページでセットされた変数は太字桃色のテキストで表示されます。変数が宣言される前に使用された場合のエラーです。ツールチップには、名前(INSERTANS:xxxを使用した場合)またはSGQAコード(新しい命名システムを使用した場合)、実際の質問、および現在の値(設定されていない場合は空欄)が表示されます。列挙された値セットからの選択を期待する質問タイプの場合、コードの表示値へのマッピングが表示されます。
|-
|太字の黄褐色のテキスト||'''<span style='color:#996600;background:#eee8aa'>サンプル</span>'''||LimeSurveyの置換値||値||LimeSurveyの置換文字列({TOKEN:xxx}、{PRIVACY_MESSAGE}など)は太字の黄褐色のテキストとして表示されます。 ツールチップには現在の値が表示されます。
|-
|赤色のテキスト||'''<span style='color:red,#eee8aa;background:#eee8aa'>サンプル</span>'''||代入演算子||注意喚起メッセージ||代入演算子(=,+=,-=,*=,/=)のいずれかを使用すると、代入演算子が赤色のテキストで表示されます。これは、aとbは等しいことを確認しようとしているとき、誤ってbの値をaに代入するようなことを防ぐのに役立ちます。
|-
|通常の黒色のテキスト||<span style='color:black;background:#eee8aa'>サンプル</span>||句読点||なし||式の内の他の句読点はすべて、通常の黒文字で表示されます。
|-
|赤枠で囲まれたテキスト||<span style='background-color: #eee8aa;'><span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'>サンプル</span></span>||構文エラー||エラーの説明||検出された構文エラーは、エラーを赤い枠線で囲んで表示されます。ツールチップにエラーが表示されます。例としては、括弧の不一致、未定義関数の使用、関数に渡す引数の数の誤り、構造化が不十分な式(変数間の演算子の欠落など)、読み取り専用変数に値を代入しようとする、変数でないものに値を代入しようとする、サポートされていない構文を使用するなどです。構文エラー検出システムは、複数のエラーがあっても式内の1つのエラーだけを報告することがあります。ただし、エラーが検出された場合は、少なくとも1つのエラーが表示されます。
|-
|
|}
 
{{Hint|Text=To be used in javascript, url etc .... a variable must be static in the page. Then the expression must be contain only variable in other page (Green variable)}}


==例==


The following screenshots give examples,  but do not show the values of the tooltips.  If you install the demo and hover the mouse over any of bold colored words, you will see an informative tooltip.
<center>[[File:em-syntax-highlighting-1-v2.jpg]]</center>


Note, because of this syntax highlighting, it is very easy to compose correct expressions, even ones that are complicated.  Although the LimeSurvey team plans to try to build an Expression Builder GUI, you can use the existing syntax-highlighting to quickly identify and fix typos.  You can also use the tool-tips to validate the accuracy of your expressions (e.g. confirm you have selected the desired variable(s).


In each of the examples, there are three columns:
===エラーを含むEM構文===
#Source - this is the raw text that you would enter into the LimeSurvey Question field
#Pretty Print - this is the syntax-highlighted equivalent of what you entered
#*Note that Expressions are shown with a tan background, but not surrounded by curly braces in this highlighting.
#*Since EM supports recursive substitution, showing curly braces in the highlighting would cause syntax errors
#Result - this is the output generated when EM processes the source
#*Everything that can be properly substituted is
#*Expressions with errors are shown in-line, with syntax highlighting.  Errors are surrounded by a red-lined box.


===適切な構文===


Here are examples of proper syntax:
ES式を入力する際の一般的なエラーの例を次に示します。ツールチップによって追加情報が提供されます。
#Values: shows that known variables are color coded according to whether are set on the current page.  Old-style INSERTANS:xxxx gets its own color-coding style
#中括弧の後にスペースを追加し忘れたインラインJavascript
#Question Attributes: shows that dot notation can access some properties of questions
#*"document.write"が中括弧の直後に表示されると、EMはそれを式と見なし、"document"と"write"はそれぞれ未定義の変数と関数と認識され、赤いボックス内に表示されます。
#Math: shows that basic and complex calculations are supported
#不明、またはスペルミスのある変数、関数、演算子
#TextProcessing: shows some of the available text-processing functions
#*ここでは、"sex"ではなく"gender"という変数名を誤って使用していても、EMはそのエラーをキャッチします。また、'++'はサポートされている演算子ではないため、赤いボックスで囲まれます。
#Dates: shows two of the available date-related functions
#eqの代わりに=を使用したり、値を代入すると警告されます。
#Conditional: shows use of if() function to choose between two choices.  These can be nested.
#*'='と'+='は、黒ではなく赤のテキストで表示されています。その上にマウスカーソルを合わせると、値を代入している旨の警告が表示されます。
#Tailored Paragraph: Shows a more typical example.  You can completely customize a report based upon prior values
#関数の引数の数の誤り
#EM processes within strings:  Shows that it can do substitutions within strings.  This example generates a tailored image name.
#*if()は3つの引数を受け取りますが、4つ与えられているため、赤い枠で囲まれた"if"にカーソルを合わせると、エラーの説明とサポートされている構文が表示されます。
#EM doesn't process curly braces like these:  Shows that if the curly braces are escaped, or there is white space between the expression and the curly braces, EM ignores it.
#*sum()は引数の数に制限はありませんが、閉じ括弧の前にコンマがあるため、赤いボックスで囲まれています。
<nowiki>**</nowiki>This is critical for embedding custom JavaScript.
#括弧の不一致
#*これは、式を記述する際の最も一般的なエラーの1つです。
#*ここでは、閉じ括弧が不足している例2つと、閉じ括弧が多すぎる例を示しています。
#サポートされていない構文
#*ESがサポートしていない演算子や記号を使用すると、赤いボックスで囲まれます。
#無効な代入
#*変数には、読み書き可能で値を変更できるもの、読み取り専用のものがあります。
#*読み取り専用変数の値を変更しようとしてもできません。この場合、EMは赤いボックスで表示します。
#*式または文字列に値を代入しようとしてもエラーが発生します。


[[File:em-syntax-highlighting-1-v2.jpg]]


===エラーを含むEM構文===
<center>[[File:em-syntax-highlighting-errors-v2.jpg]]</center>


Here are examples of common errors when typing EM expressions.  Note that the tooltips provide additional information.
#Inline Javascript that forgot to add spaces after curly brace
#*Since "document.write" appears right after a curly brace, EM thinks it is an expression, and red-boxes "document" and "write" since they are undefined variable and functions, respectively
#Unknown/Misspelledd Variables, Functions and Operators
#*Here we forgot that we are using the variable name "gender" instead of "sex", but EM catches that error.  It also red-boxes '++', since that is not a supported operator.
#Warns if use = instead of eq, or perform value assignments
#*Note that the '=' and '+=' are in red text instead of black.  If you hover the mouse over them, you will see warnings that you are assigning a value.
#Wrong number of arguments for functions
#*if() takes 3 arguments, but has been given 4, so hovering over the red-boxed "if" will explain the error and show the supported syntax
#*sum() takes an unlimited number of arguments, but we had a trailing comma before the closing parentheses, so that is red-boxed
#Mismatched parentheses
#*This is one of the most common errors when writing expressions.
#*This shows two examples of missing closing parentheses, and one example of having one too many closing parentheses.
#Unsuported syntax
#*If you use an operator or punctuation that EM does not support, it will red-box it.
#Invalid assignments
#*Some variables are readWrite and can have their values changed. Others are read-only
#*If you try to change the value of a read-only variable, you can't.  EM will red-box the attempt.
#*If you try to assign a value to an equation or a string, you will also get an error


[[File:em-syntax-highlighting-errors-v2.jpg]]
==アクティブなツールチップを使用した構文強調表示の"実際に動く"例==




==="Live" examples of Syntax Highlighting with active tooltips===
<table border="1">
<table border="1">
  <tr><th>Source</th><th>Pretty Print</th><th>Result</th></tr><tr><td><b>Here is an example of OK syntax with tooltips</b><br>Hello {if(gender=='M','Mr.','Mrs.')} {surname}, it is now {date('g:i a',time())}.  Do you know where your {sum(numPets,numKids)} chidren and pets are?
  <tr><th>ソース</th><th>整形表示</th><th>結果</th></tr><tr><td><b>ここでは、ツールチップを使ったOK構文の例を示します。</b><br>こんにちは、{if(gender=='M','Mr.','Mrs.')} {surname}。現在、{date('g:i a',time())}です。数を合わせると{sum(numPets,numKids)}になるあなたの子供とペットがどこにいるかわかりますか。


</td><td><b>Here is an example of OK syntax with tooltips</b><br>Hello <span style="background-color: #eee8aa;"><span title="Excel-style if(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span>(<span title="[java61764X1X5][G:2][Q:110]: What is your gender (male/female)?; value=M" style="color: green; font-weight: bold">gender</span> == <span title="" style="color: gray">'M'</span>,<span title="" style="color: gray">'Mr.'</span>,<span title="" style="color: gray">'Mrs.'</span>)</span> <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:20]: What is your last/surname?; value=Smith" style="color: green; font-weight: bold">surname</span></span>, it is now <span style="background-color: #eee8aa;"><span title="Format a local date/time; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span>(<span title="" style="color: gray">'g:i a'</span>,<span title="Return current UNIX timestamp; number time()" style="color: blue; font-weight: bold">time</span>())</span>.  Do you know where your <span style="background-color: #eee8aa;"><span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X4][G:2][Q:50]: How many pets do you have?; value=1" style="color: maroon; font-weight: bold">numPets</span>,<span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>)</span> chidren and pets are?
</td><td><b>ここでは、ツールチップを使ったOK構文の例を示します。</b><br>こんにちは、<span style="background-color: #eee8aa;"><span title="Excelのようなif(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span>(<span title="[java61764X1X5][G:2][Q:110]: 性別は、男性/女性どちらですか。; value=M" style="color: green; font-weight: bold">gender</span> == <span title="" style="color: gray">'M'</span>,<span title="" style="color: gray">'Mr.'</span>,<span title="" style="color: gray">'Mrs.'</span>)</span> <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:20]: あなたの姓は何ですか。; value=Smith" style="color: green; font-weight: bold">surname</span></span>。現在、<span style="background-color: #eee8aa;"><span title="ローカルの日時を表示する; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span>(<span title="" style="color: gray">'g:i a'</span>,<span title="現在のUNIXタイムスタンプを返す; number time()" style="color: blue; font-weight: bold">time</span>())</span>です。数を合わせると<span style="background-color: #eee8aa;"><span title="配列の中の値を合計する; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X4][G:2][Q:50]: ペットは何匹いますか。; value=1" style="color: maroon; font-weight: bold">numPets</span>,<span title="[java61764X1X3][G:2][Q:40]: 何人の子供がいますか。; value=2" style="color: green; font-weight: bold">numKids</span>)</span>になるあなたの子供とペットがどこにいるかわかりますか。


</td><td><b>Here is an example of OK syntax with tooltips</b><br>Hello <span id="LEMtailor_Q_40_1">Mr.</span> <span id="LEMtailor_Q_40_2">Smith</span>, it is now 6:07 am.  Do you know where your <span id="LEMtailor_Q_40_4">3</span> chidren and pets are?
</td><td><b>ここでは、ツールチップを使ったOK構文の例を示します。</b><br>こんにちは、<span id="LEMtailor_Q_40_1">Mr.</span> <span id="LEMtailor_Q_40_2">Smith</span>。現在、6:07 amです。数を合わせると<span id="LEMtailor_Q_40_4">3</span>になるあなたの子供とペットがどこにいるかわかりますか。
</td></tr>
</td></tr>
<tr><td><b>Here are common errors so you can see the tooltips</b><br>Variables used before they are declared:  {notSetYet}<br>Unknown Function:  {iff(numPets&gt;numKids,1,2)}<br>Unknown Variable: {sum(age,num_pets,numKids)}<br>Wrong # parameters: {sprintf()},{if(1,2)},{date()}<br>Assign read-only-vars:{TOKEN:ATTRIBUTE_1+=10},{name='Sally'}<br>Unbalanced parentheses: {pow(3,4},{(pow(3,4)},{pow(3,4))}
<tr><td><b>ここでは、一般的なエラーの例を使って、ツールチップを見ることができます。</b><br>宣言なしに使用された変数:  {notSetYet}<br>未知の関数:  {iff(numPets&gt;numKids,1,2)}<br>未知の変数: {sum(age,num_pets,numKids)}<br>引数の数の誤り: {sprintf()},{if(1,2)},{date()}<br>読み取り専用変数への代入:{TOKEN:ATTRIBUTE_1+=10},{name='Sally'}<br>括弧の不一致: {pow(3,4},{(pow(3,4)},{pow(3,4))}


</td><td><b>Here are common errors so you can see the tooltips</b><br>Variables used before they are declared: <span style="background-color: #eee8aa;"><span title="This variable is not declared until a later page; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="This variable is not declared until a later page; Not a valid expression; [java61764X3X6][G:3][Q:200]: Who will win the next election?; value=?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span><br>Unknown Function:  <span style="background-color: #eee8aa;"><span title="Undefined function" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined function" style="color: blue; font-weight: bold">iff</span></span>(<span title="[java61764X1X4][G:2][Q:50]: How many pets do you have?; value=1" style="color: maroon; font-weight: bold">numPets</span> &gt; <span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>,1,2)</span><br>Unknown Variable: <span style="background-color: #eee8aa;"><span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Undefined variable" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined variable" style="color: red; font-weight: bold">num_pets</span></span>,<span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>)</span><br>Wrong # parameters: <span style="background-color: #eee8aa;"><span title="Function must have at least 1 argument(s); Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function must have at least 1 argument(s); Not a valid expression; Return a formatted string; string sprintf(format, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span>()</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments2.  Function supports this many arguments, where -1=unlimited: 3; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments2.  Function supports this many arguments, where -1=unlimited: 3; Not a valid expression; Excel-style if(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span></span>(1,2)</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments0.  Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments0.  Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression; Format a local date/time; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span></span>()</span><br>Assign read-only-vars:<span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; ; value=worker" style="color: #996600; font-weight: bold">TOKEN:ATTRIBUTE_1</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">+=</span>10</span>,<span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; [java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">=</span><span title="" style="color: gray">'Sally'</span></span><br>Unbalanced parentheses: <span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Parentheses not balanced; Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span></span>(3,4</span>,<span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;">(</span><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)</span>,<span style="background-color: #eee8aa;"><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)<span title="Extra right parentheses detected" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>
</td><td><b>ここでは、一般的なエラーの例を使って、ツールチップを見ることができます。</b><br>宣言なしに使用された変数: <span style="background-color: #eee8aa;"><span title="この変数は後のページまで宣言されていません。;有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="この変数は後のページまで宣言されていません。;有効な式ではありません。;[java61764X3X6][G:3][Q:200]: 次の選挙ではだれが当選するでしょうか。; value=?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span><br>未知の関数:  <span style="background-color: #eee8aa;"><span title="未知の関数" style="border-style: solid; border-width: 2px; border-color: red;"><span title="未知の関数" style="color: blue; font-weight: bold">iff</span></span>(<span title="[java61764X1X4][G:2][Q:50]: ペットは何匹いますか。; value=1" style="color: maroon; font-weight: bold">numPets</span> &gt; <span title="[java61764X1X3][G:2][Q:40]: 何人の子供がいますか。; value=2" style="color: green; font-weight: bold">numKids</span>,1,2)</span><br>未知の変数: <span style="background-color: #eee8aa;"><span title="配列の中の値を合計する; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span>,<span title="未知の変数" style="border-style: solid; border-width: 2px; border-color: red;"><span title="未知の変数" style="color: red; font-weight: bold">num_pets</span></span>,<span title="[java61764X1X3][G:2][Q:40]: 何人の子供がいますか。; value=2" style="color: green; font-weight: bold">numKids</span>)</span><br>引数の数の誤り: <span style="background-color: #eee8aa;"><span title="関数は少なくとも1つの引数が必要です。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="関数は少なくとも1つの引数が必要です。;有効な式ではありません。; フォーマットされた文字列を返す; string sprintf(format, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span>()</span>,<span style="background-color: #eee8aa;"><span title="関数は次の個数の引数をサポートしていません2。関数がサポートする引数の数(-1は制限なし): 3; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="関数は次の個数の引数をサポートしていません2。関数がサポートする引数の数(-1は制限なし): 3; 有効な式ではありません。; Excelのようなif(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span></span>(1,2)</span>,<span style="background-color: #eee8aa;"><span title="関数は次の個数の引数をサポートしていません0。関数がサポートする引数の数(-1は制限なし): 1,2; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="関数は次の個数の引数をサポートしていません0。関数がサポートする引数の数(-1は制限なし): 1,2; 有効な式ではありません。; ローカルの日付/時刻をフォーマットする; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span></span>()</span><br>読み取り専用変数への代入:<span style="background-color: #eee8aa;"><span title="この変数の値は変更できません。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="この変数の値は変更できません。; 有効な式ではありません。; ; value=worker" style="color: #996600; font-weight: bold">TOKEN:ATTRIBUTE_1</span></span><span title="変数に新たな値を代入する" style="color: red; font-weight: bold">+=</span>10</span>,<span style="background-color: #eee8aa;"><span title="この変数の値は変更できません。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="この変数の値は変更できません。; 有効な式ではありません。; [java61764X1X1][G:1][Q:10]: あなたの名前は何ですか。; value=Peter" style="color: green; font-weight: bold">name</span></span><span title="変数に新たな値を代入する" style="color: red; font-weight: bold">=</span><span title="" style="color: gray">'Sally'</span></span><br>括弧の不一致: <span style="background-color: #eee8aa;"><span title="括弧の数が一致していません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="括弧の数が一致していません。; 指数関数; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span></span>(3,4</span>,<span style="background-color: #eee8aa;"><span title="括弧の数が一致していません。" style="border-style: solid; border-width: 2px; border-color: red;">(</span><span title="指数関数; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)</span>,<span style="background-color: #eee8aa;"><span title="指数関数; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)<span title="余分な右括弧があります。" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>


</td><td><b>Here are common errors so you can see the tooltips</b><br>Variables used before they are declared:  <span id="LEMtailor_Q_40_5"><span style="background-color: #eee8aa;"><span title="This variable is not declared until a later page; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="This variable is not declared until a later page; Not a valid expression; [java61764X3X6][G:3][Q:200]: Who will win the next election?; value=?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span></span><br>Unknown Function:  <span style="background-color: #eee8aa;"><span title="Undefined function" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined function" style="color: blue; font-weight: bold">iff</span></span>(<span title="[java61764X1X4][G:2][Q:50]: How many pets do you have?; value=1" style="color: maroon; font-weight: bold">numPets</span> &gt; <span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>,1,2)</span><br>Unknown Variable: <span style="background-color: #eee8aa;"><span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Undefined variable" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Undefined variable" style="color: red; font-weight: bold">num_pets</span></span>,<span title="[java61764X1X3][G:2][Q:40]: How many kids do you have?; value=2" style="color: green; font-weight: bold">numKids</span>)</span><br>Wrong # parameters: <span style="background-color: #eee8aa;"><span title="Function must have at least 1 argument(s); Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function must have at least 1 argument(s); Not a valid expression; Return a formatted string; string sprintf(format, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span>()</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments2.  Function supports this many arguments, where -1=unlimited: 3; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments2.  Function supports this many arguments, where -1=unlimited: 3; Not a valid expression; Excel-style if(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span></span>(1,2)</span>,<span style="background-color: #eee8aa;"><span title="Function does not support that number of arguments0.  Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Function does not support that number of arguments0.  Function supports this many arguments, where -1=unlimited: 1,2; Not a valid expression; Format a local date/time; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span></span>()</span><br>Assign read-only-vars:<span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; ; value=worker" style="color: #996600; font-weight: bold">TOKEN:ATTRIBUTE_1</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">+=</span>10</span>,<span id="LEMtailor_Q_40_12"><span style="background-color: #eee8aa;"><span title="The value of this variable can not be changed; Not a valid expression" style="border-style: solid; border-width: 2px; border-color: red;"><span title="The value of this variable can not be changed; Not a valid expression; [java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span></span><span title="Assigning a new value to a variable" style="color: red; font-weight: bold">=</span><span title="" style="color: gray">'Sally'</span></span></span><br>Unbalanced parentheses: <span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;"><span title="Parentheses not balanced; Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span></span>(3,4</span>,<span style="background-color: #eee8aa;"><span title="Parentheses not balanced" style="border-style: solid; border-width: 2px; border-color: red;">(</span><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)</span>,<span style="background-color: #eee8aa;"><span title="Exponential expression; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)<span title="Extra right parentheses detected" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>
</td><td><b>ここでは、一般的なエラーの例を使って、ツールチップを見ることができます。</b><br>宣言なしに使用された変数:  <span id="LEMtailor_Q_40_5"><span style="background-color: #eee8aa;"><span title="この変数は後のページまで宣言されていません。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="この変数は後のページまで宣言されていません。;有効な式ではありません。; [java61764X3X6][G:3][Q:200]: 次の選挙ではだれが当選するでしょうか。; value=?" style="color: #FF00FF ; font-weight: bold">notSetYet</span></span></span></span><br>未知の関数:  <span style="background-color: #eee8aa;"><span title="未知の関数" style="border-style: solid; border-width: 2px; border-color: red;"><span title="未知の関数" style="color: blue; font-weight: bold">iff</span></span>(<span title="[java61764X1X4][G:2][Q:50]: ペットは何匹いますか。; value=1" style="color: maroon; font-weight: bold">numPets</span> &gt; <span title="[java61764X1X3][G:2][Q:40]: 何人の子供がいますか。; value=2" style="color: green; font-weight: bold">numKids</span>,1,2)</span><br>未知の変数: <span style="background-color: #eee8aa;"><span title="配列の中の値を合計する; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(<span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span>,<span title="未知の変数" style="border-style: solid; border-width: 2px; border-color: red;"><span title="未知の変数" style="color: red; font-weight: bold">num_pets</span></span>,<span title="[java61764X1X3][G:2][Q:40]: 何人の子供がいますか。; value=2" style="color: green; font-weight: bold">numKids</span>)</span><br>引数の数の誤り: <span style="background-color: #eee8aa;"><span title="関数は少なくとも1つの引数が必要です。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="関数は少なくとも1つの引数が必要です。; 有効な式ではありません。; フォーマットされた文字列を返す; string sprintf(format, arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sprintf</span></span>()</span>,<span style="background-color: #eee8aa;"><span title="関数は次の個数の引数をサポートしていません2。関数がサポートする引数の数(-1は制限なし): 3; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="関数は次の個数の引数をサポートしていません2。関数がサポートする引数の数(-1は制限なし): 3; 有効な式ではありません。; Excelのようなif(test,result_if_true,result_if_false); if(test,result_if_true,result_if_false)" style="color: blue; font-weight: bold">if</span></span>(1,2)</span>,<span style="background-color: #eee8aa;"><span title="関数は次の個数の引数をサポートしていません0。関数がサポートする引数の数(-1は制限なし): 1,2; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="関数は次の個数の引数をサポートしていません0。関数がサポートする引数の数(-1は制限なし): 1,2; 有効な式ではありません。; ローカルの日付/時刻をフォーマットする; string date(format [, timestamp=time()])" style="color: blue; font-weight: bold">date</span></span>()</span><br>読み取り専用変数への代入:<span style="background-color: #eee8aa;"><span title="この変数の値は変更できません。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="この変数の値は変更できません。; 有効な式ではありません。; ; value=worker" style="color: #996600; font-weight: bold">TOKEN:ATTRIBUTE_1</span></span><span title="変数に新たな値を代入する" style="color: red; font-weight: bold">+=</span>10</span>,<span id="LEMtailor_Q_40_12"><span style="background-color: #eee8aa;"><span title="この変数の値は変更できません。; 有効な式ではありません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="この変数の値は変更できません。; 有効な式ではありません。; [java61764X1X1][G:1][Q:10]: あなたの名前は何ですか。; value=Peter" style="color: green; font-weight: bold">name</span></span><span title="変数に新たな値を代入する" style="color: red; font-weight: bold">=</span><span title="" style="color: gray">'Sally'</span></span></span><br>括弧の不一致: <span style="background-color: #eee8aa;"><span title="括弧の数が一致していません。" style="border-style: solid; border-width: 2px; border-color: red;"><span title="括弧の数が一致していません。; 指数関数; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span></span>(3,4</span>,<span style="background-color: #eee8aa;"><span title="括弧の数が一致していません。" style="border-style: solid; border-width: 2px; border-color: red;">(</span><span title="指数関数; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)</span>,<span style="background-color: #eee8aa;"><span title="指数関数; number pow(base, exp)" style="color: blue; font-weight: bold">pow</span>(3,4)<span title="余分な右括弧があります。" style="border-style: solid; border-width: 2px; border-color: red;">)</span></span>


</td></tr>
</td></tr>
<tr><td><b>Here is some of the unsupported syntax</b><br>No support for '++', '--', '%',';': {min(++age, --age,age % 2);}<br>Nor '|', '&amp;', '^': {(sum(2 | 3,3 &amp; 4,5 ^ 6)}}<br>Nor arrays: {name[2], name['mine']}
<tr><td><b>サポートされていない構文の例を示します。</b><br>サポートされていない'++''--''%'';': {min(++age, --age,age % 2);}<br>'|''&amp;''^': {(sum(2 | 3,3 &amp; 4,5 ^ 6)}}<br>配列: {name[2], name['mine']}
</td><td><b>Here is some of the unsupported syntax</b><br>No support for '++', '--', '%',';': <span style="background-color: #eee8aa;"><span title="Find lowest value; number min(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span>(<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ++ </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> -- </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> % </span>2)<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ; </span></span><br>Nor '|', '&amp;', '^': <span style="background-color: #eee8aa;">(<span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> | </span>3,3<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> &amp; </span>4,5<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ^ </span>6)</span>}<br>Nor arrays: <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span>2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span>,<span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span><span title="" style="color: gray">'mine'</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span></span>
</td><td><b>サポートされていない構文の例を示します。</b><br>サポートされていない'++''--''%'';': <span style="background-color: #eee8aa;"><span title="最小値を探す; number min(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span>(<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ++ </span><span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span>,<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> -- </span><span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span>,<span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> % </span>2)<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ; </span></span><br>'|''&amp;''^': <span style="background-color: #eee8aa;">(<span title="配列の中の値を合計する; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(2<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> | </span>3,3<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> &amp; </span>4,5<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ^ </span>6)</span>}<br>配列: <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:10]: あなたの名前は何ですか。; value=Peter" style="color: green; font-weight: bold">name</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span>2<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span>,<span title="[java61764X1X1][G:1][Q:10]: あなたの名前は何ですか。; value=Peter" style="color: green; font-weight: bold">name</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span><span title="" style="color: gray">'mine'</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span></span>


</td><td><b>Here is some of the unsupported syntax</b><br>No support for '++', '--', '%',';': <span style="background-color: #eee8aa;"><span title="Find lowest value; number min(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span>(<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ++ </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> -- </span><span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span>,<span title="[java61764X1X2][G:2][Q:30]: How old are you?; value=45" style="color: green; font-weight: bold">age</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> % </span>2)<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ; </span></span><br>Nor '|', '&amp;', '^': <span style="background-color: #eee8aa;">(<span title="Calculate the sum of values in an array; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> | </span>3,3<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> &amp; </span>4,5<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ^ </span>6)</span>}<br>Nor arrays: <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span>2<span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span>,<span title="[java61764X1X1][G:1][Q:10]: What is your first/given name?; value=Peter" style="color: green; font-weight: bold">name</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span><span title="" style="color: gray">'mine'</span><span title="Unsupported syntax" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span></span>
</td><td><b>サポートされていない構文の例を示します。</b><br>サポートされていない'++''--''%'';': <span style="background-color: #eee8aa;"><span title="最小値を探す; number min(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">min</span>(<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ++ </span><span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span>,<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> -- </span><span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span>,<span title="[java61764X1X2][G:2][Q:30]: 何歳ですか。; value=45" style="color: green; font-weight: bold">age</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> % </span>2)<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ; </span></span><br>'|''&amp;''^': <span style="background-color: #eee8aa;">(<span title="配列の中の値を合計する; number sum(arg1, arg2, ... argN)" style="color: blue; font-weight: bold">sum</span>(2<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> | </span>3,3<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> &amp; </span>4,5<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ^ </span>6)</span>}<br>配列: <span style="background-color: #eee8aa;"><span title="[java61764X1X1][G:1][Q:10]: あなたの名前は何ですか。; value=Peter" style="color: green; font-weight: bold">name</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span>2<span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span>,<span title="[java61764X1X1][G:1][Q:10]: あなたの名前は何ですか。; value=Peter" style="color: green; font-weight: bold">name</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> [ </span><span title="" style="color: gray">'mine'</span><span title="サポートされていない構文" style="border-style: solid; border-width: 2px; border-color: red;"> ] </span></span>


</td></tr>
</td></tr>
</table>
</table>


=テーラリングの例({INSERTANS:xxx}の拡張)=
 
=文言調整の例({INSERTANS:xxx}の拡張)=
 


=="Dear {Mr}/{Mrs} Smith..."==
=="Dear {Mr}/{Mrs} Smith..."==


'Mr.'か'Mrs.'を使い分けるにはif()関数を使用します。
'Mr.'か'Mrs.'を使い分けるにはif()関数を使用します。


The syntax is if(test,do_if_true,do_if_false).
構文は、if(test,do_if_true,do_if_false)となります。


{|
{|
|#||Code||Question||Type
|#||コード||質問||タイプ
|-
|-
|1||gender||What is your gender?||Gender
|1||gender||性別は?||性別
|-
|-
|2||example1||Dear {if(gender=='M','Mr.','Mrs.')} Smith, ...||Text display
|2||example1||Dear {if(gender=='M','Mr.','Mrs.')} Smith, ...||自由回答(長い)
|-
|
|}
|}


[[File:em-tailoring-q-ex1.jpg]]


Usage View:
<center>[[File:em-tailoring-q-ex1.jpg]]</center>
 
 
以下で確認できるように、"性別"に対する回答として回答者が選択したものに合わせ、"Mr"または"Mrs"になるように調整されています。
 
 
<center>[[File:em-tailoring-q-ex1-usage.jpg]]
[[File:em-tailoring-q-ex2-usage.jpg]]</center>


[[File:em-tailoring-q-ex1-usage.jpg]]


==案内メールにおける"Dear {Mr}/{Mrs} Smith..."==
==案内メールにおける"Dear {Mr}/{Mrs} Smith..."==


You can use the example above in the invitation email using attributes from the token table. Use the if() function to choose whether 'Mr.' or 'Mrs.' should be used in the email.


The syntax is if(test,do_if_true,do_if_false).
トークンテーブルの属性を使用して、上記の例を案内メールに使用できます。電子メールの中で'Mr.'または'Mrs.'を使い分けるにはif()関数を使用します。
 
 
構文は、"if(test,do_if_true,do_if_false)"となります。


{|
{|
|#||attribute||value
|#||属性||
|-
|-||Last name||Smith
|-
|-
|-||Email address||test@test.com
|1||||Smith
|-
|-
|-||ATTRIBUTE_2||M
|2||メールアドレス||test@test.com
|-
|-
|
|3||ATTRIBUTE_2||M
|}
|}


Text in invitation email:


<syntaxhighlight lang="php" enclose="div">
案内メールのテキストは以下のとおりです。
 
<syntaxhighlight lang="php">


Dear {if(ATTRIBUTE_2=='M','Mr','Mrs')} {LASTNAME},
Dear {if(ATTRIBUTE_2=='M','Mr','Mrs')} {LASTNAME},


you have been invited to participate in a survey:
あなたはアンケートに招待されました。


http:/...
https:/...


</syntaxhighlight>
</syntaxhighlight>


[[File:emEx1mail.jpg]]


email View:
<center>[[File:emEx1mail.jpg]]</center>
 
 
電子メールは次のようになります。
 
 
<center>[[File:emEx1mailview.jpg]]</center>


[[File:emEx1mailview.jpg]]


=Calculation / Assessment Examples=
=計算/評価の例=


==Calculate assessment values at runtime and store the results in the survey data==


This example uses all of EM's features, including Relevance, Tailoring, and the Equation question type.
==実行時に評価値を計算し、その結果をアンケートデータに格納する==


It also shows that all of these are JavaScript-enabled, so if you have these features on a page, it will dynamically change as people set and change their answers.
 
この例では、EMのすべての機能(出現条件、文言調整、式の質問タイプなど)を使用しています。
 
また、これらのすべてがJavaScript対応であることも示しています。したがって、ページにこれらの機能を導入すると、回答者が回答を設定したり変更したりすると、動的に変化します。


{|
{|
|#||Code||Question||Type||Relevance
|#||コード||質問||タイプ||出現条件
|-
|-
|1||numKids||How many children do you have?||Numerical input||1
|1||numKids||子供は何人いますか。||数値入力||1
|-
|-
|2||kid1||How old is your first child?||Numerical input||numKids >= 1
|2||kid1||1人目の子供は何歳ですか。||数値入力||numKids >= 1
|-
|-
|3||kid2||How old is your second child?||Numerical input||numKids >= 2
|3||kid2||2人目の子供は何歳ですか。||数値入力||numKids >= 2
|-
|-
|4||kid3||How old is your third child?||Numerical input||numKids >= 3
|4||kid3||3人目の子供は何歳ですか。||数値入力||numKids >= 3
|-
|-
|5||kid4||How old is your fourth child?||Numerical input||numKids >= 4
|5||kid4||4人目の子供は何歳ですか。||数値入力||numKids >= 4
|-
|-
|6||sumKidAges||{sum(kid1.NAOK,kid2,NAOK,kid3.NAOK,kid4.NAOK)}||Equation||1
|6||sumKidAges||{sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK)}||||1
|-
|-
|7||kidSummary||You said that you have {numKids}. {if(numKids==1,'child','children')}. {if(numKids>1,implode(' ','The sum of ages of your first ',min(numKids,4),' kids is ',sumKidAges,'.'),' ')}||Text display||1
|7||kidSummary||{if(numKids==1,'子供','子供達')}が{numKids}人いると答えました。{if(numKids>1,implode(' ','最初から',min(numKids,4),'人の子供の年齢の合計は',sumKidAges,'です。'),' ')}||テキスト表示||1
|-
|
|}
|}


Here are screen shots of representative questions.  As you can see, EM syntax-highlights all fields that might contain tailoring.  Here, you see examples of syntax-highlighting Relevance, the Equation question type, and substitions within a Question.  However, you can also put substitutions within Help, Group header display, the Welcome message, and the End message.


For this question, since the relevance is {numKids >= 2), it will only be visible if the respondant reports that they have at least two children.
この例をダウンロードするには、次のリンクをクリックしてください。 [[Media:Assessments_survey_example.zip|Assessments_survey_example]]
 
 
以下は、代表的な質問のスクリーンショットです。ご覧のとおり、EM構文では、文言調整を含んでいそうなすべてのフィールドが強調表示されます。ここでは、出現条件、式の質問タイプ、および質問内の置換の例を示します。ヘルプ、グループヘッダーの表示、ようこそメッセージ、および終了メッセージ内で置き換えることもできます。
 
次の例では、出現条件は{numKids >= 2}であるため、回答者が少なくとも2人の子供がいると回答した場合にのみ表示されます。
 
 
<center>[[File:em-tailoring2-q-kid2.jpg]]</center>
 
 
また、各変数に.NAOK接尾辞を使用することに注意してください。これは、EMが入れ子の出現条件を実現するためのものです。もし.NAOKをつけない場合、4人の子供を持っていると回答した場合にのみ合計が計算されることになります(すべての変数が真の場合)。.NAOKを使用すると、変数のすべてまたは一部が偽であっても合計を計算することを意味します(すなわち"該当なし"(Not Applicable - NA)でも構わないということです)。
 
ただし、.NAOK属性は変数がEMに渡されるかどうかにのみ影響します。例えば、その人が最初に3人の子供がいると回答し、それぞれの年齢を入力した後、気が変わり、2人であると答えた場合、3人目の子供はもはや無関係なので、3つの入力値の合計は必要ありません。
 
 
<center>[[File:em-tailoring2-q-sumKidAges.jpg]]</center>
 
 
それぞれの式は、黄褐色の背景で色分けされています。ご覧の通り、3つの別々の式があります。最後の式には、2人以上の子供がいる場合にのみ表示されるメッセージが入っています。
 
 
<center>[[File:em-tailoring2-q-kidSummary.jpg]]</center>
 
 
ここでは、実際のアンケートのスクリーンショットを示します。
 
最初にページにアクセスすると、これが表示されます。"0人の'''子ども'''がいます"ではなく、"0人の'''子どもたち'''がいます"となっていることに注意してください。
 
 
<center>[[File:em-tailoring2-s-0kids.jpg]]</center>
 
 
子どもの数を1に変更すると、同じページ上にあってもこのように表示が即座に変わります。
 
 
<center>[[File:em-tailoring2-s-1kid.jpg]]</center>
 
 
文法は正しいものになっています。 "You have 1 '''child'''".
 
今度は、子供の数の値を3に変更し、即座に表示を変更します。
 
次の条件付きメッセージが下部に表示されていることに注目してください。"The sum of ages of your first 3 kids is 0.(最初の3人の子供の年齢の合計は0です。)"
 
 
</center>[[File:em-tailoring2-s-3kids.jpg]]</center>
 
 
今、子供の年齢を入力し、その年齢を合計して、このように表示させるとします。
 
 
<center>[[File:em-tailoring2-s-3kids-sum.jpg]]</center>
 
 
値を入力するとスコアと表示が即座に更新されるため、これを使用して評価スコアの合計を表示することができます。
 
 
今度は、子供の数を2に変更します。表示は次のように変わります。


[[File:em-tailoring2-q-kid2.jpg]]


Note that this question uses the new Equation type, and that despite being "Always hidden", the result will be computed and stored to the database.
<center>[[File:em-tailoring2-s-2kids-sum.jpg]]</center>


Also note that is uses the .NAOK suffix for each variable.  This is because of how EM supports cascading relevance.  If you did not have .NAOK, then the sum would only be computed if the person said they had 4 children (e.g. if all of the variables are relevant).  By using .NAOK, that means that we want to compute the sum even if all or some of the variables are irrelevant (e.g. "Not Applicable" (NA) is alright (OK)).


However, the .NAOK attribute only affects whether variables are passed into EM.  If the person initially says they have 3 children, and enters ages for each, then changes their mind and says they have 2, we don't want to see the sum of the 3 entered values - see below for an example of this.
3番目の子供には5.5の値を入力しましたが、レポートには最初の2人の子供の値が合計されるようになりました。


[[File:em-tailoring2-q-sumKidAges.jpg]]
その理由は、第3の値は出現条件を満たさなくなり、EMはそのような値を無視するからです。


Each separate Expression is color coded with a tan background.  As you can see, three separate Expressions here.  The last one contains a message that is conditionally shown only if the person has more than one child.
子供の数を3に戻すと、再び5.5という値が見えます。これにより、ページに入力した情報を失うことはありません。


[[File:em-tailoring2-q-kidSummary.jpg]]
ただし、次または前のページに移動すると、出現条件を満たさない値はすべてセッション内およびデータベース内でNULLになります。もし、子供の数を2と設定したまま次のページに行き、もとのページに戻り、実は3人の子供がいると回答すると、5.5という年齢を見ることはありません。


Now, here are screen shots of the survey in action.


When you first visit the page, you see this.   Note that is says "You have 0 '''children'''" instead of "You have 0 '''child'''".
==データを入力し、同じページ内で入力されたものが動的に変化するレポートを表示する==


[[File:em-tailoring2-s-0kids.jpg]]


If I change the value for number of children to 1, the display instantly changes to this, even though it is on the same page.
この例は、LimeSurvey内の文言調整プロセスを示します。


Now notice that the grammar is correct, is says, "You have 1 '''child'''".
この例をダウンロードするには、下記のリンクをクリックします。 [[Media:Dynamic_change_of_the_report_when_data_is_entered_on_the_same_page_survey.zip|動的に変化するアンケートの例]]


[[File:em-tailoring2-s-1kid.jpg]]
これは、ページが最初にどのように見えるかを示しています。どの都市に住んでいるのか尋ねる質問だけがあります。


Now I change the value for number of children to 3, and the display instantly changes to this.


Notice that you now see the conditional message at the bottom:  "The sum of ages of your first 3 kids is 0.".
<center>[[File:em-on_page_report-usage-1.jpg]]</center>


[[File:em-tailoring2-s-3kids.jpg]]


Now I'll enter ages for my imaginary children, and I get this display, summing their ages.
回答を入力し始めると、文言調整プロセスも開始されます。


Again, the score and display updates instantly as I enter the values, so you can use this to show a running total of an Assessment Score.
<center>[[File:em-on_page_report-usage-2.jpg]]</center>


[[File:em-tailoring2-s-3kids-sum.jpg]]


Now, I change the value for the number of children to 2, and the display instantly changes to this.
回答を入力すると、ページの下部にある表が更新され、回答コードと回答の値が表示されます。


Notice that although I had entered a value of 5.5 for the third child, the report now only sums the values of my first 2 children.


The reason for this is that the 3rd value is now irrelevant, and irrelevant values are actively ignored by EM.
<center>[[File:em-on_page_report-usage-3.jpg]]</center>


[[File:em-tailoring2-s-2kids-sum.jpg]]
=一般的なデバッグの例=


Note, if I were to change the number of kids back to 3, I would see the value of 5.5 I entered, so I don't lose any information I enter on the page.


However, if I navigate to the Next or Previous page, all irrelevant values will be NULLed out in the session and in the database.  So, if I were to keep the value at 2, go to the next page and come back, then say  that I had 3 kids, I would no longer see the age of 5.5.
==ネストされたif()ステートメント(条件付きロジック)==


==Enter data and see a dynamically changing report of what was entered on the same page==


This example uses two of EM's features:  Relevance and Tailoring.
EMは、条件付きロジックまたは文言調整を実行できるよう、関数"if(test,do_if_true,do_if_false)"をサポートしています。この関数は、"if { } else if { } else {  }"と同等の処理を行うために入れ子にすることができます。EMは、括弧の数が合わないかどうかを通知します(たとえば、右括弧が消えているなど)か、または余計な右括弧があるかどうかを通知します。長く入れ子になったif文を作成し、保存し、構文エラーをチェックし、見つかった場合は修正してください。以下の例を一緒にチェックしてみましょう。


Rather than summarizing the questions as a table, the actual LimeSurvey group file is attached so you can try it yourself.
以下の質問のグループは、ここからアクセスできます。[[Media:Example_tailoring_group11.zip|Tailoring survey example.lsg]]


Here is what the page looks like initially.  You only see the question asking what City you live in.


[[File:em-on_page_report-usage-1.jpg]]
まず何も入力していないときは、単に"Hello."と表示されます。


Once you start to enter an answer, the rest of the questions appear.


[[File:em-on_page_report-usage-2.jpg]]
<center>[[File:em-nested-if-blank.jpg]]</center>


As you enter answers, the table at the bottom of the page is updated to show the answer codes and values of your responses.


[[File:em-on_page_report-usage-3.jpg]]
名前を入力すると、"Hello {name}."となります。


Here is the bottom of the page, which shows that you can either use {INSERTANS:xxxx} or the newer naming system interchangeably.


[[File:em-on_page_report-usage-4.jpg]]
<center>[[File:em-nested-if-name.jpg]]</center>


=Common Debugging Examples=


==Nested if() Statements (Conditional Logic)==
年齢を入力すると、就学前の子供であるかどうかに応じて調整されたメッセージが届きます。


EM supports the function if(test,do_if_true,do_if_false) so that you can perform conditional logic or tailoring.  This function can be nested to do the equivalent of if { } else if { } else {  }.  EM will let you know if the parentheses are not balanced (e.g. you are missing a closing right parenthesis), or if you have any extra right parentheses.  You should try to count the parentheses as you compose long nested if statements, save it, check for syntax errors, and fix them if any are found.  Here is an example:


Here is the group file for these examples:
<center>[[File:em-nested-if-toddler.jpg]]</center>


[[Media:limesurvey_group_33.lsg|limesurvey_group_33.lsg]]


First, with nothing entered, you just see "Hello."
学齢児童、10代の人、または大人。ここに匿名希望の10代の人がいます。


[[File:em-nested-if-blank.jpg]]


If you enter a name, it says, "Hello {name}."
<center>[[File:em-nested-if-teenager.jpg]]</center>
 
 
ここにグループのロジックファイルがあります。 "if-based"の質問に見られるように、年齢に基づいて入れ子になったif文があります。


[[File:em-nested-if-name.jpg]]


If you enter an age, you get a tailored message, depending upon whether you are a pre-school-age child:
<center>[[File:em-nested-if-logic-file.jpg]]</center>


[[File:em-nested-if-toddler.jpg]]


School aged, teenager, or adult.  Here is a  teenager who wants to be anonymous:
名前を入力すると、"Hello {name}."となります。


[[File:em-nested-if-teenager.jpg]]


Here is the logic file for the group.  As you can see in the iftest question, there are nested if statements based upon the person's age.
[[File:em-nested-if-name.jpg]]


[[File:em-nested-if-logic-file.jpg]]


When you are originally editing this question, it is likely that at some point, you will have the wrong number of parentheses.  Here's what happens if you have too few.
赤いボックスで囲まれた"if"という言葉にカーソルを合わせると、"括弧の数が合わない"と表示されます。この例では、"already an adult!"の後ろに4つの閉じ括弧があるはずですが、3つしかありません。


[[File:em-nested-if-missing-closing-paren.jpg]]
一方、余分な右かっこがある場合、次のように赤い枠で囲まれます。


If you hover over the word "if" which is surrounded by a red box, it says "Parentheses not balanced".  In this case, there should be three closing parentheses after "already an adult!", but there are only two.


If, on the other hand, you have an extra right parenthesis, it will be surrounded by a red box, like this:
<center>[[File:em-nestedd-if-extra-right-paren.jpg]]</center>


[[File:em-nestedd-if-extra-right-paren.jpg]]


When you are actually editing the question, it looks like this:
実際に質問を編集しているときは、次のようになります。


[[File:em-nested-if-edit-screen.jpg]]


In the future, we hope to have to ability to dynamically syntax-highlight these equations while you are editing them. Most programming  editors, for example, will highlight the matching parentheses or curly braces.  For now, however, you just have to count opening and closing if parentheses (the same way you might in Excel), save your best guess, and check the syntax highlighting for errors.
<center>[[File:em-nested-if-edit-screen.jpg]]</center>

Latest revision as of 02:27, 19 February 2022


これまでの説明の概略

LimeSurveyのマニュアルを理解しているならば、LimeSurvey特有の用語を理解していることになります。続いて、アンケートを強化する方法として、式と変数について説明しました。さらに、構文の強調表示の種類と意味を取り扱い、構文エラーを修正する方法を学びました。

これらの基本的な概念が理解できたら、LimeSurvey内で式がどのように機能するか、例を使って見ていきましょう。


構文強調表示

次のスクリーンショットは実際の表示例ですが、ツールチップの値は表示されません。ツールチップは、太字の色の上にマウスを置くたびに表示される便利なボックスです。

この構文強調表示によって、複雑なものであっても簡単に正しい式を作成することができます。LimeSurveyチームは、式ビルダーGUIの開発を計画していますが、すでに提供されている構文強調表示を使用すれば、タイプミスをすばやく特定し修正することができます。また、ツールチップを使って、式が正しいかを検証することもできます(目的の変数を選択したかを確認するなど)。

それぞれの例には、3つの列があります。

  1. Source - LimeSurveyの質問フィールドに入力する生のテキストです
  2. Pretty Print - 入力したものと同等ですが、構文が強調表示されています
    • この強調表示では、式は黄褐色の背景で表示されますが、中括弧で囲まれていません。
    • EMは再帰的な置換をサポートしているため、強調表示に中括弧を表示すると構文エラーが発生します
  3. Result - EMがソースを処理して生成した結果です
    • 適切に置換できるものすべて
    • エラーのある式はインラインで表示され、構文が強調表示されます。 エラーは赤い線のボックスで囲まれます。


適切な構文

適切な構文の例を以下に示します。

  1. 値: 現在のページでセットされているかに応じて既知の変数が色付きで表示されます。旧式のINSERTANS:xxxxは独自の色分けスタイルになります。
  2. 質問の属性: ドット表記により質問の属性にアクセスできます。
  3. 数学: 基本的な計算だけでなく、複雑な計算もサポートします。
  4. テキスト処理: テキスト処理関数の例
  5. 日付: 日付関連の関数の例
  6. 条件: if()の使い方。入れ子にすることも可能。
  7. 文言調整: 先行する質問の値に応じてレポートをカスタマイズできます。
  8. 文字列中のES処理: 文字列の一部を置換できます。この例では画像の名前を変えることができます。
  9. ESは次のような中括弧を処理しません: 中括弧がエスケープされている場合、式と中括弧の間に空白がある場合、ESは式を無視します。



エラーを含むEM構文

ES式を入力する際の一般的なエラーの例を次に示します。ツールチップによって追加情報が提供されます。

  1. 中括弧の後にスペースを追加し忘れたインラインJavascript
    • "document.write"が中括弧の直後に表示されると、EMはそれを式と見なし、"document"と"write"はそれぞれ未定義の変数と関数と認識され、赤いボックス内に表示されます。
  2. 不明、またはスペルミスのある変数、関数、演算子
    • ここでは、"sex"ではなく"gender"という変数名を誤って使用していても、EMはそのエラーをキャッチします。また、'++'はサポートされている演算子ではないため、赤いボックスで囲まれます。
  3. eqの代わりに=を使用したり、値を代入すると警告されます。
    • '='と'+='は、黒ではなく赤のテキストで表示されています。その上にマウスカーソルを合わせると、値を代入している旨の警告が表示されます。
  4. 関数の引数の数の誤り
    • if()は3つの引数を受け取りますが、4つ与えられているため、赤い枠で囲まれた"if"にカーソルを合わせると、エラーの説明とサポートされている構文が表示されます。
    • sum()は引数の数に制限はありませんが、閉じ括弧の前にコンマがあるため、赤いボックスで囲まれています。
  5. 括弧の不一致
    • これは、式を記述する際の最も一般的なエラーの1つです。
    • ここでは、閉じ括弧が不足している例2つと、閉じ括弧が多すぎる例を示しています。
  6. サポートされていない構文
    • ESがサポートしていない演算子や記号を使用すると、赤いボックスで囲まれます。
  7. 無効な代入
    • 変数には、読み書き可能で値を変更できるもの、読み取り専用のものがあります。
    • 読み取り専用変数の値を変更しようとしてもできません。この場合、EMは赤いボックスで表示します。
    • 式または文字列に値を代入しようとしてもエラーが発生します。



アクティブなツールチップを使用した構文強調表示の"実際に動く"例

ソース整形表示結果
ここでは、ツールチップを使ったOK構文の例を示します。
こんにちは、{if(gender=='M','Mr.','Mrs.')} {surname}。現在、{date('g:i a',time())}です。数を合わせると{sum(numPets,numKids)}になるあなたの子供とペットがどこにいるかわかりますか。
ここでは、ツールチップを使ったOK構文の例を示します。
こんにちは、if(gender == 'M','Mr.','Mrs.') surname。現在、date('g:i a',time())です。数を合わせるとsum(numPets,numKids)になるあなたの子供とペットがどこにいるかわかりますか。
ここでは、ツールチップを使ったOK構文の例を示します。
こんにちは、Mr. Smith。現在、6:07 amです。数を合わせると3になるあなたの子供とペットがどこにいるかわかりますか。
ここでは、一般的なエラーの例を使って、ツールチップを見ることができます。
宣言なしに使用された変数: {notSetYet}
未知の関数: {iff(numPets>numKids,1,2)}
未知の変数: {sum(age,num_pets,numKids)}
引数の数の誤り: {sprintf()},{if(1,2)},{date()}
読み取り専用変数への代入:{TOKEN:ATTRIBUTE_1+=10},{name='Sally'}
括弧の不一致: {pow(3,4},{(pow(3,4)},{pow(3,4))}
ここでは、一般的なエラーの例を使って、ツールチップを見ることができます。
宣言なしに使用された変数: notSetYet
未知の関数: iff(numPets > numKids,1,2)
未知の変数: sum(age,num_pets,numKids)
引数の数の誤り: sprintf(),if(1,2),date()
読み取り専用変数への代入:TOKEN:ATTRIBUTE_1+=10,name='Sally'
括弧の不一致: pow(3,4,(pow(3,4),pow(3,4))
ここでは、一般的なエラーの例を使って、ツールチップを見ることができます。
宣言なしに使用された変数: notSetYet
未知の関数: iff(numPets > numKids,1,2)
未知の変数: sum(age,num_pets,numKids)
引数の数の誤り: sprintf(),if(1,2),date()
読み取り専用変数への代入:TOKEN:ATTRIBUTE_1+=10,name='Sally'
括弧の不一致: pow(3,4,(pow(3,4),pow(3,4))
サポートされていない構文の例を示します。
サポートされていない'++'、'--'、'%'、';': {min(++age, --age,age % 2);}
'|'、'&'、'^': {(sum(2 | 3,3 & 4,5 ^ 6)}}
配列: {name[2], name['mine']}
サポートされていない構文の例を示します。
サポートされていない'++'、'--'、'%'、';': min( ++ age, -- age,age % 2) ;
'|'、'&'、'^': (sum(2 | 3,3 & 4,5 ^ 6)}
配列: name [ 2 ] ,name [ 'mine' ]
サポートされていない構文の例を示します。
サポートされていない'++'、'--'、'%'、';': min( ++ age, -- age,age % 2) ;
'|'、'&'、'^': (sum(2 | 3,3 & 4,5 ^ 6)}
配列: name [ 2 ] ,name [ 'mine' ]


文言調整の例({INSERTANS:xxx}の拡張)

"Dear {Mr}/{Mrs} Smith..."

'Mr.'か'Mrs.'を使い分けるにはif()関数を使用します。

構文は、if(test,do_if_true,do_if_false)となります。

# コード 質問 タイプ
1 gender 性別は? 性別
2 example1 Dear {if(gender=='M','Mr.','Mrs.')} Smith, ... 自由回答(長い)



以下で確認できるように、"性別"に対する回答として回答者が選択したものに合わせ、"Mr"または"Mrs"になるように調整されています。



案内メールにおける"Dear {Mr}/{Mrs} Smith..."

トークンテーブルの属性を使用して、上記の例を案内メールに使用できます。電子メールの中で'Mr.'または'Mrs.'を使い分けるにはif()関数を使用します。


構文は、"if(test,do_if_true,do_if_false)"となります。

# 属性
1 Smith
2 メールアドレス test@test.com
3 ATTRIBUTE_2 M


案内メールのテキストは以下のとおりです。

Dear {if(ATTRIBUTE_2=='M','Mr','Mrs')} {LASTNAME},

あなたはアンケートに招待されました。

https:/...



電子メールは次のようになります。



計算/評価の例

実行時に評価値を計算し、その結果をアンケートデータに格納する

この例では、EMのすべての機能(出現条件、文言調整、式の質問タイプなど)を使用しています。

また、これらのすべてがJavaScript対応であることも示しています。したがって、ページにこれらの機能を導入すると、回答者が回答を設定したり変更したりすると、動的に変化します。

# コード 質問 タイプ 出現条件
1 numKids 子供は何人いますか。 数値入力 1
2 kid1 1人目の子供は何歳ですか。 数値入力 numKids >= 1
3 kid2 2人目の子供は何歳ですか。 数値入力 numKids >= 2
4 kid3 3人目の子供は何歳ですか。 数値入力 numKids >= 3
5 kid4 4人目の子供は何歳ですか。 数値入力 numKids >= 4
6 sumKidAges {sum(kid1.NAOK,kid2.NAOK,kid3.NAOK,kid4.NAOK)} 1
7 kidSummary {if(numKids==1,'子供','子供達')}が{numKids}人いると答えました。{if(numKids>1,implode(' ','最初から',min(numKids,4),'人の子供の年齢の合計は',sumKidAges,'です。'),' ')} テキスト表示 1


この例をダウンロードするには、次のリンクをクリックしてください。 Assessments_survey_example


以下は、代表的な質問のスクリーンショットです。ご覧のとおり、EM構文では、文言調整を含んでいそうなすべてのフィールドが強調表示されます。ここでは、出現条件、式の質問タイプ、および質問内の置換の例を示します。ヘルプ、グループヘッダーの表示、ようこそメッセージ、および終了メッセージ内で置き換えることもできます。

次の例では、出現条件は{numKids >= 2}であるため、回答者が少なくとも2人の子供がいると回答した場合にのみ表示されます。



また、各変数に.NAOK接尾辞を使用することに注意してください。これは、EMが入れ子の出現条件を実現するためのものです。もし.NAOKをつけない場合、4人の子供を持っていると回答した場合にのみ合計が計算されることになります(すべての変数が真の場合)。.NAOKを使用すると、変数のすべてまたは一部が偽であっても合計を計算することを意味します(すなわち"該当なし"(Not Applicable - NA)でも構わないということです)。

ただし、.NAOK属性は変数がEMに渡されるかどうかにのみ影響します。例えば、その人が最初に3人の子供がいると回答し、それぞれの年齢を入力した後、気が変わり、2人であると答えた場合、3人目の子供はもはや無関係なので、3つの入力値の合計は必要ありません。



それぞれの式は、黄褐色の背景で色分けされています。ご覧の通り、3つの別々の式があります。最後の式には、2人以上の子供がいる場合にのみ表示されるメッセージが入っています。



ここでは、実際のアンケートのスクリーンショットを示します。

最初にページにアクセスすると、これが表示されます。"0人の子どもがいます"ではなく、"0人の子どもたちがいます"となっていることに注意してください。



子どもの数を1に変更すると、同じページ上にあってもこのように表示が即座に変わります。



文法は正しいものになっています。 "You have 1 child".

今度は、子供の数の値を3に変更し、即座に表示を変更します。

次の条件付きメッセージが下部に表示されていることに注目してください。"The sum of ages of your first 3 kids is 0.(最初の3人の子供の年齢の合計は0です。)"



今、子供の年齢を入力し、その年齢を合計して、このように表示させるとします。



値を入力するとスコアと表示が即座に更新されるため、これを使用して評価スコアの合計を表示することができます。


今度は、子供の数を2に変更します。表示は次のように変わります。



3番目の子供には5.5の値を入力しましたが、レポートには最初の2人の子供の値が合計されるようになりました。

その理由は、第3の値は出現条件を満たさなくなり、EMはそのような値を無視するからです。

子供の数を3に戻すと、再び5.5という値が見えます。これにより、ページに入力した情報を失うことはありません。

ただし、次または前のページに移動すると、出現条件を満たさない値はすべてセッション内およびデータベース内でNULLになります。もし、子供の数を2と設定したまま次のページに行き、もとのページに戻り、実は3人の子供がいると回答すると、5.5という年齢を見ることはありません。


データを入力し、同じページ内で入力されたものが動的に変化するレポートを表示する

この例は、LimeSurvey内の文言調整プロセスを示します。

この例をダウンロードするには、下記のリンクをクリックします。 動的に変化するアンケートの例

これは、ページが最初にどのように見えるかを示しています。どの都市に住んでいるのか尋ねる質問だけがあります。



回答を入力し始めると、文言調整プロセスも開始されます。


回答を入力すると、ページの下部にある表が更新され、回答コードと回答の値が表示されます。


一般的なデバッグの例

ネストされたif()ステートメント(条件付きロジック)

EMは、条件付きロジックまたは文言調整を実行できるよう、関数"if(test,do_if_true,do_if_false)"をサポートしています。この関数は、"if { } else if { } else { }"と同等の処理を行うために入れ子にすることができます。EMは、括弧の数が合わないかどうかを通知します(たとえば、右括弧が消えているなど)か、または余計な右括弧があるかどうかを通知します。長く入れ子になったif文を作成し、保存し、構文エラーをチェックし、見つかった場合は修正してください。以下の例を一緒にチェックしてみましょう。

以下の質問のグループは、ここからアクセスできます。Tailoring survey example.lsg


まず何も入力していないときは、単に"Hello."と表示されます。



名前を入力すると、"Hello {name}."となります。



年齢を入力すると、就学前の子供であるかどうかに応じて調整されたメッセージが届きます。



学齢児童、10代の人、または大人。ここに匿名希望の10代の人がいます。



ここにグループのロジックファイルがあります。 "if-based"の質問に見られるように、年齢に基づいて入れ子になったif文があります。



名前を入力すると、"Hello {name}."となります。



赤いボックスで囲まれた"if"という言葉にカーソルを合わせると、"括弧の数が合わない"と表示されます。この例では、"already an adult!"の後ろに4つの閉じ括弧があるはずですが、3つしかありません。

一方、余分な右かっこがある場合、次のように赤い枠で囲まれます。



実際に質問を編集しているときは、次のようになります。