Actions

ExpressionScript How-tos/ja: Difference between revisions

From LimeSurvey Manual

(Created page with "=はじめに=")
No edit summary
 
(177 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<languages />
__TOC__
__TOC__




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


LimeSurvey uses the new Expression Manager (EM) module which lets LimeSurvey support more complex branching, assessments, validation, and tailoring. It replaces how LimeSurvey manages Replacements, [[Setting conditions|Conditions]], and [[Assessments]] on the back-end. It also speeds up processing considerably since it eliminates most run-time database reads.


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|構文の強調表示]]の種類と意味を取り扱い、構文エラーを修正する方法を学びました。


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




#'''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 expression content is evaluated by EM, so it can contain mathematical formulas, functions, and complex string and date processing.
#'''Tailoring''': Sometimes called "piping". It 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 visibility:
#*If there is a relevance equation, then the question is only shown if the relevance evaluates to true.
#*Internally, all [[QS:Array_filter|array_filter]] and [[QS:Array_filter_exclude|array_filter_exclude]] commands become subquestion-level relevance.
#'''SGQA''':  This is how variables are named in LimeSurvey <= 1.91+
#*Stands for Survey-Group-Question-Answer
#*SGQA variable names look like 123X5X382X971, and may have sub-question suffixes.
#*These variable names are specific to the underlying S/Q/G/A database codes, so often need to be changed
#'''Equation''' Question Type: [[Question type - Equation|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:
#*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".
#*This is what becomes the variable name if you export data to SPSS or R. So, if you do statistical analysis, you need to create only unique question codes.




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


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


To help with entering and validating expressions, EM provides syntax highlighting with the following features:
それぞれの例には、3つの列があります。
#Source - LimeSurveyの質問フィールドに入力する生のテキストです
#Pretty Print - 入力したものと同等ですが、構文が強調表示されています
#*この強調表示では、式は黄褐色の背景で表示されますが、中括弧で囲まれていません。
#*EMは再帰的な置換をサポートしているため、強調表示に中括弧を表示すると構文エラーが発生します
#Result - EMがソースを処理して生成した結果です
#*適切に置換できるものすべて
#*エラーのある式はインラインで表示され、構文が強調表示されます。 エラーは赤い線のボックスで囲まれます。




==Types and Meanings of Syntax Highlighting==
===適切な構文===




{|
適切な構文の例を以下に示します。
|Color||Sample||Meaning||Tooltip||Comments
#: 現在のページでセットされているかに応じて既知の変数が色付きで表示されます。旧式のINSERTANS:xxxxは独自の色分けスタイルになります。
|-
#質問の属性: ドット表記により質問の属性にアクセスできます。
|tan background||<span style='background:#eee8aa'>Sample</span>||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
#数学: 基本的な計算だけでなく、複雑な計算もサポートします。
|-
#テキスト処理: テキスト処理関数の例
|blue bold text||'''<span style='color:blue;background:#eee8aa'>Sample</span>'''||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.
#日付: 日付関連の関数の例
|-
#条件: if()の使い方。入れ子にすることも可能。
|grey text||<span style='color:grey'>'Sample'</span>||string||none||single and double-quoted strings are shown in grey text
#文言調整: 先行する質問の値に応じてレポートをカスタマイズできます。
|-
#文字列中のES処理: 文字列の一部を置換できます。この例では画像の名前を変えることができます。
|bold maroon text||'''<span style='color:maroon;background:#eee8aa'>Sample</span>'''||variable set on the same page, but after the current question||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on the same page but after the current question is shown in bold maroon text.  This color coding should alert authors to possible errors in question sequencing; but it is allowed since some authors may want this sequence of variables a page, especially for dynamic reports.  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.
#ESは次のような中括弧を処理しません: 中括弧がエスケープされている場合、式と中括弧の間に空白がある場合、ESは式を無視します。
|-
|bold cyan text||'''<span style='color:#4C88BE;background:#eee8aa'>Sample</span>'''||variable set on the same page, prior to the current question||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on the same page and prior to the current question is shown in bold cyan 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.
|-
|bold green text||'''<span style='color:green;background:#eee8aa'>Sample</span>'''||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 pageis 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.
|-
|bold pink text||'''<span style='color:#FF00FF;background:#eee8aa'>Sample</span>'''||variable set on a later page||<nowiki>[</nowiki>name or SGQA code]: question; value; answerList showing codes for each value||Any variable that is set on a prior pageis shown in bold pink text.  These are erorrs since the variable is  being used before it is declareed.  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.
|-
|bold tan text||'''<span style='color:#996600;background:#eee8aa'>Sample</span>'''||a lime relacement value||the value||Lime Replacement Strings (like {TOKEN:xxx}, {PRIVACY_MESSAGE} are shown in bold tan text.  The tooltip shows the current value.
|-
|red text||'''<span style='color:red,#eee8aa;background:#eee8aa'>Sample</span>'''||assignment operators||warning message||If you use one of the assignment operators (=,+=,-=,*=,/=), 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.
|-
|normal black text||<span style='color:black;background:#eee8aa'>Sample</span>||punctuation||none||All other punctionation within the expression is shown as normal black text.
|-
|red-boxed text||<span style='background-color: #eee8aa;'><span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'>Sample</span></span>||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.
|-
|
|}


{{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)}}


==Examples==
<center>[[File:em-syntax-highlighting-1-v2.jpg]]</center>


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.


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).
===エラーを含むEM構文===


In each of the examples, there are three columns:
#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.


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


Here are examples of proper syntax:
#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
#Question Attributes: shows that dot notation can access some properties of questions
#Math: shows that basic and complex calculations are supported
#TextProcessing: shows some of the available text-processing functions
#Dates: shows two of the available date-related functions
#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.
#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.
<nowiki>**</nowiki>This is critical for embedding custom JavaScript.


[[File:em-syntax-highlighting-1-v2.jpg]]
<center>[[File:em-syntax-highlighting-errors-v2.jpg]]</center>


===EM Syntax Containing Errors===


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>


=Tailoring Examples (e.g. extending {INSERTANS:xxx}=
 
=文言調整の例({INSERTANS:xxx}の拡張)=
 


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


Use the if() function to conditionally choose whether to display 'Mr.' or 'Mrs.'.


The syntax is if(test,do_if_true,do_if_false).
'Mr.'か'Mrs.'を使い分けるにはif()関数を使用します。
 
構文は、if(test,do_if_true,do_if_false)となります。


{|
{|
|#||Code||Question||Type
|#||コード||質問||タイプ
|-
|1||gender||What is your gender?||Gender
|-
|-
|2||example1||Dear {if(gender=='M','Mr.','Mrs.')} Smith, ...||Text display
|1||gender||性別は?||性別
|-
|-
|
|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..." in invitation email==


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


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


{|
{|
|#||attribute||value
|#||属性||
|-
|-
|-||Last name||Smith
|1||||Smith
|-
|-
|-||Email address||test@test.com
|2||メールアドレス||test@test.com
|-
|-
|-||ATTRIBUTE_2||M
|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>


[[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.
<center>[[File:emEx1mailview.jpg]]</center>


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です。)"
 


[[File:em-tailoring2-q-kid2.jpg]]
</center>[[File:em-tailoring2-s-3kids.jpg]]</center>


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.


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.


[[File:em-tailoring2-q-sumKidAges.jpg]]
<center>[[File:em-tailoring2-s-3kids-sum.jpg]]</center>


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.


[[File:em-tailoring2-q-kidSummary.jpg]]
値を入力するとスコアと表示が即座に更新されるため、これを使用して評価スコアの合計を表示することができます。


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'''".
今度は、子供の数を2に変更します。表示は次のように変わります。


[[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.
<center>[[File:em-tailoring2-s-2kids-sum.jpg]]</center>


Now notice that the grammar is correct, is says, "You have 1 '''child'''".


[[File:em-tailoring2-s-1kid.jpg]]
3番目の子供には5.5の値を入力しましたが、レポートには最初の2人の子供の値が合計されるようになりました。


Now I change the value for number of children to 3, and the display instantly changes to this.
その理由は、第3の値は出現条件を満たさなくなり、EMはそのような値を無視するからです。


Notice that you now see the conditional message at the bottom:  "The sum of ages of your first 3 kids is 0.".
子供の数を3に戻すと、再び5.5という値が見えます。これにより、ページに入力した情報を失うことはありません。


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


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.
==データを入力し、同じページ内で入力されたものが動的に変化するレポートを表示する==


[[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.
この例は、LimeSurvey内の文言調整プロセスを示します。


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.
この例をダウンロードするには、下記のリンクをクリックします。 [[Media:Dynamic_change_of_the_report_when_data_is_entered_on_the_same_page_survey.zip|動的に変化するアンケートの例]]


The reason for this is that the 3rd value is now irrelevant, and irrelevant values are actively ignored by EM.
これは、ページが最初にどのように見えるかを示しています。どの都市に住んでいるのか尋ねる質問だけがあります。


[[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.
<center>[[File:em-on_page_report-usage-1.jpg]]</center>


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.


==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.
<center>[[File:em-on_page_report-usage-2.jpg]]</center>


Rather than summarizing the questions as a table, the actual LimeSurvey group file is attached so you can try it yourself.


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]]


Once you start to enter an answer, the rest of the questions appear.
<center>[[File:em-on_page_report-usage-3.jpg]]</center>


[[File:em-on_page_report-usage-2.jpg]]
=一般的なデバッグの例=


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]]
==ネストされたif()ステートメント(条件付きロジック)==


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


=Common Debugging Examples=
以下の質問のグループは、ここからアクセスできます。[[Media:Example_tailoring_group11.zip|Tailoring survey example.lsg]]


==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:
まず何も入力していないときは、単に"Hello."と表示されます。


Here is the group file for these examples:


[[Media:limesurvey_group_33.lsg|limesurvey_group_33.lsg]]
<center>[[File:em-nested-if-blank.jpg]]</center>


First, with nothing entered, you just see "Hello."


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


If you enter a name, it says, "Hello {name}."


[[File:em-nested-if-name.jpg]]
<center>[[File:em-nested-if-name.jpg]]</center>
 
 
年齢を入力すると、就学前の子供であるかどうかに応じて調整されたメッセージが届きます。
 
 
<center>[[File:em-nested-if-toddler.jpg]]</center>
 
 
学齢児童、10代の人、または大人。ここに匿名希望の10代の人がいます。
 
 
<center>[[File:em-nested-if-teenager.jpg]]</center>
 
 
ここにグループのロジックファイルがあります。 "if-based"の質問に見られるように、年齢に基づいて入れ子になったif文があります。
 


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つしかありません。

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



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