# Guide to Adding New Statements
So you want to add some new xAPI statements? Awesome 🤘! If you're not comfortable with PHP or can't get to grips with Moodle's logstore, then you should probably ask for the new statement in a new issue via [our Github issue tracker](https://github.com/xAPI-vle/moodle-logstore_xapi/issues), hopefully someone will kindly offer their time to add the statement for you.

If you're comfortable with PHP and the logstore, and your willing to generously lend your time here, then thank you, we really appreciate it! ❤️️  To get started, you'll need to [install the plugin using Git](install-with-git.md). Once you've installed the plugin using Git, all of the code in this Git repository will be in the "admin/tool/log/store/xapi" directory path from the root directory of your Moodle installation.

Before you get stuck in, we need to create a new Git branch so that your changes are easy to review and more likely to get merged. Open your terminal, change to the directory of the plugin ("admin/tool/log/store/xapi"), and then create the branch using `git checkout master && git pull && git checkout -b A_BRANCH_NAME_FOR_YOUR_CHANGES`.

Now we need to decide which event to use to create the statement. You might decide that you can add the statement to one of the [events we already support](../src/transformer/handler.php), if this is the case, you may actually want to change the statement for that event rather than insert a new statement, in which case you should switch to [our guide for changing statements](change-statements.md). However, you may decide that you need to add the statement to an event that isn't currently supported in this plugin, in which case you can switch to [our guide for creating new events](new-events.md).

If you're adding a new statement to an event that's already supported, hopefully you know which event you want to add the statement to, in which case you can check [the `get_event_function_map` function](/src/transformer/get_event_function_map.php) to find the transformer function that the event is being mapped to. For example, the `\core\event\course_completed'` logstore event is mapped to the `core\course_completed` transformer which can be found in [the `/src/transformer/core/course_completed` file](../src/transformer/core/course_completed), notice that `core\course_completed` is the path of the event function in [the `/src/transformer` directory](../src/transformer).

Now that you've found the transformer function you need to modify, simply add your statement(s) to the array of returned statements from the transformer function. You can then test those changes by running `./vendor/bin/phpunit` in your terminal from inside the plugin directory. You'll probably need to change the tests a little in order for them to pass since the tests check the properties and values of the statements. To change the tests, take a look in [the `tests` directory of the plugin](../tests), you'll find that it's structured very similarly to [the `src/transformer` directory](../src/transformer). You should also notice that each test is made up of 4 files, this is explained in [our testing guide](testing.md).

When your tests are all green ✅, it's time to commit your changes and make a pull request. To commit all of your changes you can run `git add -A && git commit -am "A_DESCRIPTION_OF_YOUR_CHANGES && git push"`. To make a pull request you can follow [Github's guide for creating a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). Once your pull request is made, your changes will be reviewed and merged by a maintainer.

Hopefully this guide has helped you get your new statement, if not, it sounds like we could have done better with this guide, so let us know by creating a new issue on [our Github issue tracker](https://github.com/xAPI-vle/moodle-logstore_xapi/issues). If this guide totally kicked ass, send us some love ❤️ in [our Gitter chat room](https://gitter.im/LearningLocker/learninglocker).