# Updating Learner Stages

### Introduction

When publishing a new curriculum version within the CBME module, learners will automatically be updated to have the new curriculum version (i.e., EPAs marked as “replaced” or “changing”) for all of their upcoming stages of training.  There may be a time where you would like certain learners to have stages from a specific version.  This guide will instruct you on how to properly update a learner or series of learners to have stages from a specific version.

### What you will need

In order to update the learner(s) objectives in a timely manner there are a few things to gather before you begin the process:

1\.     Assemble a list of proxy\_ids for all of the learners that you wish to update.  This process is done on a per course basis so make sure that all of the learner proxy\_ids that you compile belong to the same course.

2\.     Make note of the stages that you wish to be updated.  The script requires the stage letter in order to know which stages to update, so make a list of the stage letters.  For example, if you are updating a learner to have an old version of Transition to Discipline (D) then you will need to note D as the stage you are updating.

3\.     The final thing you will need is the cbme\_objective\_tree\_version\_id for the version that you wish to update to.  So if the course you are updating is course\_id 123 and you would like to update a learner to version 2 for a stage then you need to look up the cbme\_objective\_tree\_version\_id for course 123 version 2 in the cbme\_objective\_tree\_versions table. \
&#x20;You will also need the cbme\_objective\_tree\_version\_id for the version that the learner is already a part of.  The script requires that you set the version for every stage available to the learner which is why we need the current versions.

4\.     Access to the database

5\.     SSH access to your production environment

### Updating the learner stages

Updating the learner stages requires a developer tool to be run from developers/tools/cbme\_migration.  You must have SSH access to your production server in order to complete these steps.  **Please Note:** It’s recommended that you go through the following steps in a test/staging/development environment first so that you can ensure that the script updated the learners properly.

Steps:

1\.     Open up your database client and open the cbme\_objective\_tree\_aggregates table.

2\.     For every learner proxy\_id that you compiled ahead of time we will be deleting their cbme\_objective\_tree\_aggregate records **for the course that we are updating.** Select all of the rows where tree\_viewer\_value is the proxy\_id that we are dealing with, the tree\_viewer\_type is “proxy\_id” and the course\_id matches the course that we are using.  Once you have all of that data, we are going to DELETE it from the table.  Repeat this until we have deleted the aggregates for every learner in the list.

3\.     Now that the aggregates are deleted, we can update the learners’ stages using the script.  SSH into your server and navigate to the following directory:\
&#x20;/var/www/vhosts/your installation name here/developers/tools/cbme\_migration

4\.     Once in that directory we are going to be executing the reset-learner-tree-version.php script. **Tip:** if you run php reset-learner-tree-version.php --usage it will bring up the help dialogue to describe all of the options that are available.\
&#x20;Once you have read through all of the available options you will notice that there are multiple modes that this script can be run in. For this scenario we will be using **“specify”** mode since we want to specify which version of stages the learners will be receiving.  We must specify **all** stages in the --stages parameter so that the script updates them to the correct version.

\
&#x20;As an example, if your data is this:

* organisation\_id = 1
* course\_id = 123
* proxy\_ids = 1111,2222,3333,4444
* stages to update = C,P
* current version id = 10
* new version id = 20

The command will look like this:

```
php reset-learner-tree-version.php --mode=specify 
--course_id=123 --organisation_id=1 
--proxy_ids=1111,2222,3333,4444 --stages=D,F,C,P 
--versions=10,10,20,20
```

**We do not need to provide the --exclude parameter in this case**

You will notice with the command above that we have listed all 4 stages in the --stages parameter even though we are only updating C and P.  The reason for this is because the script requires that all stages be **specified** in order to update them to the correct version.  In this case we are not changing D and F so we set them as the original version (10) in the script parameters.  Each stage corresponds with a version in the --versions parameter, so in this case D will get version 10, F will get version 10, C will get version 20 and so on.

![Example of the output when running the script](https://3225702404-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LD7tTgZ-5g3UehqnyY6%2F-LdG4kr-a9EdHzub6-7_%2F-LdG5I7UI96AXwBu0tzC%2FCBME%20-%20Update%20Learner%20Level.png?alt=media\&token=a7b761a1-da1a-43b8-8ec4-0248313a3b8a)

5\.     Once that script runs the last thing to do is to clear the cbme\_objective\_tree cache for the course that we are dealing with.  The easiest way to do this is through the interface:\


* Login to your install as an administrator who has admin access to the course that we are updating
* Navigate to Admin > Manage Courses (Programs) > Select the course that you are using > CBME tab > Import CBME Data
* Click on the Actions button on the left side above the EPA search bar and select the Edit EPAs option.&#x20;
* Whenever one of these EPAs are updated, the cache is cleared for the course. So all that is required is to just click save on the first EPA that is listed and the cache will be cleared. You **do not** need to change any of the text in the EPA that you just saved. Simply saving what is already there will sufficiently clear the cache.

### Conclusion

Once you have cleared the cache for the course then the learners should see the updates on their dashboard. As mentioned before, it's recommended that you do this process in a test environment first so that you can verify the data is the way you would like it before updating production.  If you do run into the scenario where you updated a learner to the wrong version then you can always repeat this process and update them to the correct version.&#x20;

\
The easiest way to verify that the learners are in the correct version would be to login as some of the learners that were updated and compare their dashboards to the version they were set to.  Usually there is a difference between one version to the next whether it be the EPA titles or the number of EPAs.
