Jump to content

Help:RiskDisplay: Difference between revisions

From RiskiPedia
Short note on why UI text is best done in the RiskModel
No edit summary
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. For simple cases or debugging, it can use a direct calculation or custom text. See [[Help:RiskModel|RiskModel documentation]] for details on calculations and text formatting.
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 requires one of these attributes:
The <riskdisplay> tag has one optional attribute:


* `model`: The name of a risk model defined by a <riskmodel> tag (preferred method).
* `model`: The name of a risk model defined by a <riskmodel> tag
* `calculation`: A mathematical expression, for simple cases or debugging.
 
Use either `model` or `calculation`, not both. Optional text inside the tag overrides the riskmodel's text.


Basic syntax:
Basic syntax:
Line 19: Line 16:
Or with a direct calculation:
Or with a direct calculation:
<pre><nowiki>
<pre><nowiki>
<riskdisplay calculation="base_probability * exposure_factor">Your risk is about {result}%</riskdisplay>
<riskdisplay calculation="">Your risk is about {{#expr: {base_probability} * {exposure_factor} }}%</riskdisplay>
</nowiki></pre>
</nowiki></pre>



Revision as of 19:32, 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 calculation="">Your risk is about {{#expr: {base_probability} * {exposure_factor} }}%</riskdisplay>

Usage

  1. 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.
  2. For simple cases or debugging, use the `calculation` attribute or include text inside the tag to override the model’s description. See RiskModel documentation for calculation and 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|{result}}}</riskdisplay>

This computes a result and displays it as "1 in X" (e.g., "1 in 10" for 0.1).

Overriding Model Text

Override the model’s description with custom text:

<riskdisplay model="RiskScore">The weighted risk score is '''{result}''' points</riskdisplay>

This uses the "RiskScore" model’s calculation but displays the result with custom text.

Debugging with Detailed Text

Display raw and formatted results along with a variable for debugging:

<riskdisplay model="AccidentRisk">Raw probability: {result}
Human-friendly probability: {{One_In_N|{result}}}
Odds-ratio: {distraction_odds_ratio}</riskdisplay>

This uses the "AccidentRisk" model’s calculation, showing the raw `{result}`, a human-friendly version via {{One_In_N}}, and the `distraction_odds_ratio` variable.

Notes

  • The `model` attribute is the preferred method, referencing a <riskmodel> typically defined on a "/Data" subpage.
  • Use `calculation` or text inside the tag only for simple cases or debugging.
  • Models can be defined on the current page or a "/Data" subpage.
  • Text formatting, including templates like {{One_In_N|{result}}}, is described in RiskModel documentation.

Troubleshooting

  • **Error: "riskdisplay: missing model= or calculation="** – Include either the `model` or `calculation` attribute.
  • **Error: "riskdisplay: specify either model or calculation, not both"** – Use only one of `model` or `calculation`.
  • **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.