# How to configure automatic shaping criteria

Although a user can manually adjust the current SBT and CAB branch target levels
of the student through the skill-based treatment **CONFIG** view, ABAKadabra
will also automatically adjust the current SBT and CAB branch target levels
after each **EO trial** based on configurable **progression and regression
automation expressions**. The default progression and regression automation
expressions are typically adequate for many students, but since skill-based
treatment is not a one-size-fits-all treatment, you can configure the
progression and regression expressions for each step of the skill-based
treatment to match a student's specific needs.

The progression and regression automation expressions can be configured through
the skill-based treatment configuration forms,
just like any other skill-based treatment value. The expressions related to
**sFCR** through **CAB2** are in the respective **Advanced options**
drop-downs in the **Modify skill based treatment** form, and the expressions
related to **CAB2** through **CAB6** for each CAB branch are in the respective
**Advanced options** drop-downs in each **Modify CAB branches** form. Each
progression expression is named **{level} is complete**
(e.g. "sFCR is complete"), and each regression expression is named **{level}
is regress** (e.g. "cFCR is regress").

Each expression is a Lua expression that returns a **Boolean value** (true or
false), and has access to previous student results through the SBT Lua
programming API.

## Automatic shaping procedure

After each **EO trial** is completed in a skill-based treatment session,
ABAKadabra completes the following procedures, first for the overall SBT level
(sFCR - CAB2), and then for the specific CAB branch (CAB2 - CAB6):

- The progression expression for the
current SBT level is evaluated. If the expression evaluates to
**true**(meaning that the student is ready to progress to the next level), then the current SBT level is automatically set to the next SBT level. If the expression evaluates to**false**(meaning that the student is NOT ready to progress to the next level), then go to step 2. - The regression expression for the current SBT level is evaluated. If the
expression evaluates to
**true**(meaning the student should regress to the previous level), then the current SBT level is automatically set to the previous SBT level. If the expression evaluates to**false**(meaning the student should NOT regress to the previous level), then the current SBT level for the student remains unchanged.

## Example - configuring progression from cFCR to TR

For this example, we will consider the automatic progression from cFCR to TR.
First, let's examine the default expression: **cFCR is complete**.

```
(eo_trial_results("cfcr", "cab6", 3, "ANY").success_trials_count >= 3) or
((eo_trial_results("cfcr", "cfcr", 3, "ANY").success_trials_count >= 3) and
(eo_trial_results("cfcr", "cfcr", 10, "ANY").success_trials_percent >= 0.8))
```

This expression looks like a lot, but let's first understand what it is saying in English.

The student is ready to progress from cFCR to TR if:

there were at least three (3) trials targeting anything from cFCR to CAB6 and the last three (3) of those trials were successful, ORthere were at least three (3) trials targeting cFCR and the last three (3) of those trials were successful AND the last ten (10) cFCR trials had a success rate of at least 80%.

Now that we know what the expression is meant to accomplish, let's break it down into smaller pieces to get a better idea of what is going on.

```
eo_trial_results(
"cfcr", -- include any trial with a goal greater than or equal to cFCR
"cab6", -- include any trial with a goal less than or equal to CAB6
3, -- only examine the last 3 results
"ANY" -- include results from any CAB branch
).success_trials_count -- return the number of the EO trials that were successful
```

The first part of the expression gathers the last 3 EO trial results where the
goal is anything from **cFCR** to **CAB6** (basically only excludes **sFCR**
trials). From these results, return the number of the trials that were
successful (all steps were completed independently without any problem
behavior).

```
eo_trial_results(
"cfcr", -- include any trial with a goal greater than or equal to cFCR
"cfcr", -- include any trial with a goal less than or equal to cFCR
3, -- only examine the last 3 results
"ANY" -- include results from any CAB branch
).success_trials_count -- return the number of the EO trials that were successful
```

The second part of the expression gathers the last 3 EO trial results where the
goal is only **cFCR**. From these results, return the number of the trials
that were successful (all steps were completed independently without any
problem behavior).

```
eo_trial_results(
"cfcr", -- include any trial with a goal greater than or equal to cFCR
"cfcr", -- include any trial with a goal less than or equal to cFCR
10, -- only examine the last 10 results
"ANY" -- include results from any CAB branch
).success_trials_percent -- return the percent (0-1) of the EO trials that were successful
```

The third part of the expression gathers the last 10 EO trial results where the
goal is only **cFCR**. From these results, return the percent of the trials
that were successful (all steps were completed independently without any
problem behavior) as a decimal value between 0 and 1.

Now that we understand the default expression, let's update the expression to require at least 4 successful consecutive cFCR trials before continuing to TR.

```
(eo_trial_results("cfcr", "cab6", 4, "ANY").success_trials_count >= 4) or
((eo_trial_results("cfcr", "cfcr", 4, "ANY").success_trials_count >= 4) and
(eo_trial_results("cfcr", "cfcr", 10, "ANY").success_trials_percent >= 0.8))
```

That's all there is to it! If you would like to configure a more complex expression, see the SBT Lua programming API reference documentation for more details.

## Example - configuring regression from TR to cFCR

For this example, we will consider the automatic regression from TR to cFCR.
First, let's examine the default expression: **TR is regress**.

```
eo_trial_results("cfcr", "tr", 4).r1_trials_count >= 4
```

In English, this expression says:

The student should regress from TR to cFCR if there were at least four (4) trials targeting anything from cFCR to TR and the last four (4) of those trials had at least one (1) R1 behavior.

Let's update the expression to never regress the student back from TR to cFCR.
For this functionality, we can simply set the expression to `false`

.