Help:RiskDisplay: Difference between revisions
m Tweaked wording |
Use #expr instead of calculation/result |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Help:RiskDisplay = | = Help:RiskDisplay = | ||
The <riskdisplay> tag displays the result of a risk model defined by a [[Help:RiskModel|RiskModel]], typically stored on a "/Data" subpage with related [[Help:RiskData|RiskData]] tables | The <riskdisplay> tag displays the result of a risk model defined by a [[Help:RiskModel|RiskModel]], typically stored on a "/Data" subpage with related [[Help:RiskData|RiskData]] tables. | ||
RiskDisplays are put on pages with [[Help:DropDown|DropDown]] or [[Help:RiskParameter|RiskParameter]] UI elements to allow users to choose different variables that affect the risk calculation(s). | RiskDisplays are put on pages with [[Help:DropDown|DropDown]] or [[Help:RiskParameter|RiskParameter]] UI elements to allow users to choose different variables that affect the risk calculation(s). | ||
== Syntax == | == Syntax == | ||
The <riskdisplay> tag | The <riskdisplay> tag has one optional attribute: | ||
* `model`: The name of a risk model defined by a <riskmodel> tag | * `model`: The name of a risk model defined by a <riskmodel> tag | ||
Basic syntax: | Basic syntax: | ||
Line 19: | Line 16: | ||
Or with a direct calculation: | Or with a direct calculation: | ||
<pre><nowiki> | <pre><nowiki> | ||
<riskdisplay | <riskdisplay>Your risk is about {{#expr: {base_probability} * {exposure_factor} }}%</riskdisplay> | ||
</nowiki></pre> | </nowiki></pre> | ||
== Usage == | == Usage == | ||
# For most cases, use the <riskdisplay> tag with the `model` attribute to reference a <riskmodel>, typically defined on a "/Data" subpage with related RiskData tables. This uses the model’s calculation and | # For most cases, use the <riskdisplay> tag with the `model` attribute to reference a <riskmodel>, typically defined on a "/Data" subpage with related RiskData tables. This uses the model’s calculation and text to be presented to the user. It is best to keep the text with the RiskModel, in case the RiskModel is changed. | ||
# For simple cases or debugging, | # For simple cases or debugging, include text inside the tag to override the model’s text. See [[Help:RiskModel|RiskModel documentation]] for text formatting details. | ||
== Examples == | == Examples == | ||
Line 39: | Line 36: | ||
Define a calculation for a simple case or debugging: | Define a calculation for a simple case or debugging: | ||
<pre><nowiki> | <pre><nowiki> | ||
<riskdisplay calculation="base_probability * exposure_factor">Your risk is {{One_In_N|{ | <riskdisplay calculation="base_probability * exposure_factor">Your risk is {{One_In_N|{{#expr: {base_probability}*{exposure_factor} }} }}</riskdisplay> | ||
</nowiki></pre> | </nowiki></pre> | ||
This computes a result and displays it as "1 in X" (e.g., "1 in 10" for 0.1). | This computes a result and displays it as "1 in X" (e.g., "1 in 10" for 0.1). | ||
=== Debugging with Detailed Text === | === Debugging with Detailed Text === | ||
Display raw and formatted results along with a variable for debugging: | Display raw and formatted results along with a variable for debugging: | ||
<pre><nowiki> | <pre><nowiki> | ||
<riskdisplay | <riskdisplay>Raw probability: {{#expr: {base_probability}*{exposure_factor} }} | ||
Human-friendly probability: {{One_In_N|{ | Human-friendly probability: {{One_In_N|{{#expr: {base_probability}*{exposure_factor} }} }} | ||
</riskdisplay> | |||
<riskdisplay>Base probability: {base_probability}</riskdisplay> | |||
<riskdisplay>Exposure factor: {exposure_factor}</riskdisplay> | |||
</nowiki></pre> | </nowiki></pre> | ||
== Notes == | == Notes == | ||
* The `model` attribute is the preferred method, referencing a <riskmodel> typically defined on a "/Data" subpage. | * The `model` attribute is the preferred method, referencing a <riskmodel> typically defined on a "/Data" subpage. | ||
* Models can be defined on the current page or a "/Data" subpage. | * Models can be defined on the current page or a "/Data" subpage. | ||
* Text formatting, including templates like <nowiki>{{One_In_N | * Text formatting, including templates like <nowiki>{{One_In_N...}}</nowiki>, is described in [[Help:RiskModel|RiskModel documentation]]. | ||
== Troubleshooting == | == Troubleshooting == | ||
* **Error: "riskdisplay: can't find riskmodel named X"** – Ensure the `model` name matches a <riskmodel> on the current page or a "/Data" subpage. | * **Error: "riskdisplay: can't find riskmodel named X"** – Ensure the `model` name matches a <riskmodel> on the current page or a "/Data" subpage. | ||
* **Result not displayed** – Check that the referenced model has a valid description, or if overriding, ensure the text includes the `{result}` placeholder. See [[Help:RiskModel|RiskModel documentation]] for details. | * **Result not displayed** – Check that the referenced model has a valid description, or if overriding, ensure the text includes the `{result}` placeholder. See [[Help:RiskModel|RiskModel documentation]] for details. | ||
For related features, see [[Help:RiskModel|RiskModel documentation]] or [[Help:RiskData|RiskData documentation]]. | For related features, see [[Help:RiskModel|RiskModel documentation]] or [[Help:RiskData|RiskData documentation]]. |
Latest revision as of 20:59, 17 September 2025
Help:RiskDisplay
The <riskdisplay> tag displays the result of a risk model defined by a RiskModel, typically stored on a "/Data" subpage with related RiskData tables.
RiskDisplays are put on pages with DropDown or RiskParameter UI elements to allow users to choose different variables that affect the risk calculation(s).
Syntax
The <riskdisplay> tag has one optional attribute:
- `model`: The name of a risk model defined by a <riskmodel> tag
Basic syntax:
<riskdisplay model="heart_attack_risk" />
Or with a direct calculation:
<riskdisplay>Your risk is about {{#expr: {base_probability} * {exposure_factor} }}%</riskdisplay>
Usage
- For most cases, use the <riskdisplay> tag with the `model` attribute to reference a <riskmodel>, typically defined on a "/Data" subpage with related RiskData tables. This uses the model’s calculation and text to be presented to the user. It is best to keep the text with the RiskModel, in case the RiskModel is changed.
- For simple cases or debugging, include text inside the tag to override the model’s text. See RiskModel documentation for text formatting details.
Examples
Using a Risk Model
Display the result of a risk model named "heart_attack_risk":
<riskdisplay model="heart_attack_risk" />
This uses the calculation and description from the "heart_attack_risk" <riskmodel>, typically defined on a "/Data" subpage.
Using a Direct Calculation
Define a calculation for a simple case or debugging:
<riskdisplay calculation="base_probability * exposure_factor">Your risk is {{One_In_N|{{#expr: {base_probability}*{exposure_factor} }} }}</riskdisplay>
This computes a result and displays it as "1 in X" (e.g., "1 in 10" for 0.1).
Debugging with Detailed Text
Display raw and formatted results along with a variable for debugging:
<riskdisplay>Raw probability: {{#expr: {base_probability}*{exposure_factor} }} Human-friendly probability: {{One_In_N|{{#expr: {base_probability}*{exposure_factor} }} }} </riskdisplay> <riskdisplay>Base probability: {base_probability}</riskdisplay> <riskdisplay>Exposure factor: {exposure_factor}</riskdisplay>
Notes
- The `model` attribute is the preferred method, referencing a <riskmodel> typically defined on a "/Data" subpage.
- Models can be defined on the current page or a "/Data" subpage.
- Text formatting, including templates like {{One_In_N...}}, is described in RiskModel documentation.
Troubleshooting
- **Error: "riskdisplay: can't find riskmodel named X"** – Ensure the `model` name matches a <riskmodel> on the current page or a "/Data" subpage.
- **Result not displayed** – Check that the referenced model has a valid description, or if overriding, ensure the text includes the `{result}` placeholder. See RiskModel documentation for details.
For related features, see RiskModel documentation or RiskData documentation.