# Skill-based treatment Lua programming API

Each automation expression in the SBT web app accepts any valid Lua expression as long as the expression can be fully run within the following computational limits:

**Runtime limit**- 500ms**Memory limit**- 1MB

## Types

`cab_type`

- One of`'sfcr'`

,`'cfcr'`

,`'tr'`

,`'cab1'`

,`'cab2'`

,`'cab3'`

,`'cab4'`

,`'cab5'`

or`'cab6'`

.

## Functions

`eo_trial_results(start, end, trials_count, cab_branch_id?)`

Returns a table of aggregated results of EO trials. For example, calling this
function with a start of `'cfcr'`

and an end of `'cab1'`

will consider only the
EO trials with a final target of `'cfcr'`

, `'tr'`

, and `'cab1'`

even if other
EO trials include those CABs (such as `'cab1'`

).

This function is useful when examining EO trials as a full unit. For example, this function is useful for determining the when to advance or regress the current target levels of the student.

#### Parameters

Name | Type | Description |
---|---|---|

`start` | `cab_type` | The starting level of the final CAB in the EO trial to consider. |

`end` | `cab_type` | The ending level of the final CAB in the EO trial to consider. |

`trials_count` | `number` | The number of previous relevant trials to consider. |

`cab_branch_id` | `cab_branch_id` or `'ANY'` | The CAB branch to consider. Defaults to current CAB branch. `'ANY'` considers all CAB branches for the student. |

#### Result

Name | Type | Description |
---|---|---|

`total_r1_count` | `number` | The total number of R1 occurrences. |

`r1_trials_count` | `number` | The number of trials where at least one R1 occurred. |

`r1_trials_percent` | `number` | The percent of trials where at least one R1 occurred (decimal number between 0-1) |

`total_r2_count` | `number` | The total number of R2 occurrences. |

`r2_trials_count` | `number` | The number of trials where at least one R2 occurred. |

`r2_trials_percent` | `number` | The percent of trials where at least one R2 occurred (decimal number between 0-1). |

`success_trials_count` | `number` | The number of trials that were successful (terminal CAB occurred with no prompting, R1, or R2). |

`success_trials_percent` | `number` | The percent of trials that were successful (terminal CAB occurred with no prompting, R1, or R2) (decimal number between 0-1). |

`terminal_independent_trials_count` | `number` | The number of trials where the terminal CAB occurred independently. |

`all_independent_trials_count` | `number` | The number of trials where all the CABs occurred independently. |

`trials_count` | `number` | The total number of trials considered. This number will be less than the provided trials_count parameter if the number of relevant results is less than the provided trials_count parameter. |

`cab_type_to_cfcr_level(cab_type)`

Returns a number level version of a `cab_type`

. Useful for using a CAB type in
a math expression.

#### Parameters

Name | Type | Description |
---|---|---|

`cab_type` | `cab_type` | The CAB type to convert to a number |

#### Result

From | To |
---|---|

`'sfcr'` | 0 |

`'cfcr'` | 1 |

`'tr'` | 2 |

`'cab1'` | 3 |

`'cab2'` | 4 |

`'cab3'` | 5 |

`'cab4'` | 6 |

`'cab5'` | 7 |

`'cab6'` | 8 |

`otherwise` | 0 |

`sbt_level()`

Returns the SBT level (`cab_type`

) of the EO trial.

`cab_branch_id()`

Returns the CAB branch ID of the EO trial.